DuckieTownCarHS

Dependencies:   TCS3200 X_NUCLEO_IKS01A2 mbed-rtos mbed

Fork of DuckieTownCar by Domenico Francesco De Angelis

Committer:
deangelis1993
Date:
Wed Feb 15 13:27:01 2017 +0000
Revision:
0:65ecca01ac5c
DuckiTownCar first version for virtualization of machine

Who changed what in which revision?

UserRevisionLine numberNew contents of line
deangelis1993 0:65ecca01ac5c 1 #ifndef _DUCKIETOWNCAR_H
deangelis1993 0:65ecca01ac5c 2 #define _DUCKIETOWNCAR_H
deangelis1993 0:65ecca01ac5c 3
deangelis1993 0:65ecca01ac5c 4 #include "ByteCode.h"
deangelis1993 0:65ecca01ac5c 5 //#include "color.h"
deangelis1993 0:65ecca01ac5c 6 #include "x_nucleo_iks01a2.h"
deangelis1993 0:65ecca01ac5c 7
deangelis1993 0:65ecca01ac5c 8 /***********************************************
deangelis1993 0:65ecca01ac5c 9 * DuckieTownCarHS macchina Virtuale! *
deangelis1993 0:65ecca01ac5c 10 * by De Angelis Domenico Francesco *
deangelis1993 0:65ecca01ac5c 11 *--------> UNINA FabLAB <------------*
deangelis1993 0:65ecca01ac5c 12 ************************************************/
deangelis1993 0:65ecca01ac5c 13
deangelis1993 0:65ecca01ac5c 14 //Se con le classi siamo nel torno, è meglio sbagliare alla grande! :D
deangelis1993 0:65ecca01ac5c 15
deangelis1993 0:65ecca01ac5c 16 #define DEBUG_CAR
deangelis1993 0:65ecca01ac5c 17
deangelis1993 0:65ecca01ac5c 18 //Singleton
deangelis1993 0:65ecca01ac5c 19 class DuckieTownCar
deangelis1993 0:65ecca01ac5c 20 {
deangelis1993 0:65ecca01ac5c 21 private:
deangelis1993 0:65ecca01ac5c 22 static DuckieTownCar* instance;//istanza della macchina
deangelis1993 0:65ecca01ac5c 23 ByteCode code;
deangelis1993 0:65ecca01ac5c 24
deangelis1993 0:65ecca01ac5c 25 LSM6DSLSensor *acc_gyro;//giroscopio
deangelis1993 0:65ecca01ac5c 26 int32_t axes[3],off[3];
deangelis1993 0:65ecca01ac5c 27 float parziale_angolo[3],angolo[3];//angolo indica di quanto sia ruotato rispetto ad offset iniziale in [gyro/d]
deangelis1993 0:65ecca01ac5c 28 //sceda per i motori
deangelis1993 0:65ecca01ac5c 29
deangelis1993 0:65ecca01ac5c 30 //scheda dei Colori TCS3200
deangelis1993 0:65ecca01ac5c 31 //ColorSensor sensor_color;
deangelis1993 0:65ecca01ac5c 32
deangelis1993 0:65ecca01ac5c 33 DuckieTownCar();
deangelis1993 0:65ecca01ac5c 34
deangelis1993 0:65ecca01ac5c 35 void infoAxes();//aggiorna i valori di angolo!
deangelis1993 0:65ecca01ac5c 36
deangelis1993 0:65ecca01ac5c 37 void dritto();
deangelis1993 0:65ecca01ac5c 38 void gira();
deangelis1993 0:65ecca01ac5c 39 public:
deangelis1993 0:65ecca01ac5c 40 ~DuckieTownCar(){error("Ora mi devi spiegare come ci sei arrivato qui...\n");}
deangelis1993 0:65ecca01ac5c 41 static DuckieTownCar* getInstance();
deangelis1993 0:65ecca01ac5c 42
deangelis1993 0:65ecca01ac5c 43 void initCarSensor();
deangelis1993 0:65ecca01ac5c 44 __forceinline void updateStateCar();//aggiorno lo stato della macchina attraverso i sensori!
deangelis1993 0:65ecca01ac5c 45 __forceinline void readMission(const ByteCode& codice){this->code.code = codice.code; this->code.dim_code = codice.dim_code;}
deangelis1993 0:65ecca01ac5c 46 void execute() const;
deangelis1993 0:65ecca01ac5c 47 void executeLine(unsigned char code) const;
deangelis1993 0:65ecca01ac5c 48 void executeRandom() const;
deangelis1993 0:65ecca01ac5c 49
deangelis1993 0:65ecca01ac5c 50 //nel caso vogliamo permettere di configurare l'auto
deangelis1993 0:65ecca01ac5c 51 //void setVel(float);
deangelis1993 0:65ecca01ac5c 52 //float getVel() const;
deangelis1993 0:65ecca01ac5c 53 };
deangelis1993 0:65ecca01ac5c 54
deangelis1993 0:65ecca01ac5c 55 #endif