fix for go to the kart

This commit is contained in:
Rémi Heredero 2023-09-06 21:03:23 +02:00
parent 7750978f18
commit 84630eb6fd
10 changed files with 137 additions and 80 deletions

View File

@ -269,6 +269,11 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, bool rtr, uint32_t data){
}
if(idMsg == 0xE) { // DRIVE_BRAKE
// status - - -
eKart.brake = incomeData.separate.byte0;
}
if(idMsg == 0xF) { // STEERING_ALIVE
// statusH statusL - -
ALIVE_ISALIVE(&steering()->myChecker);
@ -293,6 +298,17 @@ void CM_processIncome(uint8_t idSender, uint8_t idMsg, bool rtr, uint32_t data){
* SUPPLY *
**********/
case 6:
if(idMsg == 0x4) {
DRIVE_startBehaviour(drive());
STEERING_startBehaviour(steering());
ALIVE_startBehaviourSender(ALcontroller());
ALIVE_startBehaviourChecker(ALjoy());
ALIVE_emitBorn(ALjoy(), 100, 0);
ALIVE_emitReady(ALjoy(), 200, 0);
}
if(idMsg == 0xF) { // BATTERY_ALIVE
// - - - -
// TODO battery say ALIVE

View File

@ -61,14 +61,14 @@ bool DRIVE_processEvent(Event* ev) {
if (ev->id == evDRpollTorque) {
//if(steeringState == STST_RUN) {
CM_DRIVE_POWER(&eKart.torque);
if (KART_CST.DRIVE_STOP_TIME == 0) KART_CST.DRIVE_STOP_TIME = 1;
DRIVE_emitPollTorque(me, KART_CST.DRIVE_STOP_TIME*5, 0);
//}
}
if (ev->id == evDRpollSpeed) {
CM_DISPLAY_SPEED(&eKart.speed);
}
DRIVE_emitPollTorque(me, KART_CST.DRIVE_STOP_TIME*9, 0);
break;
case STDR_DEAD:
@ -104,6 +104,8 @@ bool DRIVE_processEvent(Event* ev) {
break;
case STDR_RUN:
if (KART_CST.DRIVE_STOP_TIME == 0) KART_CST.DRIVE_STOP_TIME = 1;
DRIVE_emitPollTorque(me, KART_CST.DRIVE_STOP_TIME*5, 0);
if (me->run.f != NULL) {
me->run.f(me->run.p);
}

View File

@ -31,9 +31,9 @@ void MEM_init(){
KART_CST.CONTROL_MAX_SPEED_FW = 50;
KART_CST.CONTROL_MAX_SPEED_BW = 25;
KART_CST.JOYSTICK_MODE = 0;
KART_CST.JOYSTICK_PARAM1 = 5;
KART_CST.JOYSTICK_PARAM2 = 1;
KART_CST.JOYSTICK_MODE = 0; // mode 0 is time based, mode 1 is change based
KART_CST.JOYSTICK_PARAM1 = 5; // for mode 0, values are send every param1*10ms
KART_CST.JOYSTICK_PARAM2 = 1; // for mode 0, values need to change param2 at least for sending
KART_CST.JOYSTICK_ALIVE_TIME = 25;
KART_CST.DISPLAY_ALIVE_TIME = 100;

View File

@ -72,7 +72,7 @@ void Factory_build() {
//start all state machines
void Factory_start() {
CAN_startBehaviour();
/*
DRIVE_startBehaviour(drive());
STEERING_startBehaviour(steering());
@ -81,7 +81,7 @@ void Factory_start() {
ALIVE_startBehaviourChecker(ALjoy());
ALIVE_emitBorn(ALjoy(), 100, 0);
ALIVE_emitReady(ALjoy(), 200, 0);
*/
}

View File

@ -45,6 +45,7 @@ void calcPosition(uint8_t joy_pos){
}
lastPos = calcPosition;
calcPosition *= -1; // change left and right
calcPosition *= (int32_t) KART_CST.CONTROL_STEERING_FACTOR;
calcPosition /= 1000;
calcPosition += eKart.center;

View File

@ -26,6 +26,7 @@ void STEERING_init(STEERING* me){
me->wait.f = NULL;
me->run.f = NULL;
me->dead.f = NULL;
eKart.center = 560024;
}
void STEERING_startBehaviour(STEERING* me){

View File

@ -67,7 +67,7 @@ bool ALIVE_processEvent(Event* ev) {
case STAL_BORN:
if (ev->id == evALready) {
me->state = STAL_WAIT;
ALIVE_emitPoll(me, me->aliveTime*10, 0);
ALIVE_emitPoll(me, me->aliveTime*20, 0);
}
break;
@ -80,7 +80,7 @@ bool ALIVE_processEvent(Event* ev) {
}
} else if (me->isAlive){
me->state = STAL_WAIT;
ALIVE_emitPoll(me, me->aliveTime*10, 0);
ALIVE_emitPoll(me, me->aliveTime*20, 0);
} else {
me->state = STAL_DEAD;
}
@ -105,7 +105,7 @@ bool ALIVE_processEvent(Event* ev) {
me->state = STAL_BREAK;
}
} else {
ALIVE_emitPoll(me, me->aliveTime*10, 0);
ALIVE_emitPoll(me, me->aliveTime*20, 0);
}
}
break;

View File

@ -272,6 +272,7 @@
<property key="debugoptions.useswbreakpoints" value="false"/>
<property key="event.recorder.enabled" value="false"/>
<property key="event.recorder.scvd.files" value=""/>
<property key="firmware.download.all" value="false"/>
<property key="hwtoolclock.frcindebug" value="false"/>
<property key="lastid" value=""/>
<property key="memories.aux" value="false"/>

File diff suppressed because one or more lines are too long

View File

@ -46,10 +46,10 @@
<Window_Position>
<Visibility>SHOWNORMAL</Visibility>
<WindowPlacement>RESTORETOMAXIMIZED</WindowPlacement>
<Top>522</Top>
<Left>622</Left>
<Bottom>1019</Bottom>
<Right>1044</Right>
<Top>195</Top>
<Left>426</Left>
<Bottom>692</Bottom>
<Right>848</Right>
</Window_Position>
</Bus_Statistics>
<J1939_Database_Files/>
@ -327,8 +327,8 @@
<Message>
<Id>529</Id>
<Signal>posX</Signal>
<Signal>button</Signal>
<Signal>posY</Signal>
<Signal>button</Signal>
</Message>
<Message>
<Id>1040</Id>
@ -348,9 +348,9 @@
</Message>
<Message>
<Id>336</Id>
<Signal>HOMING</Signal>
<Signal>SET_CENTER</Signal>
<Signal>RESET</Signal>
<Signal>SET_CENTER</Signal>
<Signal>HOMING</Signal>
</Message>
<Message>
<Id>82</Id>
@ -363,16 +363,16 @@
<Window_Position>
<Visibility>SHOWNORMAL</Visibility>
<WindowPlacement>HIDE</WindowPlacement>
<Top>151</Top>
<Left>608</Left>
<Right>1098</Right>
<Bottom>582</Bottom>
<Top>456</Top>
<Left>632</Left>
<Right>1079</Right>
<Bottom>744</Bottom>
</Window_Position>
<COLUMN_WIDTH>
<MESSAGE_COLUMN>94</MESSAGE_COLUMN>
<Raw_Val_Column>94</Raw_Val_Column>
<MESSAGE_COLUMN>151</MESSAGE_COLUMN>
<Raw_Val_Column>137</Raw_Val_Column>
<Physical_Val_Column>172</Physical_Val_Column>
<Signal_Column>94</Signal_Column>
<Signal_Column>86</Signal_Column>
</COLUMN_WIDTH>
</CAN_Signal_Watch>
<J1939_Signal_Watch>
@ -562,9 +562,9 @@
<Window_Position>
<Visibility>SHOWNORMAL</Visibility>
<WindowPlacement>SETMINPOSITION</WindowPlacement>
<Top>0</Top>
<Top>3</Top>
<Left>0</Left>
<Bottom>810</Bottom>
<Bottom>627</Bottom>
<Right>606</Right>
</Window_Position>
<Interpretation_Window_Position>
@ -653,7 +653,7 @@
<ID>Data Byte(s)</ID>
<Order>13</Order>
<IsVisible>1</IsVisible>
<Width>701</Width>
<Width>643</Width>
</COLUMN>
<IsHex>1</IsHex>
<IsAppend>0</IsAppend>
@ -665,7 +665,7 @@
<Top>0</Top>
<Left>0</Left>
<Bottom>549</Bottom>
<Right>1614</Right>
<Right>1556</Right>
</Window_Position>
<Interpretation_Window_Position>
<Visibility>SHOWNORMAL</Visibility>
@ -738,7 +738,7 @@
<ID>Checksum</ID>
<Order>10</Order>
<IsVisible>1</IsVisible>
<Width>715</Width>
<Width>657</Width>
</COLUMN>
<IsHex>1</IsHex>
<IsAppend>0</IsAppend>
@ -750,7 +750,7 @@
<Top>0</Top>
<Left>0</Left>
<Bottom>549</Bottom>
<Right>1614</Right>
<Right>1556</Right>
</Window_Position>
<Interpretation_Window_Position>
<Visibility>SHOWNORMAL</Visibility>
@ -765,10 +765,10 @@
<Window_Position>
<Visibility>SHOWNORMAL</Visibility>
<WindowPlacement>SETMINPOSITION</WindowPlacement>
<Top>3</Top>
<Left>1052</Left>
<Bottom>658</Bottom>
<Right>1912</Right>
<Top>4</Top>
<Left>648</Left>
<Bottom>659</Bottom>
<Right>1508</Right>
</Window_Position>
<Message_List>
<Message>
@ -885,7 +885,7 @@
<IsExtended>FALSE</IsExtended>
<IsRtr>FALSE</IsRtr>
<DLC>3</DLC>
<DataBytes>25,0,0</DataBytes>
<DataBytes>25,50,0</DataBytes>
<Repetion>10</Repetion>
<Repetition_Enabled>FALSE</Repetition_Enabled>
<Key_Value>a</Key_Value>
@ -899,7 +899,43 @@
<DLC>2</DLC>
<DataBytes>0,0</DataBytes>
<Repetion>500</Repetion>
<Repetition_Enabled>TRUE</Repetition_Enabled>
<Repetition_Enabled>FALSE</Repetition_Enabled>
<Key_Value>a</Key_Value>
<Key_Enabled>FALSE</Key_Enabled>
</Message>
<Message>
<Channel>1</Channel>
<Message_ID>543</Message_ID>
<IsExtended>FALSE</IsExtended>
<IsRtr>FALSE</IsRtr>
<DLC>1</DLC>
<DataBytes>0</DataBytes>
<Repetion>100</Repetion>
<Repetition_Enabled>FALSE</Repetition_Enabled>
<Key_Value>a</Key_Value>
<Key_Enabled>FALSE</Key_Enabled>
</Message>
<Message>
<Channel>1</Channel>
<Message_ID>23</Message_ID>
<IsExtended>FALSE</IsExtended>
<IsRtr>FALSE</IsRtr>
<DLC>4</DLC>
<DataBytes>250,0,0,0</DataBytes>
<Repetion>10</Repetion>
<Repetition_Enabled>FALSE</Repetition_Enabled>
<Key_Value>a</Key_Value>
<Key_Enabled>FALSE</Key_Enabled>
</Message>
<Message>
<Channel>1</Channel>
<Message_ID>1540</Message_ID>
<IsExtended>FALSE</IsExtended>
<IsRtr>FALSE</IsRtr>
<DLC>4</DLC>
<DataBytes>0,0,0,0</DataBytes>
<Repetion>10</Repetion>
<Repetition_Enabled>FALSE</Repetition_Enabled>
<Key_Value>a</Key_Value>
<Key_Enabled>FALSE</Key_Enabled>
</Message>