The Fortran program rbtjnts.f implements the analytical solution. You should be able to look at rbtjnts.f and have a pretty good idea how the program works. We will talk about the individual lines in the program in just a moment.
! This is the file "rbtjnts.f". program rbtjnts ! Written by JCDiaz June 30 1996. ! ! This program determines the X-Y position of a robotic elbow joint. ! ! Input: ! Predetermined. ! -- The X-Y) position of the shoulder joint ! -- The length of the arm. ! The user is prompted by the program to enter: ! -- The angle of the shoulder joint in degrees ! counterclockwise from the positive X axis. ! Output: ! The output is to the screen: ! -- The X-Y position of a robotic elbow joint ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! shoulderx and shouldery are the X and Y coordinates of the shoulder joint. ! arm is the length of the robotic arm, in meters. ! ! alphad is the angle of the shoulder joint, measured in degrees. ! alphar is the angle of the shoulder joint, measured in radians. ! ! elbowx and elbowy are the x and y coordinates of the elbow joint. implicit none ! no undefined variables real :: shoulderx, shouldery real :: arml real :: alphad, alphar real :: elbowx, elbowy real, parameter :: pi = 3.14159 ! Declares pi to be a constant. ! Set up the known values. shoulderx = 0.0 shouldery = 1.45 arml = 0.343 ! Request the angle of the shoulder joint from the user. print *, 'Enter the angle of the shoulder joint (in degrees): ' read *, alphad ! Convert to radians. alphar = alphad * (pi / 180.0) ! Determine the (x, y) position of the elbow joint. elbowx = shoulderx + (arml * sin(alphar)) elbowy = shouldery - (arml * cos(alphar)) ! Print out the results. print *, 'The X coordinate of the elbow joint is ', elbowx print *, 'The Y coordinate of the elbow joint is ', elbowY end ! End of file.
Take a moment to read the program and try to understand how it determines the position of the robotic elbow joint. Don't worry if you don't ``know'' how to write Fortran. Using your own knowledge of the problem, you should be able to figure out, more or less, what the programs do and how they do it.