Programme de contrôle de l'octopode 4DOF, Theraphosa-Salconi.

Dependencies:   debug mbed

CtrlBridge

  • fonction quelquonque pour communiquer avec les module
  • fonction quelquonque pour faire des recherche dans les module dispo
  • autre fonction pour jouer avec MemRegistre

Version 1.2.0

  • Ajout d'un mode de simulation pour tester le code avec seulement un contrôleur stm32
Committer:
salco
Date:
Tue Jan 31 13:15:42 2017 +0000
Revision:
41:0b5c14dda54a
Parent:
40:ecef15b1dfad
Tentative de modifier les commit inutile sur debug.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
salco 2:4c5b0f6d0a6b 1 /**
salco 35:d81f6b927932 2 * @file directive.h
salco 2:4c5b0f6d0a6b 3 * @brief Cette classe est le modele des 3 taches de controle.
salco 2:4c5b0f6d0a6b 4 * @author Salco
salco 2:4c5b0f6d0a6b 5 * @version 2.00
salco 2:4c5b0f6d0a6b 6 * @date 11 mars 2015
salco 2:4c5b0f6d0a6b 7 */
salco 2:4c5b0f6d0a6b 8 #ifndef DIRECTIVE_H
salco 2:4c5b0f6d0a6b 9 #define DIRECTIVE_H
salco 2:4c5b0f6d0a6b 10
salco 39:34d7802e8d15 11
salco 28:ac5c6350ed9a 12
salco 28:ac5c6350ed9a 13
salco 28:ac5c6350ed9a 14 #define mvToADC(value)((value*1.023)/5)
salco 28:ac5c6350ed9a 15 #define ADCTomv(value)((value*5)/1.023)
salco 28:ac5c6350ed9a 16 #define ultrasonicToInch(value)(ADCTomv(value)/9.8)
salco 28:ac5c6350ed9a 17
salco 39:34d7802e8d15 18 #define inchToCm(value)(value*2.54)
salco 28:ac5c6350ed9a 19 #define mvToInch(value)(value/9.8)
salco 28:ac5c6350ed9a 20
salco 28:ac5c6350ed9a 21
salco 19:0ac80045ba4c 22
salco 3:e0d6e081a9d3 23 #include "mbed.h"
salco 19:0ac80045ba4c 24 #include "debug.h"
salco 2:4c5b0f6d0a6b 25 #include "source/Task/TTask.h"
salco 3:e0d6e081a9d3 26 #include "Motrice/mouvement.h"
salco 28:ac5c6350ed9a 27 #include <stdlib.h> /* srand, rand */
salco 38:57d5f36a0333 28 #include <list>
salco 28:ac5c6350ed9a 29 #include <time.h> /* time */
salco 28:ac5c6350ed9a 30 #include "labyrinthe.h"
salco 35:d81f6b927932 31 #include "settingDebug.h"
salco 2:4c5b0f6d0a6b 32
salco 28:ac5c6350ed9a 33 //////////////////////////////
salco 28:ac5c6350ed9a 34 // 00 - Nothing //
salco 28:ac5c6350ed9a 35 //X01 - Calibration(milieu) //
salco 28:ac5c6350ed9a 36 //X02 - Debout //
salco 28:ac5c6350ed9a 37 //X03 - Coucher //
salco 28:ac5c6350ed9a 38 //X04 - Tourne Gauche //
salco 28:ac5c6350ed9a 39 //X05 - Tourne Droite //
salco 28:ac5c6350ed9a 40 // 06 - Marche //
salco 28:ac5c6350ed9a 41 // 07 - Recule //
salco 28:ac5c6350ed9a 42 // 08 - Repositioner legs //
salco 28:ac5c6350ed9a 43 // 09 - Crabe Gauche // Dont use Crabe because it's really anoying
salco 28:ac5c6350ed9a 44 // 10 - Crabe Droite // Dont use Crabe because it's really anoying
salco 28:ac5c6350ed9a 45 // 11 - Position naturel //
salco 28:ac5c6350ed9a 46 //////////////////////////////
salco 39:34d7802e8d15 47 #define TBL_CMD_NOTHING 0
salco 39:34d7802e8d15 48 #define TBL_CMD_CALIBRATION 1
salco 39:34d7802e8d15 49 #define TBL_CMD_DEBOUT 2
salco 39:34d7802e8d15 50 #define TBL_CMD_COUCHER 3
salco 39:34d7802e8d15 51 #define TBL_CMD_TURN_LEFT 4
salco 39:34d7802e8d15 52 #define TBL_CMD_TURN_RIGHT 5
salco 39:34d7802e8d15 53 #define TBL_CMD_MARCHE 6
salco 39:34d7802e8d15 54 #define TBL_CMD_RECULE 7
salco 39:34d7802e8d15 55 #define TBL_CMD_REPOSITIONE 8
salco 39:34d7802e8d15 56 #define TBL_CMD_CRAB_LEFT 9
salco 39:34d7802e8d15 57 #define TBL_CMD_CRAB_RIGHT 10
salco 39:34d7802e8d15 58 #define TBL_CMD_DEFAULT_POS 11
salco 39:34d7802e8d15 59
salco 2:4c5b0f6d0a6b 60 class Directive : public TTask
salco 2:4c5b0f6d0a6b 61 {
salco 27:ea60d12dccdf 62 //CtrlBridge* m_CtrlBridge;
salco 3:e0d6e081a9d3 63 Faculter_motrice *ctrDesPattes;
salco 27:ea60d12dccdf 64 /*Serial*//*Raw*/Serial *ssc32;
salco 27:ea60d12dccdf 65 string m_capteurUltrasonic,m_capteurIR,m_capteurProximiter;
salco 28:ac5c6350ed9a 66 //char c;
salco 28:ac5c6350ed9a 67 Labyrinthe* myMaze;
salco 39:34d7802e8d15 68 bool followThePath;
salco 28:ac5c6350ed9a 69
salco 38:57d5f36a0333 70 struct positionXY
salco 38:57d5f36a0333 71 {
salco 38:57d5f36a0333 72 signed char posX;
salco 38:57d5f36a0333 73 signed char posY;
salco 39:34d7802e8d15 74 char direction;
salco 38:57d5f36a0333 75 };
salco 38:57d5f36a0333 76 std::list<positionXY> bufferNewWay;
salco 38:57d5f36a0333 77
salco 39:34d7802e8d15 78 double m_valueCapteurUltrasonic,m_valueCapteurIR;
salco 39:34d7802e8d15 79 int m_valueCapteurProximiter;
salco 40:ecef15b1dfad 80 unsigned char tableauDeCommange[DIRECTIVE_TABLEAUDECOMMANDE_SIZE];
salco 28:ac5c6350ed9a 81 unsigned char size_tableauDeCommange;
salco 28:ac5c6350ed9a 82 void updateModuleValue(void);
salco 39:34d7802e8d15 83 void turnRightDirection(char currentDir, char nextDir);
salco 28:ac5c6350ed9a 84
salco 38:57d5f36a0333 85
salco 2:4c5b0f6d0a6b 86 protected:
salco 28:ac5c6350ed9a 87 /*
salco 28:ac5c6350ed9a 88 * Tache principale de la classe
salco 28:ac5c6350ed9a 89 */
salco 2:4c5b0f6d0a6b 90 virtual void task(void);
salco 40:ecef15b1dfad 91 void updateMaze(void);
salco 28:ac5c6350ed9a 92 void analiseMaze(void);
salco 38:57d5f36a0333 93 char checkOtherWay(char dir, bool checkExplorer=false);
salco 39:34d7802e8d15 94 void checkOtherWay(char &caseFront, char &caseBack, char &caseLeft, char &caseRight);
salco 38:57d5f36a0333 95
salco 38:57d5f36a0333 96 bool searchNewWay(void);
salco 39:34d7802e8d15 97
salco 38:57d5f36a0333 98 bool isAnotherWay(void);
salco 2:4c5b0f6d0a6b 99 public:
salco 2:4c5b0f6d0a6b 100 Directive();
salco 2:4c5b0f6d0a6b 101 virtual~Directive();
salco 28:ac5c6350ed9a 102 double IRToCm (double miliVolt);
salco 28:ac5c6350ed9a 103 void addTableauDeCommande(unsigned char value);
salco 2:4c5b0f6d0a6b 104
salco 2:4c5b0f6d0a6b 105 };
salco 2:4c5b0f6d0a6b 106 #endif // DIRECTIVE_H