Direct and inverse kinematics of a scara robotic arm, based on trigonometry

Dependencies:   MODSERIAL mbed

Revision:
1:dd8fca950fed
Parent:
0:8d4438eabc82
Child:
2:47913550ec8d
diff -r 8d4438eabc82 -r dd8fca950fed main.cpp
--- a/main.cpp	Mon Oct 19 12:33:06 2015 +0000
+++ b/main.cpp	Mon Oct 19 12:40:29 2015 +0000
@@ -27,19 +27,13 @@
     double L2 = 0.26;   
     double para2 = (x*x+y*y-L1*L1-L2*L2)/(2*L1*L2);
     
-    //double theta_1 = 0.0;
-    double theta_2 = 0.0;
-    double theta_Q = 0.0;
-    
-    //double theta_2 = acos(para2)* 180 / PI;
+    double theta_2 = acos(para2)* 180 / PI;
     double theta_total = atan2 (y,x) * 180 / PI;
-    //double theta_Q = acos( (x*x+y*y+L1*L1-L2*L2) / (2*L1*sqrt(x*x+y*y)) )* 180 / PI;
+    double theta_Q = acos( (x*x+y*y+L1*L1-L2*L2) / (2*L1*sqrt(x*x+y*y)) )* 180 / PI;
     double theta_1 = theta_total - theta_Q;
     
     a = theta_1;
     b = theta_2;
-    //a = theta_1;
-    //b = theta_2;
 }
 
 
@@ -47,8 +41,8 @@
 {
     pc.baud(115200);
 
-    double theta_1 = 0.0;
-    double theta_2 = 0.0;
+    double theta_1 = 1.0;
+    double theta_2 = 1.0;
 
     double xy[2] = {0.0,0.0};