check if steering ready for driving
This commit is contained in:
parent
447c9d8801
commit
0f7f078440
@ -8,6 +8,8 @@
|
|||||||
#include "drive.h"
|
#include "drive.h"
|
||||||
#include "car.h"
|
#include "car.h"
|
||||||
#include "can_message.h"
|
#include "can_message.h"
|
||||||
|
#include "steering.h"
|
||||||
|
#include "factory/factory.h"
|
||||||
|
|
||||||
void DRIVE_init(DRIVE* me){
|
void DRIVE_init(DRIVE* me){
|
||||||
me->state = STDR_INIT;
|
me->state = STDR_INIT;
|
||||||
@ -22,7 +24,7 @@ void DRIVE_init(DRIVE* me){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DRIVE_startBehaviour(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) {
|
bool DRIVE_processEvent(Event* ev) {
|
||||||
@ -31,6 +33,8 @@ bool DRIVE_processEvent(Event* ev) {
|
|||||||
DRIVE_STATES oldState = me->state;
|
DRIVE_STATES oldState = me->state;
|
||||||
evIDT evid = Event_getId(ev);
|
evIDT evid = Event_getId(ev);
|
||||||
uint64_t data = Event_getData(ev);
|
uint64_t data = Event_getData(ev);
|
||||||
|
STEERING_STATES steeringState = steering()->state;
|
||||||
|
|
||||||
|
|
||||||
switch (me->state) { // onState
|
switch (me->state) { // onState
|
||||||
case STDR_INIT:
|
case STDR_INIT:
|
||||||
@ -55,8 +59,10 @@ bool DRIVE_processEvent(Event* ev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ev->id == evDRpollTorque) {
|
if (ev->id == evDRpollTorque) {
|
||||||
|
if(steeringState == STST_RUN) {
|
||||||
CM_DRIVE_POWER(&eKart.torque);
|
CM_DRIVE_POWER(&eKart.torque);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ev->id == evDRpollSpeed) {
|
if (ev->id == evDRpollSpeed) {
|
||||||
CM_DISPLAY_SPEED(&eKart.speed);
|
CM_DISPLAY_SPEED(&eKart.speed);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "../middleware/alive.h"
|
#include "../middleware/alive.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
STDR_INIT,
|
STDR_INIT = 100,
|
||||||
STDR_WAIT,
|
STDR_WAIT,
|
||||||
STDR_RUN,
|
STDR_RUN,
|
||||||
STDR_DEAD
|
STDR_DEAD
|
||||||
|
Reference in New Issue
Block a user