-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw_robot.m
More file actions
35 lines (30 loc) · 1.69 KB
/
draw_robot.m
File metadata and controls
35 lines (30 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function draw_robot(x, y)
% Draw the body of the robot (rectangle)
bodyWidth = 0.6; % Width of the robot body
bodyLength = 0.3; % Length of the robot body
bodyX = [-bodyWidth/2, bodyWidth/2, bodyWidth/2, -bodyWidth/2]; % Robot body outline
bodyY = [-bodyLength/2, -bodyLength/2, bodyLength/2, bodyLength/2]; % Robot body outline
% Draw the robot body in blue
fill(x + bodyX, y + bodyY, [0, 0, 1], 'EdgeColor', 'k'); % Body color (blue)
% Draw the wheels (circles)
wheelRadius = 0.085; % Increased radius of the wheels
% Positions of the wheels (adjusted to be closer to the body)
wheelPositions = [
-bodyWidth/2 + 0.05, -bodyLength/2 - 0.05; % Left front
bodyWidth/2 - 0.1, -bodyLength/2 - 0.05; % Right front
-bodyWidth/2 + 0.05, bodyLength/2 - 0.02; % Left rear
bodyWidth/2 - 0.1, bodyLength/2 - 0.02 % Right rear
];
% Draw wheels at each corner
for i = 1:size(wheelPositions, 1)
rectangle('Position', [x + wheelPositions(i, 1), y + wheelPositions(i, 2), wheelRadius, wheelRadius], ...
'Curvature', [1, 1], 'FaceColor', 'k'); % Wheels are black
end
% Draw the circular top mount (in orange) centered on the body
topMountRadius = 0.13; % Radius of the top mount
topMountX = x; % X position for the center of the top mount
topMountY = y; % Y position at the center of the body
% Draw the top mount
rectangle('Position', [topMountX - topMountRadius, topMountY - topMountRadius, topMountRadius * 2, topMountRadius * 2], ...
'Curvature', [1, 1], 'FaceColor', [1, 0.5, 0], 'EdgeColor', 'k'); % Circle in orange
end