8 motor test

Dependencies:   AX12 mbed

Fork of AX12-HelloWorld by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
tedparrott6
Date:
Thu Nov 16 14:53:46 2017 +0000
Parent:
1:b12b06e2fc2d
Commit message:
NA

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b12b06e2fc2d -r 9448381519ed main.cpp
--- a/main.cpp	Thu Mar 31 12:03:04 2011 +0000
+++ b/main.cpp	Thu Nov 16 14:53:46 2017 +0000
@@ -3,12 +3,304 @@
 
 int main() {
 
-    AX12 myax12 (p9, p10, 1);
+    //Initiates all of the motors in the legs
+    AX12 m1 (p9, p10, 1);
+    AX12 m2 (p9, p10, 2);
+    AX12 m3 (p9, p10, 3);
+    AX12 m4 (p9, p10, 4);
+    AX12 m5 (p9, p10, 5);
+    AX12 m6 (p9, p10, 6);
+    AX12 m7 (p9, p10, 7);
+    AX12 m8 (p9, p10, 8);
+    Serial pc(USBTX, USBRX);
+    
+    // Sets motors to initial positions, with waits in between to ensure positions are reached
+    m3.SetGoal(150);
+    pc.printf("\n\rMotor 3 Initiated");
+    wait(1);
+    m4.SetGoal(150);
+    pc.printf("\n\rMotor 4 Initiated");
+    wait(1);
+    m1.SetGoal(150);
+    pc.printf("\n\rMotor 1 Initiated");
+    wait(1);
+    m2.SetGoal(150);
+    pc.printf("\n\rMotor 2 Initiated");
+    wait(1);
+    m5.SetGoal(150);
+    pc.printf("\n\rMotor 5 Initiated");
+    wait(1);
+    m6.SetGoal(150);
+    pc.printf("\n\rMotor 6 Initiated");
+    wait(1);
+    m7.SetGoal(150);
+    pc.printf("\n\rMotor 7 Initiated");
+    wait(1);
+    m8.SetGoal(150);
+    pc.printf("\n\rMotor 8 Initiated");
+    wait(1);
 
     while (1) {
-        myax12.SetGoal(0);    // go to 0 degrees
-        wait (2.0);
-        myax12.SetGoal(300);  // go to 300 degrees
-        wait (2.0);
+        
+        // Begins loop by sending each joint to key locations at appropriate speeds
+        
+        //m4.SetCRSpeed(0.00489);
+        //m3.SetCRSpeed(0.05381);
+        //m2.SetCRSpeed(0.0349);
+        //m1.SetCRSpeed(0.0083);
+        m4.SetGoal(132);
+        m3.SetGoal(136);
+        m2.SetGoal(142.87);
+        m1.SetGoal(151.7);
+        pc.printf("\n\r1");
+        wait(0.1);
+        
+        //m5.SetCRSpeed(0.0273);
+        //m6.SetCRSpeed(0.086);
+        //m7.SetCRSpeed(0.0671);
+        //m8.SetCRSpeed(0.0189);
+        m5.SetGoal(152);
+        m6.SetGoal(208);
+        m7.SetGoal(179);
+        m8.SetGoal(143);
+        pc.printf("\n\r2");
+        wait(0.2);
+        
+        //m4.SetCRSpeed(0.01467);
+        //m3.SetCRSpeed(0.02933);
+        //m2.SetCRSpeed(0.0366);
+        //m1.SetCRSpeed(0.0087);
+        m4.SetGoal(136);
+        m3.SetGoal(128);
+        m2.SetGoal(152.85);
+        m1.SetGoal(149.32);
+        pc.printf("\n\r3");
+        wait(0.4);
+        
+        //m4.SetCRSpeed(0.02569);
+        //m3.SetCRSpeed(0.01834);
+        //m2.SetCRSpeed(0.021);
+        //m1.SetCRSpeed(0.005);
+        m4.SetGoal(143);
+        m3.SetGoal(133);
+        m2.SetGoal(158.57);
+        m1.SetGoal(147.96);
+        pc.printf("\n\r4");
+        wait(0.1);
+        
+        //m5.SetCRSpeed(0.0489);
+        //m6.SetCRSpeed(0.0342);
+        //m7.SetCRSpeed(0.0587);
+        //m8.SetCRSpeed(0.0147);
+        m5.SetGoal(162);
+        m6.SetGoal(215);
+        m7.SetGoal(167);
+        m8.SetGoal(146);
+        pc.printf("\n\r5");
+        wait(0.3);
+        
+        //m4.SetCRSpeed(0.0212);
+        //m3.SetCRSpeed(0.01467);
+        //m2.SetCRSpeed(0.007);
+        //m1.SetCRSpeed(0.0017);
+        //m5.SetCRSpeed(0.022);
+        //m6.SetCRSpeed(0.0587);
+        //m7.SetCRSpeed(0.0416);
+        //m8.SetCRSpeed(0.0098);
+        m4.SetGoal(156);
+        m3.SetGoal(142);
+        m2.SetGoal(162.88);
+        m1.SetGoal(146.94);
+        m5.SetGoal(171);
+        m6.SetGoal(191);
+        m7.SetGoal(150);
+        m8.SetGoal(150);
+        pc.printf("\n\r6");
+        wait(0.6);
+        
+        //m5.SetCRSpeed(0.0073);
+        //m6.SetCRSpeed(0.1174);
+        //m7.SetCRSpeed(0);
+        //m8.SetCRSpeed(0);
+        m5.SetGoal(172);
+        m6.SetGoal(175);
+        m7.SetGoal(150);
+        m8.SetGoal(150);
+        pc.printf("\n\r7");
+        wait(0.2);
+        
+        //m5.SetCRSpeed(0.0073);
+        //m6.SetCRSpeed(0.0881);
+        //m7.SetCRSpeed(0.0037);
+        //m8.SetCRSpeed(0);
+        m5.SetGoal(170);
+        m6.SetGoal(151);
+        m7.SetGoal(149);
+        m8.SetGoal(150);
+        pc.printf("\n\r8");
+        wait(0.1);
+        
+        //m4.SetCRSpeed(0.01467);
+        //m3.SetCRSpeed(0.00734);
+        //m2.SetCRSpeed(0.0106);
+        //m1.SetCRSpeed(0.0025);
+        m4.SetGoal(158);
+        m3.SetGoal(141);
+        m2.SetGoal(164.33);
+        m1.SetGoal(146.6);
+        pc.printf("\n\r9");
+        wait(0.2);
+        
+        //m4.SetCRSpeed(0.011);
+        //m3.SetCRSpeed(0.02935);
+        //m2.SetCRSpeed(0.0264);
+        //m1.SetCRSpeed(0.0062);
+        m4.SetGoal(161);
+        m3.SetGoal(133);
+        m2.SetGoal(157.14);
+        m1.SetGoal(148.3);
+        pc.printf("\n\r10");
+        wait(0.1);
+        
+        //m5.SetCRSpeed(0.0073);
+        //m6.SetCRSpeed(0.0147);
+        //m7.SetCRSpeed(0.0073);
+        //m8.SetCRSpeed(0);
+        m5.SetGoal(169);
+        m6.SetGoal(153);
+        m7.SetGoal(150);
+        m8.SetGoal(150);
+        pc.printf("\n\r11");
+        wait(0.2);
+        
+        //m5.SetCRSpeed(0.0049);
+        //m6.SetCRSpeed(0.0538);
+        //m7.SetCRSpeed(0.0342);
+        //m8.SetCRSpeed(0.0098);
+        m5.SetGoal(168);
+        m6.SetGoal(164);
+        m7.SetGoal(157);
+        m8.SetGoal(148);
+        pc.printf("\n\r12");
+        wait(0.1);
+        
+        //m4.SetCRSpeed(0.02726);
+        //m3.SetCRSpeed(0.08597);
+        //m2.SetCRSpeed(0.0761);
+        //m1.SetCRSpeed(0.0178);
+        m4.SetGoal(148);
+        m3.SetGoal(92);
+        m2.SetGoal(120.83);
+        m1.SetGoal(156.8);
+        pc.printf("\n\r13");
+        wait(0.2);
+        
+        //m5.SetCRSpeed(0.022);
+        //m6.SetCRSpeed(0.0294);
+        //m7.SetCRSpeed(0.0367);
+        //m8.SetCRSpeed(0.011);
+        m5.SetGoal(174);
+        m6.SetGoal(172);
+        m7.SetGoal(147);
+        m8.SetGoal(151);
+        pc.printf("\n\r14");
+        wait(0.4);
+        
+        //m5.SetCRSpeed(0.0624);
+        //m6.SetCRSpeed(0.0183);
+        //m7.SetCRSpeed(0.022);
+        //m8.SetCRSpeed(0.0037);
+        m5.SetGoal(157);
+        m6.SetGoal(167);
+        m7.SetGoal(141);
+        m8.SetGoal(152);
+        pc.printf("\n\r15");
+        wait(0.1);
+        
+        //m4.SetCRSpeed(0.04892);
+        //m3.SetCRSpeed(0.03424);
+        //m2.SetCRSpeed(0.0584);
+        //m1.SetCRSpeed(0.0133);
+        m4.SetGoal(138);
+        m3.SetGoal(85);
+        m2.SetGoal(132.77);
+        m1.SetGoal(154.08);
+        pc.printf("\n\r16");
+        wait(0.3);
+        
+        //m4.SetCRSpeed(0.02202);
+        //m3.SetCRSpeed(0.0587);
+        //m2.SetCRSpeed(0.0421);
+        //m1.SetCRSpeed(0.01);
+        //m5.SetCRSpeed(0.0212);
+        //m6.SetCRSpeed(0.0147);
+        //m7.SetCRSpeed(0.0065);
+        //m8.SetCRSpeed(0.0016);
+        m4.SetGoal(129);
+        m3.SetGoal(109);
+        m2.SetGoal(150);
+        m1.SetGoal(150);
+        m5.SetGoal(144);
+        m6.SetGoal(158);
+        m7.SetGoal(137);
+        m8.SetGoal(153);
+        pc.printf("\n\r17");
+        wait(0.6);
+        
+        //m4.SetCRSpeed(0.0073);
+        //m3.SetCRSpeed(0.11742);
+        //m2.SetCRSpeed(0);
+        //m1.SetCRSpeed(0);
+        m4.SetGoal(128);
+        m3.SetGoal(125);
+        m2.SetGoal(150);
+        m1.SetGoal(150);
+        pc.printf("\n\r18");
+        wait(0.2);
+        
+        //m4.SetCRSpeed(0.0073);
+        //m3.SetCRSpeed(0.0886);
+        //m2.SetCRSpeed(0.0052);
+        //m1.SetCRSpeed(0.0012);
+        m4.SetGoal(130);
+        m3.SetGoal(149);
+        m2.SetGoal(151.43);
+        m1.SetGoal(149.66);
+        pc.printf("\n\r19");
+        wait(0.1);
+        
+        //m5.SetCRSpeed(0.0147);
+        //m6.SetCRSpeed(0.0073);
+        //m7.SetCRSpeed(0.0073);
+        //m8.SetCRSpeed(0.0);
+        m5.SetGoal(142);
+        m6.SetGoal(159);
+        m7.SetGoal(136);
+        m8.SetGoal(153);
+        pc.printf("\n\r20");
+        wait(0.2);
+        
+        //m5.SetCRSpeed(0.011);
+        //m6.SetCRSpeed(0.0294);
+        //m7.SetCRSpeed(0.0257);
+        //m8.SetCRSpeed(0.0037);
+        m5.SetGoal(139);
+        m6.SetGoal(167);
+        m7.SetGoal(143);
+        m8.SetGoal(152);
+        pc.printf("\n\r21");
+        wait(0.1);
+        
+        //m4.SetCRSpeed(0.0073);
+        //m3.SetCRSpeed(0.01467);
+        //m2.SetCRSpeed(0.0105);
+        //m1.SetCRSpeed(0.0025);
+        m4.SetGoal(131);
+        m3.SetGoal(147);
+        m2.SetGoal(150);
+        m1.SetGoal(150);
+        pc.printf("\n\r22");
+        wait(0.2);
+        
     }
 }
\ No newline at end of file