check if steering ready for driving
This commit is contained in:
		| @@ -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) { | ||||
|   | ||||
| @@ -11,7 +11,7 @@ | ||||
| #include "../middleware/alive.h" | ||||
|  | ||||
| typedef enum { | ||||
|     STDR_INIT, | ||||
|     STDR_INIT = 100, | ||||
|     STDR_WAIT, | ||||
|     STDR_RUN, | ||||
|     STDR_DEAD | ||||
|   | ||||
		Reference in New Issue
	
	Block a user