Skip to content

Launch control + Internal speed controller#31

Open
sebLopezCot wants to merge 33 commits into
launch-controlfrom
launch-control-internal-speed-controller
Open

Launch control + Internal speed controller#31
sebLopezCot wants to merge 33 commits into
launch-controlfrom
launch-control-internal-speed-controller

Conversation

@sebLopezCot

Copy link
Copy Markdown
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.

@sebLopezCot sebLopezCot requested a review from daniwhite October 13, 2018 21:32
@nistath nistath self-requested a review October 13, 2018 22:07
Comment thread can_spec_my18.yml
length: 32
c_type: int32_t
VCUSpeedCntrlMinInputValue:
can_id: 0x231

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

Comment thread src/vcu/src/controls.c Outdated

int32_t speedControlTorqueOutput = get_speed_controller_torque_command();
if (speedControlTorqueOutput >= MAX_TORQUE) {
speedControlTorqueOutput = MAX_TORQUE;

Copy link
Copy Markdown
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).

Comment thread src/vcu/src/controls.c Outdated
speed_command = 500; // get_launch_control_speed(front_wheel_speed);
sendSpeedCmdMsg(speed_command, torque_command);

set_speed_controller_setpoint(500); // RPM

Copy link
Copy Markdown
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.

Comment thread src/vcu/src/speed_controller.c Outdated
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
Copy Markdown
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

Comment thread src/vcu/src/speed_controller.c Outdated
// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

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;

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

Comment thread src/dashboard/src/page_manager.c
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