



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This lecture handout is from Embedded Intelligent Robotics course. It includes: Inverse Kinematics for Robotic Arm, Law of Cosines Inverse Kinematics, Geometric Representation, Random Angle Method, Conclusions, Target, Transforms
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!
dx = dx - _distance_rand * cos( _theta1_rand ); dy = dy - _distance_rand * sin( _theta1_rand ); // Calculate second angle from first angle and segment _theta2_rand = atan2(dy, dx); //} else { // If the distance is greater than arm length, arm is straight // _theta1_rand = _theta2_rand = int(theta); //} } void solve() { // Compute difference between start and end points float dx = (targetX - _points_x[0]); float dy = (targetY - _points_y[0]); cout << "Difference of (x, y): " << "(" << dx << ", " << dy << ")" << endl; // Compute distance between start and end points float dist = sqrt(dxdx + dydy); cout << "Distance from base to target: " << dist << endl; // Compute angle between start and end points float theta = atan2(dy,dx); float temp = (theta * RAD_CONVERT); cout << "Angle between base and target: " << temp << endl; // Clamp the distance float totalLength = _distance * 2; if( dist < totalLength ) { // Calculate first angle: http://en.wikipedia.org/wiki/Dot_product#Geometric_interpretation _theta1 = acos( dist / totalLength ) + theta; dx = dx - _distance * cos( _theta1 ); dy = dy - _distance * sin( _theta1 ); // Calculate second angle from first angle and segment _theta2 = atan2(dy, dx); } else { // If the distance is greater than arm length, arm is straight _theta1 = _theta2 = int(theta); }
//cout << "Angle between base and target: " << temp << endl; /* // Compute positions from angles _points[1].x = _points[0].x + Math.cos( _theta1 ) * _distance; _points[1].y = _points[0].y + Math.sin( _theta1 ) * _distance; _points[2].x = _points[1].x + Math.cos( _theta2 ) * _distance; _points[2].y = _points[1].y + Math.sin( _theta2 ) * _distance; } */ }
int main() { int xVal, yVal;
cout << "Your initial target coords are (" << targetX << ", " << targetY << ") in mm" << endl; cout << "Enter the X-coordinate (mm) for the target:" << endl; cin >> xVal; cout << "Enter the Y-coordinate (mm) for the target:" << endl; cin >> yVal;
targetX = float(xVal); targetY = float(yVal);
cout << "Your target coordinates are (" << xVal << ", " << yVal << ") in mm" << endl; cout << "Your float target coords are (" << targetX << ", " << targetY << ") in mm" << endl;
solve(); float temp1 = (_theta1 * RAD_CONVERT); float temp2 = (_theta2 * RAD_CONVERT); cout << "Theta 1 is " << temp1 << endl << "Theta 2 is " << temp2 << endl;
// Try random angle measurement, see how many iterations until at previously calculated best angles cout << "Random angle search: " << endl; randSearch(); float temp1_rand = (_theta1_rand * RAD_CONVERT); float temp2_rand = (_theta2_rand * RAD_CONVERT); cout << "Theta 1 rand is " << temp1_rand << endl << "Theta 2 rand is " << temp2_rand << endl;
cout << "It took " << randIter << " iterations to match calculated IK values" << endl; }