Carte esclave gros robot

Dependencies:   mbed Herkulex_Library_2019 ident_crac actions_Pr

Files at this revision

API Documentation at this revision

Comitter:
gein
Date:
Fri Apr 22 16:14:30 2022 +0000
Parent:
53:b7d2682fba44
Commit message:
base bras mesure

Changed in this revision

Actionneurs/herkulex_rob.cpp Show annotated file Show diff for this revision Revisions of this file
Herkulex_Library_2019.lib Show annotated file Show diff for this revision Revisions of this file
actions_Pr.lib Show annotated file Show diff for this revision Revisions of this file
ident_crac.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
diff -r b7d2682fba44 -r 529b24478996 Actionneurs/herkulex_rob.cpp
--- a/Actionneurs/herkulex_rob.cpp	Sat Jul 17 11:08:16 2021 +0000
+++ b/Actionneurs/herkulex_rob.cpp	Fri Apr 22 16:14:30 2022 +0000
@@ -9,8 +9,8 @@
             setTorque(2 ,TORQUE_ON ,1);setTorque(5 ,TORQUE_ON ,1);
             setTorque(3 ,TORQUE_ON ,1);setTorque(6 ,TORQUE_ON ,1);
             
-            setTorque(1 ,TORQUE_ON ,2);setTorque(4 ,TORQUE_ON ,2);
-            setTorque(2 ,TORQUE_ON ,2);setTorque(5 ,TORQUE_ON ,2);
+            setTorque(101 ,TORQUE_ON ,1);setTorque(4 ,TORQUE_ON ,2);
+            setTorque(102 ,TORQUE_ON ,1);setTorque(5 ,TORQUE_ON ,2);
             setTorque(3 ,TORQUE_ON ,2);setTorque(6 ,TORQUE_ON ,2);
             
             setTorque(1 ,TORQUE_ON ,3);setTorque(4 ,TORQUE_ON ,3);
@@ -20,6 +20,7 @@
             setTorque(7 ,TORQUE_ON,4);setTorque(10 ,TORQUE_ON,4);
             
             setTorque(8 ,TORQUE_ON,4);setTorque(9  ,TORQUE_ON,4);setTorque(11 ,TORQUE_ON,4);
+            
 }
 
 void verouillage_torque(void)  //débloquer les servomoteurs
diff -r b7d2682fba44 -r 529b24478996 Herkulex_Library_2019.lib
--- a/Herkulex_Library_2019.lib	Sat Jul 17 11:08:16 2021 +0000
+++ b/Herkulex_Library_2019.lib	Fri Apr 22 16:14:30 2022 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/CRAC-Team/code/Herkulex_Library_2019/#c56de4781963
+https://os.mbed.com/teams/CRAC-Team/code/Herkulex_Library_2019/#b3c14933d596
diff -r b7d2682fba44 -r 529b24478996 actions_Pr.lib
--- a/actions_Pr.lib	Sat Jul 17 11:08:16 2021 +0000
+++ b/actions_Pr.lib	Fri Apr 22 16:14:30 2022 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/CRAC-Team/code/actions_Pr/#f052129d3b4e
+https://os.mbed.com/teams/CRAC-Team/code/actions_Pr/#dd39b63a012a
diff -r b7d2682fba44 -r 529b24478996 ident_crac.lib
--- a/ident_crac.lib	Sat Jul 17 11:08:16 2021 +0000
+++ b/ident_crac.lib	Fri Apr 22 16:14:30 2022 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/CRAC-Team/code/ident_crac/#55036d818d21
+https://os.mbed.com/teams/CRAC-Team/code/ident_crac/#03f028eacefe
diff -r b7d2682fba44 -r 529b24478996 main.cpp
--- a/main.cpp	Sat Jul 17 11:08:16 2021 +0000
+++ b/main.cpp	Fri Apr 22 16:14:30 2022 +0000
@@ -5,17 +5,29 @@
 
 CAN can(PB_8,PB_9,1000000); // Rx&Tx pour le CAN
 
-Serial pc(USBTX,USBRX);
+
+
+Serial pc(USBTX,USBRX,115200);
 
+DigitalOut me(PA_4,1);
+char data[2]= {0x75};
+CANMessage tx_msg(0x732,data,1,CANData,CANStandard);
 CANMessage msgRxBuffer[SIZE_FIFO];
 unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN
 signed char FIFO_lecture=0;//Position du fifo de lecture des messages CAN
 unsigned char EtatGameEnd=0, EtatGameStart = 0, EtatGameRecalage = 0;
 unsigned short ackFinAction = 0;
-char bras_choix=0;
+
+AnalogIn avant_droit(PB_0);//1
+AnalogIn avant_gauche(PB_1);//A
+CANMessage tx_message;
+char bidon[8];
+
+char bras_choix=0,num_ca=0,msg_carre=0;
 void initialisation_CAN (void) ;
 
 
+
 void canProcessRx(void);
 
 /*********************************************************************************************/
@@ -24,9 +36,8 @@
 /*********************************************************************************************/
 void canRx_ISR (void)
 {
-    if (can.read(msgRxBuffer[FIFO_ecriture])) 
-    {  
-        FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO;        
+    if (can.read(msgRxBuffer[FIFO_ecriture])) {
+        FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO;
     }
 }
 
@@ -34,31 +45,35 @@
 {
     can.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN
     SendRawId(ALIVE_ACTIONNEURS_AVANT);
+    CANMessage tx_message(0x222, bidon, 2, CANData, CANStandard);
     servo_interrupt_en(); //permettre les interuptions
     wait(1);
     deverouillage_torque();
+    setTorque(101,TORQUE_ON,2);
+    setTorque(4,TORQUE_ON,2);
+    setTorque(102,TORQUE_ON,2);
+    setTorque(5,TORQUE_ON,2);
     pc.printf("\nLAUNCHED\n\r");
     //on rentre tous les bras dans le robot dans le vagin de sa mere
-    gabarit_robot_gauche();
-    wait_ms(300);
-    gabarit_robot_droit();
-    wait_ms(300);
-    gabarit_robot_manche();
-    wait_ms(300);
+//    gabarit_robot_gauche();
+//    wait_ms(300);
+//    gabarit_robot_droit();
+//    wait_ms(300);
+//    gabarit_robot_manche();
+//    wait_ms(300);
     //DigitalIn cap2(PC_14);
-    SendRawId(CHECK_ACTIONNEURS_AVANT);
-    while(1) 
-    {
+//    SendRawId(CHECK_ACTIONNEURS_AVANT);
+    while(1) {
         canProcessRx();
-        f_mesure();//dt35
-        
-        selection_bras_attraper();
-        selection_bras_relacher();
-        automate_manche_air_haut();
-        automate_manche_air_bas();
-        automate_manche_air_moy();
-        selection_bras_prepa();
-        selection_bras_poser();
+//        f_mesure();//dt35
+        traitement();
+//        selection_bras_attraper();
+//        selection_bras_relacher();
+//        automate_manche_air_haut();
+//        automate_manche_air_bas();
+//        automate_manche_air_moy();
+//        selection_bras_prepa();
+//        selection_bras_poser();
         /*
         automate_bras_attraper_1();
         automate_bras_relacher_1();
@@ -69,6 +84,10 @@
         */
         //automate_manche_air() ;
         /*automate_position_lidar();*/
+        tx_message.data[1] = avant_droit.read() * 260;
+        tx_message.data[0] = avant_gauche.read() * 260;
+        can.write(tx_message);
+        wait_ms(20);
     }
 }
 //fin du main
@@ -92,8 +111,7 @@
     if(FIFO_occupation!=0) {
         int identifiant=msgRxBuffer[FIFO_lecture].id;
 
-        switch(identifiant) 
-        {
+        switch(identifiant) {
             case GLOBAL_START:
                 EtatGameStart = 1;
                 EtatGameEnd = 0;
@@ -101,7 +119,7 @@
             case RECALAGE_START :
                 EtatGameRecalage = 1;
                 break;
-                
+
             case INSTRUCTION_END_MOTEUR:
                 ackFinAction = msgRxBuffer[FIFO_lecture].data[0]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[1])<<8);
                 break;
@@ -164,118 +182,151 @@
                 break;
 
 //----------------------------------------------------------------cases test-----------------------------------------------------------------//
-                
+
             case TEST_BRAS_A:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
                 aut_bras_av_3_at = 0;
                 break;
-                
+
             case TEST_BRAS_B:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
                 aut_bras_av_3_re = 0;
                 break;
-                
+
             case TEST_BRAS_C:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
                 aut_bras_av_3_at = 1;
                 break;
-                
+
             case TEST_BRAS_D:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
                 aut_bras_av_3_re = 1;
                 break;
-                
+
             case TEST_BRAS_1:
                 test_BRAS_1();
                 break;
-                
+
             case TEST_BRAS_2:
-                test_BRAS_2();  
+                test_BRAS_2();
                 break;
-                
+
             case TEST_BRAS_3:
-                test_BRAS_3();  
+                test_BRAS_3();
                 break;
-                
-            case TEST_BRAS_4:  
-                test_BRAS_4(); 
+
+            case TEST_BRAS_4:
+                test_BRAS_4();
                 break;
-                
-            case TEST_BRAS_5:   
+
+            case TEST_BRAS_5:
                 break;
-                
-            case TEST_BRAS_6:  
+
+            case TEST_BRAS_6:
                 break;
-////////////////////////////////////////////CASE DE COMPETITIONS/////////////////////////////////////////////   
+////////////////////////////////////////////CASE DE canPETITIONS/////////////////////////////////////////////
             case BRAS_AT:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
-                aut_bras_av_at = 1; 
+                aut_bras_av_at = 1;
                 break;
-            
+
             case BRAS_RE:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
                 aut_bras_av_re = 1;
                 break;
-            
+
             case BRAS_PREPA:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
-                aut_bras_av_prepa = 1; 
+                aut_bras_av_prepa = 1;
                 break;
-        
+
             case BRAS_POSE:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
                 aut_bras_av_pose = 1;
                 break;
-              
+
             case GABARIT_ROBOT:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 gabarit_robot_droit();
                 gabarit_robot_gauche();
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
                 break;
-            
+
             case AUTOMATE_MANCHE_HAUT:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
                 aut_manche_haut = 1;
-                break;  
-            
+                break;
+
             case AUTOMATE_MANCHE_BAS:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
                 aut_manche_bas = 1;
                 break;
-                
+
             case AUTOMATE_MANCHE_MOY :
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 bras_choix = msgRxBuffer[FIFO_lecture].data[0];
                 aut_manche_moy = 1;
                 break ;
-                
+
             case PAVILLON_DEPLOYE :
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 pavilon_deploye();
                 break ;
-                
+
             case LECTURE_GIROUETTE :
                 unsigned char port_final ;
                 port_final = lecture_girouette() ;
                 //if( port_final != 2)
-                    SendMsgCan(VALEUR_GIROUETTE, &port_final, sizeof(char)) ;
+                SendMsgCan(VALEUR_GIROUETTE, &port_final, sizeof(char)) ;
                 break ;
-                
+
             case TEST_LECTURE_GIROUETTE :
                 test_lecture_girou() ;
                 break ;
-                 
+            case BF_RANGER:
+                msg_carre=1;
+
+                pc.printf(" ok recu ");
+                break;
+
+            case BF_PRETEST:
+                msg_carre=3;
+
+
+                break;
+
+            case BF_MESURE:
+                msg_carre=2;
+                num_ca=msgRxBuffer[FIFO_lecture].data[0];
+
+                break;
+
+            case BF_COLOR:
+                set_color(msgRxBuffer[FIFO_lecture].data[0] & 0x1);
+                break;
+
+            case BF_TEST:
+                BF_test_mesure(msgRxBuffer[FIFO_lecture].data[0] & 0x1);
+
+                break;
+            case BF_POS:
+                Interrupt2_en();
+                pc.printf(" haut: %d    ",getPos(ID_HAUT,2));
+                Interrupt2_en();
+                pc.printf(" MILLIEU: %d     ",getPos(ID_MILLIEU,2));
+
+                break;
+
             default:
                 break;
         }
@@ -283,10 +334,10 @@
     }
 }
 
-void initialisation_CAN(void) 
+void initialisation_CAN(void)
 {
     CANMessage msg_init;
-    msg_init.id = CHECK_ACTIONNEURS_AVANT;    
+    msg_init.id = CHECK_ACTIONNEURS_AVANT;
     msg_init.len=1;
     msg_init.format=CANStandard;
     msg_init.type=CANData;
diff -r b7d2682fba44 -r 529b24478996 main.h
--- a/main.h	Sat Jul 17 11:08:16 2021 +0000
+++ b/main.h	Fri Apr 22 16:14:30 2022 +0000
@@ -20,6 +20,7 @@
 extern Serial pc;
 
 extern char bras_choix;
+extern char num_ca,msg_carre;
 
 extern unsigned short ackFinAction;
 #endif
\ No newline at end of file