CRAC Team / Mbed 2 deprecated carte_esclave201_petit_rob

Dependencies:   mbed Herkulex_Library_2019 actions_Gr ident_crac actions_Pr

Committer:
Artiom
Date:
Tue May 07 17:27:38 2019 +0000
Revision:
1:568955af8c2b
Parent:
0:bc74da1c502f
Child:
2:9e63099cca99
Ajout de l'envoi de commande vers la carte pompe

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Artiom 0:bc74da1c502f 1 #include "Actionneurs.h"
Artiom 0:bc74da1c502f 2 #include "ident_crac.h"
Artiom 0:bc74da1c502f 3 #include "mbed.h"
Artiom 0:bc74da1c502f 4 #include "fonctions_herkulex.h"
Artiom 1:568955af8c2b 5 #include "main.h"
Artiom 0:bc74da1c502f 6
Artiom 0:bc74da1c502f 7 #ifdef ROBOT_SMALL
Artiom 0:bc74da1c502f 8 void init_petit_robot(void)
Artiom 0:bc74da1c502f 9 {
Artiom 0:bc74da1c502f 10
Artiom 0:bc74da1c502f 11 uint8_t servos_av_gauche[4] = {RLED_ON, AV_EP_G, RLED_ON, AV_poigne_G};
Artiom 0:bc74da1c502f 12 uint8_t servos_av_centre[4] = {GLED_ON, AV_EP_C, GLED_ON, AV_poigne_C};
Artiom 0:bc74da1c502f 13 uint8_t servos_av_droite[4] = {BLED_ON, AV_EP_D, BLED_ON, AV_poigne_D};
Artiom 0:bc74da1c502f 14
Artiom 0:bc74da1c502f 15 uint16_t pos_av_gauche[2] = {520,780};//epaule,poigne520,780
Artiom 0:bc74da1c502f 16 uint16_t pos_av_centre[2] = {470,350};
Artiom 0:bc74da1c502f 17 uint16_t pos_av_droite[2] = {550,270};
Artiom 0:bc74da1c502f 18
Artiom 0:bc74da1c502f 19 uint8_t servos_ar_gauche[4] = {RLED_ON, AR_EP_G, RLED_ON, AR_poigne_G};
Artiom 0:bc74da1c502f 20 uint8_t servos_ar_centre[4] = {GLED_ON, AR_EP_C, GLED_ON, AR_poigne_C};
Artiom 0:bc74da1c502f 21 uint8_t servos_ar_droite[4] = {BLED_ON, AR_EP_D, BLED_ON, AR_poigne_D};
Artiom 0:bc74da1c502f 22
Artiom 0:bc74da1c502f 23 uint16_t pos_ar_gauche[2] = {530,780};
Artiom 0:bc74da1c502f 24 uint16_t pos_ar_centre[2] = {500,250};
Artiom 0:bc74da1c502f 25 uint16_t pos_ar_droite[2] = {430,200};
Artiom 0:bc74da1c502f 26
Artiom 1:568955af8c2b 27
Artiom 1:568955af8c2b 28 uint8_t servos_sol[4] = {GLED_ON, AR_sol, GLED_ON, AV_sol};
Artiom 1:568955af8c2b 29 uint16_t pos_sol[2] = {200,800}; //90°
Artiom 1:568955af8c2b 30
Artiom 0:bc74da1c502f 31 int speed=100;
Artiom 1:568955af8c2b 32
Artiom 0:bc74da1c502f 33 deverouillage_torque();
Artiom 0:bc74da1c502f 34 positionControl_Mul_ensemble_complex(2,speed,servos_av_gauche, pos_av_gauche,3);
Artiom 0:bc74da1c502f 35 positionControl_Mul_ensemble_complex(2,speed,servos_av_centre, pos_av_centre,2);
Artiom 0:bc74da1c502f 36 positionControl_Mul_ensemble_complex(2,speed,servos_av_droite, pos_av_droite,1);
Artiom 0:bc74da1c502f 37
Artiom 0:bc74da1c502f 38 positionControl_Mul_ensemble_complex(2,speed,servos_ar_gauche, pos_ar_gauche,1);
Artiom 0:bc74da1c502f 39 positionControl_Mul_ensemble_complex(2,speed,servos_ar_centre, pos_ar_centre,2);
Artiom 0:bc74da1c502f 40 positionControl_Mul_ensemble_complex(2,speed,servos_ar_droite, pos_ar_droite,3);
Artiom 1:568955af8c2b 41
Artiom 1:568955af8c2b 42 positionControl_Mul_ensemble_complex(2,speed,servos_sol, pos_sol,4);
Artiom 0:bc74da1c502f 43 }
Artiom 1:568955af8c2b 44
Artiom 0:bc74da1c502f 45 void presentoir_avant(void)
Artiom 0:bc74da1c502f 46 {
Artiom 0:bc74da1c502f 47 uint8_t servos_av_gauche[4] = {RLED_ON, AV_EP_G, RLED_ON, AV_poigne_G};
Artiom 0:bc74da1c502f 48 uint8_t servos_av_centre[4] = {GLED_ON, AV_EP_C, GLED_ON, AV_poigne_C};
Artiom 0:bc74da1c502f 49 uint8_t servos_av_droite[4] = {BLED_ON, AV_EP_D, BLED_ON, AV_poigne_D};
Artiom 0:bc74da1c502f 50
Artiom 0:bc74da1c502f 51 uint16_t pos_av_gauche[2] = {520,490};
Artiom 0:bc74da1c502f 52 uint16_t pos_av_centre[2] = {470,512};
Artiom 0:bc74da1c502f 53 uint16_t pos_av_droite[2] = {550,540};
Artiom 0:bc74da1c502f 54
Artiom 1:568955af8c2b 55 int speed=25;
Artiom 0:bc74da1c502f 56
Artiom 0:bc74da1c502f 57 deverouillage_torque();
Artiom 0:bc74da1c502f 58 positionControl_Mul_ensemble_complex(2,speed,servos_av_gauche, pos_av_gauche,3);
Artiom 0:bc74da1c502f 59 positionControl_Mul_ensemble_complex(2,speed,servos_av_centre, pos_av_centre,2);
Artiom 0:bc74da1c502f 60 positionControl_Mul_ensemble_complex(2,speed,servos_av_droite, pos_av_droite,1);
Artiom 1:568955af8c2b 61 /*
Artiom 1:568955af8c2b 62 for(char pompe=0;pompe<8;pompe++){
Artiom 1:568955af8c2b 63 can.write(CANMessage(HACHEUR_GET_ATOM, &pompe,1));
Artiom 1:568955af8c2b 64 wait(1);
Artiom 1:568955af8c2b 65 }*/
Artiom 1:568955af8c2b 66 can.write(CANMessage(HACHEUR_GET_PRESENTOIR_AV));
Artiom 1:568955af8c2b 67 }
Artiom 0:bc74da1c502f 68
Artiom 0:bc74da1c502f 69 void presentoir_arriere(void)
Artiom 0:bc74da1c502f 70 {
Artiom 0:bc74da1c502f 71 uint8_t servos_ar_gauche[4] = {RLED_ON, AR_EP_G, RLED_ON, AR_poigne_G};
Artiom 0:bc74da1c502f 72 uint8_t servos_ar_centre[4] = {GLED_ON, AR_EP_C, GLED_ON, AR_poigne_C};
Artiom 0:bc74da1c502f 73 uint8_t servos_ar_droite[4] = {BLED_ON, AR_EP_D, BLED_ON, AR_poigne_D};
Artiom 0:bc74da1c502f 74
Artiom 0:bc74da1c502f 75 uint16_t pos_ar_gauche[2] = {530,512};
Artiom 0:bc74da1c502f 76 uint16_t pos_ar_centre[2] = {500,430};
Artiom 0:bc74da1c502f 77 uint16_t pos_ar_droite[2] = {430,470};
Artiom 0:bc74da1c502f 78
Artiom 1:568955af8c2b 79 int speed=25;
Artiom 0:bc74da1c502f 80
Artiom 0:bc74da1c502f 81 deverouillage_torque();
Artiom 0:bc74da1c502f 82 positionControl_Mul_ensemble_complex(2,speed,servos_ar_gauche, pos_ar_gauche,1);
Artiom 0:bc74da1c502f 83 positionControl_Mul_ensemble_complex(2,speed,servos_ar_centre, pos_ar_centre,2);
Artiom 0:bc74da1c502f 84 positionControl_Mul_ensemble_complex(2,speed,servos_ar_droite, pos_ar_droite,3);
Artiom 0:bc74da1c502f 85
Artiom 1:568955af8c2b 86 can.write(CANMessage(HACHEUR_GET_PRESENTOIR_AR));
Artiom 1:568955af8c2b 87
Artiom 0:bc74da1c502f 88 }
Artiom 1:568955af8c2b 89
Artiom 0:bc74da1c502f 90 void balance_avant(void)
Artiom 0:bc74da1c502f 91 {
Artiom 0:bc74da1c502f 92 uint8_t servos_av_gauche[4] = {RLED_ON, AV_EP_G, RLED_ON, AV_poigne_G};
Artiom 0:bc74da1c502f 93 uint8_t servos_av_centre[4] = {GLED_ON, AV_EP_C, GLED_ON, AV_poigne_C};
Artiom 0:bc74da1c502f 94 uint8_t servos_av_droite[4] = {BLED_ON, AV_EP_D, BLED_ON, AV_poigne_D};
Artiom 0:bc74da1c502f 95
Artiom 0:bc74da1c502f 96 uint16_t pos_av_gauche[2] = {800,780};
Artiom 0:bc74da1c502f 97 uint16_t pos_av_centre[2] = {200,220};
Artiom 0:bc74da1c502f 98 uint16_t pos_av_droite[2] = {250,270};
Artiom 0:bc74da1c502f 99
Artiom 1:568955af8c2b 100 int speed=25;
Artiom 0:bc74da1c502f 101
Artiom 0:bc74da1c502f 102 deverouillage_torque();
Artiom 0:bc74da1c502f 103 positionControl_Mul_ensemble_complex(2,speed,servos_av_gauche, pos_av_gauche,3);
Artiom 0:bc74da1c502f 104 positionControl_Mul_ensemble_complex(2,speed,servos_av_centre, pos_av_centre,2);
Artiom 0:bc74da1c502f 105 positionControl_Mul_ensemble_complex(2,speed,servos_av_droite, pos_av_droite,1);
Artiom 0:bc74da1c502f 106
Artiom 0:bc74da1c502f 107 }
Artiom 0:bc74da1c502f 108 void balance_arriere(void)
Artiom 0:bc74da1c502f 109 {
Artiom 0:bc74da1c502f 110 uint8_t servos_ar_gauche[4] = {RLED_ON, AR_EP_G, RLED_ON, AR_poigne_G};
Artiom 0:bc74da1c502f 111 uint8_t servos_ar_centre[4] = {GLED_ON, AR_EP_C, GLED_ON, AR_poigne_C};
Artiom 0:bc74da1c502f 112 uint8_t servos_ar_droite[4] = {BLED_ON, AR_EP_D, BLED_ON, AR_poigne_D};
Artiom 0:bc74da1c502f 113
Artiom 0:bc74da1c502f 114 uint16_t pos_ar_gauche[2] = {820,780};
Artiom 0:bc74da1c502f 115 uint16_t pos_ar_centre[2] = {230,150};
Artiom 0:bc74da1c502f 116 uint16_t pos_ar_droite[2] = {150,200};
Artiom 0:bc74da1c502f 117
Artiom 1:568955af8c2b 118 int speed=25;
Artiom 0:bc74da1c502f 119
Artiom 0:bc74da1c502f 120 deverouillage_torque();
Artiom 0:bc74da1c502f 121 positionControl_Mul_ensemble_complex(2,speed,servos_ar_gauche, pos_ar_gauche,1);
Artiom 0:bc74da1c502f 122 positionControl_Mul_ensemble_complex(2,speed,servos_ar_centre, pos_ar_centre,2);
Artiom 0:bc74da1c502f 123 positionControl_Mul_ensemble_complex(2,speed,servos_ar_droite, pos_ar_droite,3);
Artiom 0:bc74da1c502f 124
Artiom 0:bc74da1c502f 125 }
Artiom 0:bc74da1c502f 126
Artiom 1:568955af8c2b 127 void goldenium_avant(void)
Artiom 1:568955af8c2b 128 {
Artiom 1:568955af8c2b 129 uint8_t servos_av_centre[4] = {GLED_ON, AV_EP_C, GLED_ON, AV_poigne_C};
Artiom 1:568955af8c2b 130 uint16_t pos_av_centre[2] = {200,220};
Artiom 1:568955af8c2b 131 int speed=25;
Artiom 1:568955af8c2b 132
Artiom 1:568955af8c2b 133 deverouillage_torque();
Artiom 1:568955af8c2b 134 positionControl_Mul_ensemble_complex(2,speed,servos_av_centre, pos_av_centre,2);
Artiom 1:568955af8c2b 135
Artiom 1:568955af8c2b 136 char pompe=AV_CENTRE;
Artiom 1:568955af8c2b 137 can.write(CANMessage(HACHEUR_GET_ATOM, &pompe,1));
Artiom 1:568955af8c2b 138 wait(1);
Artiom 1:568955af8c2b 139 can.write(CANMessage(HACHEUR_RELEASE_ATOM, &pompe,1));
Artiom 1:568955af8c2b 140 wait(3);
Artiom 1:568955af8c2b 141 }
Artiom 1:568955af8c2b 142
Artiom 1:568955af8c2b 143 void goldenium_arriere(void)
Artiom 1:568955af8c2b 144 {
Artiom 1:568955af8c2b 145 uint8_t servos_ar_centre[4] = {GLED_ON, AR_EP_C, GLED_ON, AR_poigne_C};
Artiom 1:568955af8c2b 146 uint16_t pos_ar_centre[2] = {230,150};
Artiom 1:568955af8c2b 147 int speed=25;
Artiom 1:568955af8c2b 148 deverouillage_torque();
Artiom 1:568955af8c2b 149 positionControl_Mul_ensemble_complex(2,speed,servos_ar_centre, pos_ar_centre,2);
Artiom 1:568955af8c2b 150
Artiom 1:568955af8c2b 151 char pompe=AR_CENTRE;
Artiom 1:568955af8c2b 152 can.write(CANMessage(HACHEUR_GET_ATOM, &pompe,1));
Artiom 1:568955af8c2b 153 wait(1);
Artiom 1:568955af8c2b 154 can.write(CANMessage(HACHEUR_RELEASE_ATOM, &pompe,1));
Artiom 1:568955af8c2b 155 wait(3);
Artiom 1:568955af8c2b 156 }
Artiom 1:568955af8c2b 157
Artiom 1:568955af8c2b 158 void accelerateur_avant(void)
Artiom 1:568955af8c2b 159 {
Artiom 1:568955af8c2b 160 uint8_t servos_av_gauche[4] = {RLED_ON, AV_EP_G, RLED_ON, AV_poigne_G};
Artiom 1:568955af8c2b 161 uint8_t servos_av_centre[4] = {GLED_ON, AV_EP_C, GLED_ON, AV_poigne_C};
Artiom 1:568955af8c2b 162 uint8_t servos_av_droite[4] = {BLED_ON, AV_EP_D, BLED_ON, AV_poigne_D};
Artiom 1:568955af8c2b 163
Artiom 1:568955af8c2b 164 uint16_t pos_av_gauche[2] = {800,490};
Artiom 1:568955af8c2b 165 uint16_t pos_av_centre[2] = {200,220};
Artiom 1:568955af8c2b 166 uint16_t pos_av_droite[2] = {250,540};
Artiom 1:568955af8c2b 167
Artiom 1:568955af8c2b 168 int speed=25;
Artiom 1:568955af8c2b 169
Artiom 1:568955af8c2b 170 deverouillage_torque();
Artiom 1:568955af8c2b 171 positionControl_Mul_ensemble_complex(2,speed,servos_av_gauche, pos_av_gauche,3);
Artiom 1:568955af8c2b 172 positionControl_Mul_ensemble_complex(2,speed,servos_av_centre, pos_av_centre,2);
Artiom 1:568955af8c2b 173 positionControl_Mul_ensemble_complex(2,speed,servos_av_droite, pos_av_droite,1);
Artiom 1:568955af8c2b 174 }
Artiom 1:568955af8c2b 175 void accelerateur_arriere(void)
Artiom 1:568955af8c2b 176 {
Artiom 1:568955af8c2b 177 uint8_t servos_ar_gauche[4] = {RLED_ON, AR_EP_G, RLED_ON, AR_poigne_G};
Artiom 1:568955af8c2b 178 uint8_t servos_ar_centre[4] = {GLED_ON, AR_EP_C, GLED_ON, AR_poigne_C};
Artiom 1:568955af8c2b 179 uint8_t servos_ar_droite[4] = {BLED_ON, AR_EP_D, BLED_ON, AR_poigne_D};
Artiom 1:568955af8c2b 180
Artiom 1:568955af8c2b 181 uint16_t pos_ar_gauche[2] = {820,512};
Artiom 1:568955af8c2b 182 uint16_t pos_ar_centre[2] = {230,150};
Artiom 1:568955af8c2b 183 uint16_t pos_ar_droite[2] = {150,470};
Artiom 1:568955af8c2b 184
Artiom 1:568955af8c2b 185 int speed=25;
Artiom 1:568955af8c2b 186
Artiom 1:568955af8c2b 187 deverouillage_torque();
Artiom 1:568955af8c2b 188 positionControl_Mul_ensemble_complex(2,speed,servos_ar_gauche, pos_ar_gauche,1);
Artiom 1:568955af8c2b 189 positionControl_Mul_ensemble_complex(2,speed,servos_ar_centre, pos_ar_centre,2);
Artiom 1:568955af8c2b 190 positionControl_Mul_ensemble_complex(2,speed,servos_ar_droite, pos_ar_droite,3);
Artiom 1:568955af8c2b 191 }
Artiom 1:568955af8c2b 192
Artiom 1:568955af8c2b 193
Artiom 1:568955af8c2b 194
Artiom 1:568955af8c2b 195 void sol_avant(void)
Artiom 1:568955af8c2b 196 {
Artiom 1:568955af8c2b 197 int speed=1;
Artiom 1:568955af8c2b 198 char pompe=AV_BAS;
Artiom 1:568955af8c2b 199
Artiom 1:568955af8c2b 200 can.write(CANMessage(HACHEUR_GET_ATOM, &pompe,1));
Artiom 1:568955af8c2b 201 positionControl(AV_sol,512,speed,BLED_ON,4);//descend
Artiom 1:568955af8c2b 202
Artiom 1:568955af8c2b 203 wait(0.5);
Artiom 1:568955af8c2b 204
Artiom 1:568955af8c2b 205 positionControl(AV_sol,800,speed,BLED_ON,4);//remonte
Artiom 1:568955af8c2b 206 can.write(CANMessage(HACHEUR_RELEASE_ATOM, &pompe,1));
Artiom 1:568955af8c2b 207 wait(3);
Artiom 1:568955af8c2b 208 }
Artiom 1:568955af8c2b 209
Artiom 1:568955af8c2b 210 void sol_arriere(void)
Artiom 1:568955af8c2b 211 {
Artiom 1:568955af8c2b 212 int speed=1;
Artiom 1:568955af8c2b 213 char pompe=AR_BAS;
Artiom 1:568955af8c2b 214
Artiom 1:568955af8c2b 215 can.write(CANMessage(HACHEUR_GET_ATOM, &pompe,1));
Artiom 1:568955af8c2b 216 positionControl(AR_sol,512,speed,BLED_ON,4);//descend
Artiom 1:568955af8c2b 217
Artiom 1:568955af8c2b 218 wait(0.5);
Artiom 1:568955af8c2b 219
Artiom 1:568955af8c2b 220 positionControl(AR_sol,200,speed,BLED_ON,4);//remonte
Artiom 1:568955af8c2b 221 can.write(CANMessage(HACHEUR_RELEASE_ATOM, &pompe,1));
Artiom 1:568955af8c2b 222 wait(3);
Artiom 1:568955af8c2b 223 }
Artiom 1:568955af8c2b 224
Artiom 1:568955af8c2b 225
Artiom 1:568955af8c2b 226
Artiom 1:568955af8c2b 227
Artiom 0:bc74da1c502f 228
Artiom 0:bc74da1c502f 229 #endif