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

One pedal drive #262

Closed
wants to merge 16 commits into from
Closed

One pedal drive #262

wants to merge 16 commits into from

Conversation

Akashem06
Copy link
Member

No description provided.

@@ -48,20 +51,44 @@ static float prv_get_float(uint32_t u) {
return fu.f;
}

static float prv_one_pedal_drive_current(float throttle_percent, float car_velocity,
DriveState *drive_state) {
float threshold = car_velocity <= MAX_OPD_SPEED ? car_velocity * COASTING_THERSHOLD_SCALE
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick, I think these should be if statements instead of ternary

case NEUTRAL:
s_target_current = 0;
case BRAKE: // When braking and regen is off it should be the same as NEUTRAL. regen = 0
s_target_current = regen < 100 ? regen / 100.0 : throttle_percent;
Copy link
Collaborator

Choose a reason for hiding this comment

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

same thing with ternary here

@@ -130,9 +156,11 @@ static void motor_controller_rx_all() {

case MOTOR_CONTROLLER_BASE_L + VEL_MEASUREMENT:
set_motor_velocity_velocity_l(prv_get_float(msg.data_u32[0]) * VELOCITY_SCALE);
s_car_velocity_l = prv_get_float(msg.data_u32[1]) * CONVERT_VELOCITY_TO_KPH;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this file used this msg struct already but could you link to the doc where the uint32's value is defined? The link up top is dead


DriveState drive_state = get_drive_output_drive_state();
bool regen = get_drive_output_regen_braking();
uint8_t regen = get_drive_output_regen_braking();
Copy link
Collaborator

Choose a reason for hiding this comment

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

A comment about what this value is would be useful

@Akashem06 Akashem06 closed this May 19, 2024
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.

2 participants