Ajout des copyrights
This commit is contained in:
parent
2d7be3ade0
commit
6d7e38165f
321
Main.ino
321
Main.ino
|
@ -1,158 +1,163 @@
|
||||||
#include "IO.hpp"
|
/*
|
||||||
#include "Ressources.hpp"
|
Copyright 2025
|
||||||
|
Thibaut Ferrand / Ulysse Cura
|
||||||
// Unit tests activation
|
*/
|
||||||
#define UNIT_TESTS
|
|
||||||
|
#include "IO.hpp"
|
||||||
/*
|
#include "Ressources.hpp"
|
||||||
Etapes :
|
|
||||||
- 1ere etape : avancer jusqu'a la montée / condition : si montée detecté : etape suivante
|
// Unit tests activation
|
||||||
- 2eme etape : avancer j'usqua la fin de la montée / condition : si fin de montée detecté : etape suivante
|
#define UNIT_TESTS
|
||||||
- 3eme etape : tourner de 90* / condition : si action terminé : etape suivante
|
|
||||||
- 4eme etape : avancer jusqu'au bors du plateau / condition : si choc de fin detecté : etape suivante
|
/*
|
||||||
- 5eme etape : faire tourner actionneurs pour figurine
|
Etapes :
|
||||||
*/
|
- 1ere etape : avancer jusqu'a la montée / condition : si montée detecté : etape suivante
|
||||||
|
- 2eme etape : avancer j'usqua la fin de la montée / condition : si fin de montée detecté : etape suivante
|
||||||
/*
|
- 3eme etape : tourner de 90* / condition : si action terminé : etape suivante
|
||||||
Modules necessaires :
|
- 4eme etape : avancer jusqu'au bors du plateau / condition : si choc de fin detecté : etape suivante
|
||||||
- angle // Asservissement et control du robot
|
- 5eme etape : faire tourner actionneurs pour figurine
|
||||||
- choc // Controle du robot (fin !)
|
*/
|
||||||
(?)- accelerometre // Asservissement
|
|
||||||
*/
|
/*
|
||||||
|
Modules necessaires :
|
||||||
// Movement states
|
- angle // Asservissement et control du robot
|
||||||
enum class State {
|
- choc // Controle du robot (fin !)
|
||||||
WaitingForTirette,
|
(?)- accelerometre // Asservissement
|
||||||
WaitingTimer,
|
*/
|
||||||
ForwardToRamp,
|
|
||||||
ForwardToScene,
|
// Movement states
|
||||||
Turn90Blue, // If blue team
|
enum class State {
|
||||||
Turn90Yellow, // If yellow team => this is the only action where you have to do something different depending on your team
|
WaitingForTirette,
|
||||||
ForwardToSceneEdge,
|
WaitingTimer,
|
||||||
Dancing
|
ForwardToRamp,
|
||||||
};
|
ForwardToScene,
|
||||||
|
Turn90Blue, // If blue team
|
||||||
// CodeCell implementation
|
Turn90Yellow, // If yellow team => this is the only action where you have to do something different depending on your team
|
||||||
CodeCell code_cell;
|
ForwardToSceneEdge,
|
||||||
IO my_IO {&code_cell};
|
Dancing
|
||||||
|
};
|
||||||
void setup()
|
|
||||||
{
|
// CodeCell implementation
|
||||||
// Initialise serial
|
CodeCell code_cell;
|
||||||
Serial.begin(115200);
|
IO my_IO {&code_cell};
|
||||||
|
|
||||||
Serial.println("Starting Initialisation");
|
void setup()
|
||||||
|
{
|
||||||
// Initialise the CodeCell for angle and tap detectIOn
|
// Initialise serial
|
||||||
code_cell.Init(MOTION_ROTATION);
|
Serial.begin(115200);
|
||||||
|
|
||||||
// Initialise IO
|
Serial.println("Starting Initialisation");
|
||||||
int nb_errors = my_IO.init();
|
|
||||||
|
// Initialise the CodeCell for angle and tap detectIOn
|
||||||
if(nb_errors)
|
code_cell.Init(MOTION_ROTATION);
|
||||||
{
|
|
||||||
Serial.printf("%d errors occured during IO init.", nb_errors);
|
// Initialise IO
|
||||||
while(true);
|
int nb_errors = my_IO.init();
|
||||||
}
|
|
||||||
|
if(nb_errors)
|
||||||
my_IO.getScreen()->drawBitmap(38, 0, Res::Imgs::riombotique, 52, 64, WHITE);
|
{
|
||||||
//my_IO.getScreen()->drawBitmap(75, 0, Imgs::poivron_robotique, 52, 64, WHITE);
|
Serial.printf("%d errors occured during IO init.", nb_errors);
|
||||||
|
while(true);
|
||||||
Serial.println("Initalisation Finished");
|
}
|
||||||
|
|
||||||
my_IO.motorControlOn();
|
my_IO.getScreen()->drawBitmap(38, 0, Res::Imgs::riombotique, 52, 64, WHITE);
|
||||||
|
//my_IO.getScreen()->drawBitmap(75, 0, Imgs::poivron_robotique, 52, 64, WHITE);
|
||||||
#ifdef UNIT_TESTS
|
|
||||||
Serial.println("UNIT_TESTS");
|
Serial.println("Initalisation Finished");
|
||||||
#endif
|
|
||||||
}
|
my_IO.motorControlOn();
|
||||||
|
|
||||||
#ifdef UNIT_TESTS
|
#ifdef UNIT_TESTS
|
||||||
|
Serial.println("UNIT_TESTS");
|
||||||
void loop()
|
#endif
|
||||||
{
|
}
|
||||||
my_IO.update();
|
|
||||||
|
#ifdef UNIT_TESTS
|
||||||
//Serial.printf("Is Selected Color Blue : %d\n", my_IO.isSelectedColorBlue());
|
|
||||||
//Serial.printf("Is Tirette Pulled : %d\n", my_IO.isTirettePulled());
|
void loop()
|
||||||
|
{
|
||||||
my_IO.setDir(0);
|
my_IO.update();
|
||||||
my_IO.setSpeed(2048.0f);
|
|
||||||
}
|
//Serial.printf("Is Selected Color Blue : %d\n", my_IO.isSelectedColorBlue());
|
||||||
|
//Serial.printf("Is Tirette Pulled : %d\n", my_IO.isTirettePulled());
|
||||||
#else
|
|
||||||
|
my_IO.setDir(0);
|
||||||
void loop()
|
my_IO.setSpeed(2048.0f);
|
||||||
{
|
}
|
||||||
static State actual_state {State::ForwardToRamp};
|
|
||||||
|
#else
|
||||||
switch(actual_state)
|
|
||||||
{
|
void loop()
|
||||||
case State::WaitingForTirette:
|
{
|
||||||
if(my_IO.isTirettePulled())
|
static State actual_state {State::ForwardToRamp};
|
||||||
{
|
|
||||||
actual_state = State::WaitingTimer;
|
switch(actual_state)
|
||||||
}
|
{
|
||||||
break;
|
case State::WaitingForTirette:
|
||||||
|
if(my_IO.isTirettePulled())
|
||||||
case State::WaitingTimer:
|
{
|
||||||
static unsigned long initial_time = millis();
|
actual_state = State::WaitingTimer;
|
||||||
|
}
|
||||||
if(millis() - initial_time >= 90000)
|
break;
|
||||||
{
|
|
||||||
actual_state = State::ForwardToRamp;
|
case State::WaitingTimer:
|
||||||
}
|
static unsigned long initial_time = millis();
|
||||||
break;
|
|
||||||
|
if(millis() - initial_time >= 90000)
|
||||||
case State::ForwardToRamp:
|
{
|
||||||
my_IO.forward();
|
actual_state = State::ForwardToRamp;
|
||||||
|
}
|
||||||
if(my_IO.getAngle(Axes::Y) > 9)
|
break;
|
||||||
{
|
|
||||||
actual_state = State::ForwardToScene;
|
case State::ForwardToRamp:
|
||||||
}
|
my_IO.forward();
|
||||||
break;
|
|
||||||
|
if(my_IO.getAngle(Axes::Y) > 9)
|
||||||
case State::ForwardToScene:
|
{
|
||||||
IO::motors.forward();
|
actual_state = State::ForwardToScene;
|
||||||
|
}
|
||||||
if(IO::gyro.getAngle(Axes::Y) < 2)
|
break;
|
||||||
{
|
|
||||||
actual_state = IO::ext_controls.isSelectedColorBlue() ? State::Turn90Blue : State::Turn90Yellow;
|
case State::ForwardToScene:
|
||||||
}
|
IO::motors.forward();
|
||||||
break;
|
|
||||||
|
if(IO::gyro.getAngle(Axes::Y) < 2)
|
||||||
case State::Turn90Blue:
|
{
|
||||||
IO::motors.setDir(90);
|
actual_state = IO::ext_controls.isSelectedColorBlue() ? State::Turn90Blue : State::Turn90Yellow;
|
||||||
|
}
|
||||||
if(IO::gyro.getAngle() > 90)
|
break;
|
||||||
{
|
|
||||||
actual_state = State::ForwardToSceneEdge;
|
case State::Turn90Blue:
|
||||||
}
|
IO::motors.setDir(90);
|
||||||
break;
|
|
||||||
|
if(IO::gyro.getAngle() > 90)
|
||||||
case State::Turn90Yellow:
|
{
|
||||||
IO::motors.setAngle(-90);
|
actual_state = State::ForwardToSceneEdge;
|
||||||
|
}
|
||||||
if(IO::gyro.getAngle() < -90)
|
break;
|
||||||
{
|
|
||||||
actual_state = State::ForwardToSceneEdge;
|
case State::Turn90Yellow:
|
||||||
}
|
IO::motors.setAngle(-90);
|
||||||
break;
|
|
||||||
|
if(IO::gyro.getAngle() < -90)
|
||||||
case State::ForwardToSceneEdge:
|
{
|
||||||
IO::motors.forward();
|
actual_state = State::ForwardToSceneEdge;
|
||||||
|
}
|
||||||
if(IO::gyro.getAngle() < 0)
|
break;
|
||||||
{
|
|
||||||
actual_state = State::Dancing;
|
case State::ForwardToSceneEdge:
|
||||||
}
|
IO::motors.forward();
|
||||||
break;
|
|
||||||
|
if(IO::gyro.getAngle() < 0)
|
||||||
case State::Dancing:
|
{
|
||||||
IO::ext_controls.startSpecialAction();
|
actual_state = State::Dancing;
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
|
case State::Dancing:
|
||||||
#endif
|
IO::ext_controls.startSpecialAction();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue