v2019

Dependencies:   CRAC-Strat_2019 SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Dependents:   Codeprincipal_2019 CRAC-Strat_2019

Committer:
Sitkah
Date:
Fri Apr 06 13:47:19 2018 +0000
Revision:
29:41e02746041d
Parent:
27:76ead555a63d
version fusionn?e

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sitkah 29:41e02746041d 1 #include "global.h"
Sitkah 29:41e02746041d 2
Sitkah 29:41e02746041d 3
Sitkah 29:41e02746041d 4
antbig 0:ad97421fb1fb 5
antbig 0:ad97421fb1fb 6 void debug_Instruction(struct S_Instruction instruction)
antbig 0:ad97421fb1fb 7 {
antbig 0:ad97421fb1fb 8 printf("\n********* Debug instruction *********\n");
antbig 0:ad97421fb1fb 9
antbig 0:ad97421fb1fb 10 printf("* Line => %d\n", instruction.lineNumber);
antbig 0:ad97421fb1fb 11 printf("* Type => %s\n", InstructionTypeToString(instruction.order));
antbig 0:ad97421fb1fb 12 printf("* Direction => %s\n", InstructionDirectionToString(instruction.direction));
antbig 0:ad97421fb1fb 13
antbig 0:ad97421fb1fb 14 printf("* Arg1 => %d\n", instruction.arg1);
antbig 0:ad97421fb1fb 15 printf("* Arg2 => %d\n", instruction.arg2);
antbig 0:ad97421fb1fb 16 printf("* Arg3 => %d\n", instruction.arg3);
antbig 0:ad97421fb1fb 17
antbig 0:ad97421fb1fb 18 printf("* Recalage => %s\n", InstructionPrecisionOuRecalageToString(instruction.precision));
antbig 0:ad97421fb1fb 19 printf("* NextAction=> %s\n", InstructionNextActionTypeToString(instruction.nextActionType));
antbig 0:ad97421fb1fb 20 printf("* JumpAction=> %s\n", InstructionNextActionJumpTypeToString(instruction.jumpAction));
antbig 0:ad97421fb1fb 21
antbig 0:ad97421fb1fb 22 printf("* JumpTimeOrX => %d\n", instruction.JumpTimeOrX);
antbig 0:ad97421fb1fb 23 printf("* JumpY => %d\n", instruction.JumpY);
antbig 0:ad97421fb1fb 24 printf("* nextLineOK => %d\n", instruction.nextLineOK);
antbig 0:ad97421fb1fb 25 printf("* nextLineError => %d\n", instruction.nextLineError);
antbig 0:ad97421fb1fb 26
antbig 0:ad97421fb1fb 27 printf("*************************************\n");
antbig 0:ad97421fb1fb 28 }
antbig 0:ad97421fb1fb 29
antbig 0:ad97421fb1fb 30 char* InstructionTypeToString(enum E_InstructionType type)
antbig 0:ad97421fb1fb 31 {
antbig 0:ad97421fb1fb 32 switch(type)
antbig 0:ad97421fb1fb 33 {
antbig 0:ad97421fb1fb 34 case MV_COURBURE: return "Courbure";
antbig 0:ad97421fb1fb 35 case MV_LINE: return "Ligne";
antbig 0:ad97421fb1fb 36 case MV_TURN: return "Rotation";
antbig 0:ad97421fb1fb 37 case MV_XYT: return "Position XYT";
antbig 0:ad97421fb1fb 38 case MV_RECALAGE: return "Recalage";
antbig 0:ad97421fb1fb 39 case ACTION: return "Action";
antbig 0:ad97421fb1fb 40 default: return "Inconnue";
antbig 0:ad97421fb1fb 41 }
antbig 0:ad97421fb1fb 42 }
antbig 0:ad97421fb1fb 43 char* InstructionDirectionToString(enum E_InstructionDirection type)
antbig 0:ad97421fb1fb 44 {
antbig 0:ad97421fb1fb 45 switch(type)
antbig 0:ad97421fb1fb 46 {
antbig 0:ad97421fb1fb 47 case BACKWARD: return "en arriere";
antbig 0:ad97421fb1fb 48 case FORWARD: return "en avant";
antbig 0:ad97421fb1fb 49 case RELATIVE: return "relatif";
antbig 0:ad97421fb1fb 50 case ABSOLUTE: return "absolu";
antbig 0:ad97421fb1fb 51 default: return "absent";
antbig 0:ad97421fb1fb 52 }
antbig 0:ad97421fb1fb 53 }
antbig 0:ad97421fb1fb 54 char* InstructionPrecisionOuRecalageToString(enum E_InstructionPrecisionOuRecalage type)
antbig 0:ad97421fb1fb 55 {
antbig 0:ad97421fb1fb 56 switch(type)
antbig 0:ad97421fb1fb 57 {
antbig 0:ad97421fb1fb 58 case PRECISION: return "correction position en fin de mouvement";
antbig 0:ad97421fb1fb 59 case RECALAGE_X: return "recalage en X";
antbig 0:ad97421fb1fb 60 case RECALAGE_Y: return "recalage en Y";
antbig 0:ad97421fb1fb 61 default: return "absent";
antbig 0:ad97421fb1fb 62 }
antbig 0:ad97421fb1fb 63 }
antbig 0:ad97421fb1fb 64 char* InstructionNextActionTypeToString(enum E_InstructionNextActionType type)
antbig 0:ad97421fb1fb 65 {
antbig 0:ad97421fb1fb 66 switch(type)
antbig 0:ad97421fb1fb 67 {
antbig 0:ad97421fb1fb 68 case JUMP: return "jump";
antbig 0:ad97421fb1fb 69 case WAIT: return "attente fin instruction";
antbig 0:ad97421fb1fb 70 case ENCHAINEMENT: return "enchainement";
antbig 0:ad97421fb1fb 71 default: return "absent";
antbig 0:ad97421fb1fb 72 }
antbig 0:ad97421fb1fb 73 }
antbig 0:ad97421fb1fb 74 char* InstructionNextActionJumpTypeToString(enum E_InstructionNextActionJumpType type)
antbig 0:ad97421fb1fb 75 {
antbig 0:ad97421fb1fb 76 switch(type)
antbig 0:ad97421fb1fb 77 {
antbig 0:ad97421fb1fb 78 case JUMP_TIME: return "attente temps";
antbig 0:ad97421fb1fb 79 case JUMP_POSITION: return "attente position";
antbig 0:ad97421fb1fb 80 default: return "absent";
antbig 0:ad97421fb1fb 81 }
antbig 0:ad97421fb1fb 82 }
antbig 0:ad97421fb1fb 83
antbig 0:ad97421fb1fb 84 void errorLoop(void) {
antbig 0:ad97421fb1fb 85 while(true) {
antbig 0:ad97421fb1fb 86 led1 = 1;
antbig 0:ad97421fb1fb 87 wait(0.2);
antbig 0:ad97421fb1fb 88 led1 = 0;
antbig 0:ad97421fb1fb 89 wait(0.2);
Sitkah 29:41e02746041d 90
antbig 0:ad97421fb1fb 91 }
antbig 0:ad97421fb1fb 92 }
antbig 0:ad97421fb1fb 93
antbig 1:116040d14164 94 void errorInstructionLoop(void) {
antbig 1:116040d14164 95 while(true) {
antbig 1:116040d14164 96 led2 = 1;
antbig 1:116040d14164 97 wait(0.2);
antbig 1:116040d14164 98 led2 = 0;
antbig 1:116040d14164 99 wait(0.2);
antbig 1:116040d14164 100 }
antbig 1:116040d14164 101 }
antbig 1:116040d14164 102
antbig 0:ad97421fb1fb 103 /****************************************************************************************/
antbig 0:ad97421fb1fb 104 /* FUNCTION NAME: sendStratEtat */
antbig 0:ad97421fb1fb 105 /* DESCRIPTION : permet le debug de l'etat de l'automate de stratégie */
antbig 0:ad97421fb1fb 106 /****************************************************************************************/
antbig 11:ed13a480ddca 107 void sendStratEtat(unsigned char etat, unsigned char currentInstruction) {
antbig 0:ad97421fb1fb 108
antbig 0:ad97421fb1fb 109 CANMessage msgTx=CANMessage();
antbig 0:ad97421fb1fb 110 msgTx.id=DEBUG_STRATEGIE_AUTOMATE; // tx nouvelle position en (x,y,theta)
antbig 0:ad97421fb1fb 111 msgTx.len=1;
antbig 0:ad97421fb1fb 112 msgTx.format=CANStandard;
antbig 0:ad97421fb1fb 113 msgTx.type=CANData;
antbig 0:ad97421fb1fb 114 // x sur 2 octets
antbig 0:ad97421fb1fb 115 msgTx.data[0]=(unsigned char)etat;
antbig 11:ed13a480ddca 116 msgTx.data[1]=(unsigned char)currentInstruction;
antbig 0:ad97421fb1fb 117
antbig 0:ad97421fb1fb 118 can1.write(msgTx);
antbig 27:76ead555a63d 119 }
antbig 27:76ead555a63d 120
antbig 27:76ead555a63d 121 void debugXYTTarget(signed short target_x_robot, signed short target_y_robot, signed short target_theta_robot) {
antbig 27:76ead555a63d 122 printf("going to new position x: %d, y: %d, t: %d\n",target_x_robot,target_y_robot,target_theta_robot);
Sitkah 29:41e02746041d 123 }
Sitkah 29:41e02746041d 124
Sitkah 29:41e02746041d 125