Problem 1. Design (but don\'t implement) a program that determines the absolute
ID: 639096 • Letter: P
Question
Problem 1. Design (but don't implement) a program that determines the absolute position of a robot arm after the user inputs the arm motion desired. The user input will be relative to the robot arms current location, while the absolute position will be in terms of fixed coordinates. The coordinates will be Cartesian, with the robot arm fixed at the (0,0) point (the origin). The robot can reach no farther than 10 units out when fully extended, and cannot contract to within 2 units of the origin. When the ending position is outside the robots reach, the robot should not move, and the program issue an error statement. The robot arm starts at the point (10, 0). The program should end when the arm is returned to this position. Determine which variables you will need to create in the program, and give them appropriate names. Design a test for your program.Explanation / Answer
a=1;
x(1)=10;
y(1)=0;
i=1;
a=1;
while a
i=i+1;
x(i)= input('please enter the distance you wnat to move in x direction(with sign) ');
x(i)=x(i)+x(i-1);
y(i)= input('please enter the distance you wnat to move in y direction(with sign) ');
y(i)=y(i)+y(i-1);
while (((x(i)*x(i)+y(i)*y(i))>100)+((x(i)*x(i)+y(i)*y(i))<4))
disp(' robot can not move to that place, error');
x(i)= input('please enter the distance you wnat to move in x direction(with sign) ');
x(i)=x(i)+x(i-1);
y(i)= input('please enter the distance you wnat to move in y direction(with sign) ');
y(i)=y(i)+y(i-1);
end
if ((x(i)==10 )*(y(i)==0))
a=0;
end
end
plot(x,y,'-');
title('Graph of robot ar, movement')
xlabel('x coordinate') % x-axis label
ylabel('y coordinate')
legend('arm movement')
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.