|
|
MEEN 292 - Spring 2005 | home
Computer Program #1 | Computer Program #2 | Computer Program #3 | Computer Program #4 | Computer Program #5 | Computer Program #6 | Computer Program #7 | Computer Program #8
Computer Program #5
Two-Link Robot Arm
The figure below shows a two-link robot arm. One end of the arm is fixed at the origin of the coordinate system, and the other end is at coordinate (x,y). The arm's positioning actuators control the link angles theta and phi, as shown. In terms of theta and phi, the coordinates of the joint between links are (a, b), where
a = L1 cos(theta)
b = L1 sin(theta)
The coordinates (x, y) are given by
x - a = L2 cos(theta + phi)
y - b = L2 sin(theta + phi)
Combining, we see that
x = L1 cos(theta) + L2 cos(theta + phi)
y = L1 sin(theta) + L2 sin(theta + phi)
In order to position the end of the second link properly at coordinates (x, y), the controller must determine the proper settings for the actuators at the joints, i.e., angles theta and phi.
Write a C++ program that will accept as input the values of L1, L2, x, and y and will calculate the proper values of theta and phi. Note that depending on the input data, there may be zero, one, or two solutions for each case. You need calculate only one solution for each dataset. Empower your program to be able to handle an arbitrary number of datasets, printing the input and output data for each case under column headings.
![]() |