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

Regen Pedal Remap and Hysteresis Derate #1351

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

Conversation

philam2001
Copy link
Contributor

@philam2001 philam2001 commented Oct 15, 2024

Changelist

  • regen range 20% of pedal, cruising range 10%, acceleration range 70%
  • change app_canTx_VC_MappedPedalPercentage to -100% to 100% for better readability
  • clean up regen code and clarify some things in drive state

Testing Done

Resolved Tickets

FIRM-156

@philam2001 philam2001 self-assigned this Oct 15, 2024
@philam2001 philam2001 added the Vehicle Controls Torque Vectoring, Regen, Brake/Drive Diffs label Oct 15, 2024
@philam2001 philam2001 force-pushed the phi/pedal_remap branch 2 times, most recently from ae55042 to 3774fa5 Compare November 29, 2024 22:36
Copy link
Contributor

@Lucien950 Lucien950 left a comment

Choose a reason for hiding this comment

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

few questions

static RegenBraking_Inputs regenAttributes = { .enable_active_differential = true };
static ActiveDifferential_Inputs activeDifferentialInputs;
static PowerLimiting_Inputs powerLimitingInputs = { .power_limit_kW = POWER_LIMIT_REGEN_kW };
static bool regen_enabled = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this a static variable? can we just have a function which determines it? I worry about stale information

Copy link
Contributor Author

Choose a reason for hiding this comment

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

initialized once at the beginning and persists between calls until we change it wheelSpeedInRange. I think you would want this to make sure you have the last condition the car state was in for hysterisis? what stale info do u mean

@@ -76,11 +80,22 @@ bool app_regen_safetyCheck(RegenBraking_Inputs *regenAttr, ActiveDifferential_In

static bool wheelSpeedInRange(ActiveDifferential_Inputs *inputs)
{
// Hysterisis
Copy link
Contributor

Choose a reason for hiding this comment

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

this this hysterisis or does it just cut it off < 7kph?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it'll cut off at 5kph if you were regening before and then start back up again after 7kph

// no power limit, no active differential
regenAttr->left_inverter_torque_Nm = MAX_REGEN_Nm * pedal_percentage * regenAttr->derating_value;
regenAttr->right_inverter_torque_Nm = MAX_REGEN_Nm * pedal_percentage * regenAttr->derating_value;
return apps_pedal_percentage / (MAX_PEDAL_PERCENT - PEDAL_SCALE - 0.1f);
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think this is right, I think you need to

Suggested change
return apps_pedal_percentage / (MAX_PEDAL_PERCENT - PEDAL_SCALE - 0.1f);
return (apps_pedal_percentage-0.1f) / (MAX_PEDAL_PERCENT - PEDAL_SCALE - 0.1f);

Copy link
Contributor

Choose a reason for hiding this comment

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

because this assumes that the increasing part of the graph is rooted at the origin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh nice catch oops

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fak i should write tests for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Vehicle Controls Torque Vectoring, Regen, Brake/Drive Diffs
Development

Successfully merging this pull request may close these issues.

2 participants