Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch control + Internal speed controller #31

Open
wants to merge 33 commits into
base: launch-control
Choose a base branch
from

Conversation

sebLopezCot
Copy link
Contributor

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.

@nistath nistath self-requested a review October 13, 2018 22:07
length: 32
c_type: int32_t
VCUSpeedCntrlMinInputValue:
can_id: 0x231
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 space after : gore


// PUBLIC STRUCTS
typedef struct {
int32_t kp_times_1000;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should be unsigned

} SpeedControllerInternalVars;

// PUBLIC FUNCTIONS
void init_speed_controller_defaults(int32_t max_input_speed,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another annoying indentation inconsistency


int32_t speedControlTorqueOutput = get_speed_controller_torque_command();
if (speedControlTorqueOutput >= MAX_TORQUE) {
speedControlTorqueOutput = MAX_TORQUE;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't multiply by 1000

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Had offline conversation.)

@skoppula
Copy link
Collaborator

White spacing appears to be hard, @sebLopezCot 😿

@@ -108,6 +108,10 @@ void dispatch_init() {
carstats.vcu_controls_received = false;
carstats.vcu_lc_controls_received = false;

carstats.rpm_setpoint.rpm_setpoint = 0;
carstats.ki.ki_times_1000 = 1000;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend you just zero this when init'ing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or loading in the default vals (we might want to start putting kp, ki as defines in a header for speed controller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants