diff --git a/306-controller_interface.X/app/drive.c b/306-controller_interface.X/app/drive.c index 72c7fb7..5a92c15 100644 --- a/306-controller_interface.X/app/drive.c +++ b/306-controller_interface.X/app/drive.c @@ -8,6 +8,8 @@ #include "drive.h" #include "car.h" #include "can_message.h" +#include "steering.h" +#include "factory/factory.h" void DRIVE_init(DRIVE* me){ me->state = STDR_INIT; @@ -22,7 +24,7 @@ void DRIVE_init(DRIVE* me){ } void DRIVE_startBehaviour(DRIVE* me){ - POST(me, &DRIVE_processEvent, evDRinit, 0, 0); + POST(me, &DRIVE_processEvent, evDRinit, 100, 0); } bool DRIVE_processEvent(Event* ev) { @@ -31,6 +33,8 @@ bool DRIVE_processEvent(Event* ev) { DRIVE_STATES oldState = me->state; evIDT evid = Event_getId(ev); uint64_t data = Event_getData(ev); + STEERING_STATES steeringState = steering()->state; + switch (me->state) { // onState case STDR_INIT: @@ -55,7 +59,9 @@ bool DRIVE_processEvent(Event* ev) { } if (ev->id == evDRpollTorque) { - CM_DRIVE_POWER(&eKart.torque); + if(steeringState == STST_RUN) { + CM_DRIVE_POWER(&eKart.torque); + } } if (ev->id == evDRpollSpeed) { diff --git a/306-controller_interface.X/app/drive.h b/306-controller_interface.X/app/drive.h index 647e66e..e313c71 100644 --- a/306-controller_interface.X/app/drive.h +++ b/306-controller_interface.X/app/drive.h @@ -11,7 +11,7 @@ #include "../middleware/alive.h" typedef enum { - STDR_INIT, + STDR_INIT = 100, STDR_WAIT, STDR_RUN, STDR_DEAD