Couleur et gyroscope corrigés
This commit is contained in:
parent
9f3f039bb0
commit
c9c98375c7
9
IO.hpp
9
IO.hpp
|
@ -67,7 +67,7 @@ class IO {
|
||||||
pinMode(PIN_TIRETTE, INPUT_PULLUP);
|
pinMode(PIN_TIRETTE, INPUT_PULLUP);
|
||||||
pinMode(PIN_BUTTON_COLOR, INPUT_PULLUP);
|
pinMode(PIN_BUTTON_COLOR, INPUT_PULLUP);
|
||||||
|
|
||||||
m_code_cell->Motion_RotationRead(m_init_x, m_init_y, m_init_z);
|
initGyroscope();
|
||||||
|
|
||||||
m_initMotors();
|
m_initMotors();
|
||||||
m_initServo();
|
m_initServo();
|
||||||
|
@ -84,6 +84,11 @@ class IO {
|
||||||
return nb_errors;
|
return nb_errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initGyroscope()
|
||||||
|
{
|
||||||
|
m_code_cell->Motion_RotationRead(m_init_x, m_init_y, m_init_z);
|
||||||
|
}
|
||||||
|
|
||||||
int update()
|
int update()
|
||||||
{
|
{
|
||||||
static unsigned long last_color_change_time {0};
|
static unsigned long last_color_change_time {0};
|
||||||
|
@ -122,7 +127,7 @@ class IO {
|
||||||
m_is_tirette_pulled = (digitalRead(PIN_TIRETTE) == HIGH);
|
m_is_tirette_pulled = (digitalRead(PIN_TIRETTE) == HIGH);
|
||||||
m_is_color_blue = is_color_blue;
|
m_is_color_blue = is_color_blue;
|
||||||
|
|
||||||
is_color_blue = (digitalRead(PIN_BUTTON_COLOR) == HIGH);
|
is_color_blue = (digitalRead(PIN_BUTTON_COLOR) == LOW);
|
||||||
|
|
||||||
if(m_is_motor_control_activated)
|
if(m_is_motor_control_activated)
|
||||||
{
|
{
|
||||||
|
|
25
Main.ino
25
Main.ino
|
@ -108,9 +108,10 @@ void loop()
|
||||||
case State::WaitingTimer:
|
case State::WaitingTimer:
|
||||||
static unsigned long initial_time = millis();
|
static unsigned long initial_time = millis();
|
||||||
|
|
||||||
//if(millis() - initial_time >= 90000)
|
if(millis() - initial_time >= 90000)
|
||||||
if(millis() - initial_time >= 2000)
|
//if(millis() - initial_time >= 2000)
|
||||||
{
|
{
|
||||||
|
my_IO.initGyroscope();
|
||||||
actual_state = State::ForwardToRamp;
|
actual_state = State::ForwardToRamp;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -136,15 +137,6 @@ void loop()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case State::Turn90Blue:
|
case State::Turn90Blue:
|
||||||
my_IO.setDirWithAngularSpeed(-90.0f);
|
|
||||||
|
|
||||||
if(my_IO.getAngle(Axes::Z) < -80.0f)
|
|
||||||
{
|
|
||||||
actual_state = State::ForwardToSceneEdge;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case State::Turn90Yellow:
|
|
||||||
my_IO.setDirWithAngularSpeed(90.0f);
|
my_IO.setDirWithAngularSpeed(90.0f);
|
||||||
|
|
||||||
if(my_IO.getAngle(Axes::Z) >= 80.0f)
|
if(my_IO.getAngle(Axes::Z) >= 80.0f)
|
||||||
|
@ -153,8 +145,17 @@ void loop()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case State::Turn90Yellow:
|
||||||
|
my_IO.setDirWithAngularSpeed(-90.0f);
|
||||||
|
|
||||||
|
if(my_IO.getAngle(Axes::Z) < -80.0f)
|
||||||
|
{
|
||||||
|
actual_state = State::ForwardToSceneEdge;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case State::ForwardToSceneEdge:
|
case State::ForwardToSceneEdge:
|
||||||
my_IO.setSpeed(1100.0f);
|
my_IO.setSpeed(1200.0f);
|
||||||
|
|
||||||
if(my_IO.getAngle(Axes::Y) > 5.0f)
|
if(my_IO.getAngle(Axes::Y) > 5.0f)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue