Browse Source

fine tuning of paddle parameters

master
phail 3 years ago
parent
commit
b9710cbcc9
  1. 6
      include/Paddelec.h
  2. 1
      include/config.h
  3. 2
      include/go_display.h
  4. 40
      src/communication.cpp
  5. 4
      src/go_display.cpp

6
include/Paddelec.h

@ -33,15 +33,15 @@ class Paddelec
{
imu.init();
cfgPaddle.paddleAngleThreshold = 22.0; // activation angle threshold of paddle. Below threshold, paddle is not enganged and paddelec is freewheeling.
cfgPaddle.deltaRtoSpeed = 0.0006; // conversion factor between paddle movement to speed. This defines also the maximum speed.
cfgPaddle.pwmMultiplier = 0.02; // effect of paddle stroke to speed
cfgPaddle.deltaRtoSpeed = 0.00025; // conversion factor between paddle movement to speed. This defines also the maximum speed.
cfgPaddle.pwmMultiplier = 0.10; // effect of paddle stroke to speed
cfgPaddle.crosstalkLR = 0.0; // multiplier for steering
cfgPaddle.realign = 0.0; // paddelc tries to go straight forward
cfgPaddle.drag = 0.0002; // drag/water resistance
cfgPaddle.flipControl = 1; // 1: Normal. -1 Flipped
cfgPaddle.maxValidSpeed = 15.0; // All speed inputs above this threshold are considered unplausible and therefore faulty
cfgPaddle.maxValidSteer = 15.0; // All steer inputs above this threshold are considered unplausible and therefore faulty
cfgPaddle.maxValidGyro = (int16_t)(20.0 / cfgPaddle.deltaRtoSpeed); // All steer inputs above this threshold are considered unplausible and therefore faulty
cfgPaddle.maxValidGyro = (int16_t)(40.0 / cfgPaddle.deltaRtoSpeed); // All steer inputs above this threshold are considered unplausible and therefore faulty
cfgPaddle.inertiaThreshold = 20.0; // Minimum value to get vehicle moving
cfgPaddle.inertiaOffset = 50.0; // Offset to set vehicle in motion
cfgPaddle.debugMode = true; // enable debug output

1
include/config.h

@ -132,6 +132,7 @@ extern sysconfig_t sysconfig;
#if (CONFIGURATION_SET == CFG_PANZER)
# define OTA_HANDLER
# define SERIAL2_GNDPIN 26 // Pin used as GND - Needed for psycho
# define INPUT_NUNCHUK
#endif

2
include/go_display.h

@ -56,6 +56,8 @@ namespace GO_DISPLAY
MENU_PADDLEMULTDEC,
MENU_PADDLESPEEDINC,
MENU_PADDLESPEEDDEC,
MENU_PWM_VOLLGAS,
MENU_PWM_HALBGAS,
MENU_IDLE
} menu_result;

40
src/communication.cpp

@ -41,9 +41,9 @@ PROTOCOL_PWM_DATA PWMData = {
.speed_minimum_pwm = 1 // guard value, below this set to zero
#else
.pwm = {0,0},
.speed_max_power = 400,
.speed_min_power = -400,
.speed_minimum_pwm = 30 // guard value, below this set to zero
.speed_max_power = 500,
.speed_min_power = -500,
.speed_minimum_pwm = 20 // guard value, below this set to zero
#endif
};
@ -573,16 +573,19 @@ void processOdroidGo()
static int16_t tempPID = 100;
double deltaRtoSpeed = paddelec.cfgPaddle.deltaRtoSpeed * 10000.0;
double pwmMultiplier = paddelec.cfgPaddle.pwmMultiplier * 100.0;
// TODO: assuming motor 0 is left and motor 1 is right
GO_DISPLAY::set(GO_DISPLAY::CURRENT_LEFT ,hbpOut.getMotorAmpsAvg(0));
GO_DISPLAY::set(GO_DISPLAY::CURRENT_RIGHT ,hbpOut.getMotorAmpsAvg(1));
GO_DISPLAY::set(GO_DISPLAY::SPEED, hbpOut.getSpeed_kmh());
GO_DISPLAY::set(GO_DISPLAY::STEER, hbpOut.getSteer_kmh());
GO_DISPLAY::set(GO_DISPLAY::PWM_LEFT, PWMData.pwm[0]);
GO_DISPLAY::set(GO_DISPLAY::PWM_RIGHT, PWMData.pwm[1]);
GO_DISPLAY::set(GO_DISPLAY::PWM_RIGHT, deltaRtoSpeed);
GO_DISPLAY::set(GO_DISPLAY::BATTERY_VOLTAGE, hbpOut.getBatteryVoltage());
GO_DISPLAY::set(GO_DISPLAY::PACKAGE_LOSS_DOWNSTREAM, (float) latency);
GO_DISPLAY::set(GO_DISPLAY::PACKAGE_LOSS_UPSTREAM, (float) tempPID);
GO_DISPLAY::set(GO_DISPLAY::PACKAGE_LOSS_UPSTREAM, pwmMultiplier);
GO_DISPLAY::plotBattery(hbpOut.getBatteryVoltage());
GO_DISPLAY::plotSpeed(hbpOut.getSpeed_kmh());
@ -590,22 +593,22 @@ void processOdroidGo()
double odroidSpeed = 0.0;
double odroidSteer = 0.0;
if(GO.JOY_Y.isAxisPressed() == 2) odroidSpeed = 200.0;
if(GO.JOY_Y.isAxisPressed() == 1) odroidSpeed = -200.0;
if(GO.JOY_X.isAxisPressed() == 1) odroidSteer = 200.0;
if(GO.JOY_X.isAxisPressed() == 2) odroidSteer = -200.0;
if(GO.JOY_Y.isAxisPressed() == 2) odroidSpeed = PWMData.speed_max_power / 3;
if(GO.JOY_Y.isAxisPressed() == 1) odroidSpeed = -PWMData.speed_max_power / 3;
if(GO.JOY_X.isAxisPressed() == 1) odroidSteer = PWMData.speed_max_power / 3;
if(GO.JOY_X.isAxisPressed() == 2) odroidSteer = -PWMData.speed_max_power / 3;
if(GO.BtnA.isPressed()) odroidSpeed = odroidSpeed *2.0;
if(GO.BtnB.isPressed()) odroidSpeed = odroidSpeed *2.0;
if(odroidSpeed > 400) odroidSpeed = 400;
if(odroidSpeed < -400) odroidSpeed = -400;
if(odroidSpeed > PWMData.speed_max_power) odroidSpeed = PWMData.speed_max_power;
if(odroidSpeed < -PWMData.speed_max_power) odroidSpeed = -PWMData.speed_max_power;
if(nunchukState != RUNNING)
{
slowReset(motor.setpoint.pwm, odroidSpeed, 0, 0.15);
slowReset(motor.setpoint.steer, odroidSteer, 0, 0.5);
slowReset(motor.setpoint.steer, odroidSteer, 0, 0.2);
}
if(GO.BtnStart.isPressed()) hbpOut.sendPing();
@ -728,6 +731,19 @@ void processOdroidGo()
else state = OD_LCD_MONITORINIT;
break;
case GO_DISPLAY::MENU_PWM_VOLLGAS:
PWMData.speed_max_power = 1000;
hbpOut.sendPWMData(PWMData.pwm[0], PWMData.pwm[1], PWMData.speed_max_power, PWMData.speed_min_power, PWMData.speed_minimum_pwm, PROTOCOL_SOM_ACK);
state = OD_LCD_MONITORINIT;
break;
case GO_DISPLAY::MENU_PWM_HALBGAS:
PWMData.speed_max_power = 400;
hbpOut.sendPWMData(PWMData.pwm[0], PWMData.pwm[1], PWMData.speed_max_power, PWMData.speed_min_power, PWMData.speed_minimum_pwm, PROTOCOL_SOM_ACK);
state = OD_LCD_MONITORINIT;
break;
default:
break;
}

4
src/go_display.cpp

@ -191,6 +191,10 @@ namespace GO_DISPLAY
GO.lcd.print("Paddle increase gyro to speed");
GO.lcd.setCharCursor(firstcolumn + 2, cursor++);
GO.lcd.print("Paddle decrease gyro to speed");
GO.lcd.setCharCursor(firstcolumn + 2, cursor++);
GO.lcd.print("PWM no limit");
GO.lcd.setCharCursor(firstcolumn + 2, cursor++);
GO.lcd.print("PWM limit 400");
entries = cursor - firstline;
cursor = firstline;

Loading…
Cancel
Save