This commit is contained in:
Rémi Heredero 2023-09-07 10:31:26 +02:00
parent 8d389cdea2
commit 5c555f6ee1
4 changed files with 9 additions and 3 deletions

View File

@ -24,7 +24,7 @@ void MEM_init(){
uint8_t check = MEM_read_1_byte(0x0);
if(check != 0x42){
KART_CST.CONTROL_STEERING_MODE = 0;
KART_CST.CONTROL_ALIVE_TIME = 250; // should be 50
KART_CST.CONTROL_ALIVE_TIME = 50; // should be 50
KART_CST.CONTROL_SPEED_FACTOR = 111111; // 111'111
KART_CST.CONTROL_POWER_FACTOR = 10000; // 10'000
KART_CST.CONTROL_STEERING_FACTOR = 5600240; // 5'600'024

View File

@ -40,6 +40,7 @@ void Factory_init() {
CAN_setSender(1);
MEM_init();
initRamp();
ALIVE_init(ALcontroller(), 6);
ALIVE_setAliveTime(ALcontroller(), KART_CST.CONTROL_ALIVE_TIME);

View File

@ -225,7 +225,9 @@ void calcTorque(uint8_t joy_pos) {
if(joy_pos >= 0) {
calcTorque = rampTorque[joy_pos];
} else {
calcTorque = -rampTorque[-joy_pos];
joy_pos *= -1;
calcTorque = rampTorque[joy_pos];
calcTorque *= -1;
}
calcTorque *= KART_CST.CONTROL_POWER_FACTOR; // convert by power factor
calcTorque /= 1000; // torque define by joystick
@ -239,7 +241,9 @@ void calcPosition(uint8_t joy_pos){
if(joy_pos >= 0) {
calcPosition = rampPosition[joy_pos];
} else {
calcPosition = -rampPosition[-joy_pos];
joy_pos *= -1;
calcPosition = rampPosition[joy_pos];
rampPosition *= -1;
}
calcPosition *= (int32_t) KART_CST.CONTROL_STEERING_FACTOR;
calcPosition /= 1000;

View File

@ -13,6 +13,7 @@
#include "../mcc_generated_files/mcc.h"
#include "car.h"
void initRamp();
void deadJoystick(void* p);
void calcTorque(uint8_t joy_pos);
void calcPosition(uint8_t joy_pos);