Launch control + Internal speed controller#31
Conversation
| length: 32 | ||
| c_type: int32_t | ||
| VCUSpeedCntrlMinInputValue: | ||
| can_id: 0x231 |
|
|
||
| // PUBLIC STRUCTS | ||
| typedef struct { | ||
| int32_t kp_times_1000; |
There was a problem hiding this comment.
Small thing but this indentation is annoying
| int32_t max_output_value; | ||
| int32_t min_input_value; | ||
| int32_t max_input_value; | ||
| int32_t dt; |
There was a problem hiding this comment.
Maybe should be unsigned
| } SpeedControllerInternalVars; | ||
|
|
||
| // PUBLIC FUNCTIONS | ||
| void init_speed_controller_defaults(int32_t max_input_speed, |
There was a problem hiding this comment.
Another annoying indentation inconsistency
|
|
||
| int32_t speedControlTorqueOutput = get_speed_controller_torque_command(); | ||
| if (speedControlTorqueOutput >= MAX_TORQUE) { | ||
| speedControlTorqueOutput = MAX_TORQUE; |
There was a problem hiding this comment.
This isn't correct - you need to compare it with what the driver is commanding (which is torque_command).
| speed_command = 500; // get_launch_control_speed(front_wheel_speed); | ||
| sendSpeedCmdMsg(speed_command, torque_command); | ||
|
|
||
| set_speed_controller_setpoint(500); // RPM |
There was a problem hiding this comment.
This should be configurable from the dash.
| speed_controller_params.kp_times_1000 = 200; | ||
| speed_controller_params.ki_times_1000 = 0; | ||
| speed_controller_params.kd_times_1000 = 0; | ||
| speed_controller_params.i_windup_max = 10; |
There was a problem hiding this comment.
This is waayyyyyyyy to small
| // Multiply by 100 for precision, example: 1234 rpm * 1000 / 12ms = 102833, 1 rpm * 1000 / 12ms = 83 | ||
| speed_controller_vars.deriv_rpm_error = | ||
| (speed_controller_vars.rpm_error | ||
| - speed_controller_vars.last_rpm_error) * 1000 / speed_controller_params.dt; |
There was a problem hiding this comment.
(Had offline conversation.)
…thub.com/MITMotorsports/MY18 into launch-control-internal-speed-controller
…:MITMotorsports/MY18 into launch-control-internal-speed-controller
This reverts commit 903e520.
|
White spacing appears to be hard, @sebLopezCot 😿 |
| carstats.vcu_lc_controls_received = false; | ||
|
|
||
| carstats.rpm_setpoint.rpm_setpoint = 0; | ||
| carstats.ki.ki_times_1000 = 1000; |
There was a problem hiding this comment.
I'd recommend you just zero this when init'ing
There was a problem hiding this comment.
Or loading in the default vals (we might want to start putting kp, ki as defines in a header for speed controller
(cherry picked from commit 40490cb)
This PR is used for reviewing the internal speed controller code which may be integrated with launch control. Note: this code should only be used on the jacks for it sets a constant speed and does not use the speeding up state yet.