Skip to content

VCU linelock regen implementation#243

Open
Acloran wants to merge 4 commits into
mainfrom
codex/vcu-linelock-regen
Open

VCU linelock regen implementation#243
Acloran wants to merge 4 commits into
mainfrom
codex/vcu-linelock-regen

Conversation

@Acloran
Copy link
Copy Markdown

@Acloran Acloran commented May 25, 2026

Added VCU functionality for line lock and regen control

@Acloran Acloran requested a review from a team as a code owner May 25, 2026 12:52
@Acloran Acloran requested review from alicedimauro and angelasrsh and removed request for a team May 25, 2026 12:52
@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lhre-2026 Ready Ready Preview, Comment May 25, 2026 12:52pm

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new RegenLinelock component to the VCU model, enabling regenerative braking control via a rear linelock valve. The implementation includes logic for estimating battery pack OCV, calculating torque limits based on available current and voltage headroom, and enforcing safety gates related to temperature, motor speed, and CAN message validity. Firmware changes include new CAN message handlers for battery pack status and switch commands. Review feedback focuses on improving safety by ensuring torque limits are always enforced, expanding parameter validation, and aggregating input validity into the component's summary fault bit.

Comment on lines +129 to +132
const float cap_nm = params->regen_linelock.absolute_regen_torque_cap_nm;
if (cap_nm > 0.0f) {
torque_nm = clamp_f(torque_nm, 0.0f, cap_nm);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The if (cap_nm > 0.0f) check is potentially dangerous. If absolute_regen_torque_cap_nm is set to 0.0f (or not initialized), the clamp is skipped, and the function could return an extremely high torque value calculated at low speeds. Removing the if ensures the torque is always clamped to the configured limit.

  const float cap_nm = params->regen_linelock.absolute_regen_torque_cap_nm;
  torque_nm = clamp_f(torque_nm, 0.0f, cap_nm);

Comment on lines +16 to +18
params->regen_linelock.min_cell_temp_c <
params->regen_linelock.max_cell_temp_c &&
params->regen_linelock.max_cell_temp_c > 0.0f;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The parameter validation should include a check for absolute_regen_torque_cap_nm to ensure it is a positive value, as it is used as a divisor or clamp limit in torque calculations.

         params->regen_linelock.min_cell_temp_c <
             params->regen_linelock.max_cell_temp_c &&
         params->regen_linelock.max_cell_temp_c > 0.0f &&
         params->regen_linelock.absolute_regen_torque_cap_nm > 0.0f;

out->faults.regen_linelock_motor_speed_low = motor_speed_low;
out->faults.regen_linelock_current_hard_cut =
state->current_hard_cut_latched;
out->faults.regen_linelock_any_fault = state->current_hard_cut_latched;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

regen_linelock_any_fault should include regen_linelock_input_invalid. Loss of critical CAN inputs (battery status, inverter data) is a fault condition that should be aggregated into the component's summary fault bit to ensure the vehicle can react appropriately (e.g., by cutting torque via any_fault_exists).

Suggested change
out->faults.regen_linelock_any_fault = state->current_hard_cut_latched;
out->defaults.regen_linelock_any_fault = state->current_hard_cut_latched ||
!input_valid;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Control Systems documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant