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

Parking mode idle improved behavior #32

Open
wants to merge 1 commit into
base: v1.1-preview2-devel1
Choose a base branch
from

Conversation

surfdado
Copy link
Contributor

If rider jumps off the board and the board changes direction after jumping off, it is assumed that the parking brake should be on.

This addresses the use case where you're going uphill and you jump off because it got too steep

Copy link
Owner

@lukash lukash left a comment

Choose a reason for hiding this comment

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

Thanks for this, I like it in general, comments are mostly about putting things in the right places and nitpicks.

@@ -592,6 +594,7 @@ static bool check_faults(data *d) {
}
} else {
d->fault_switch_timer = d->current_time;
d->motor.last_erpm_sign = d->motor.erpm_sign;
Copy link
Owner

Choose a reason for hiding this comment

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

Modifying the MotorData structure outside of the motor_data_ functions goes against the concept of the modularization (which is, any work with the module data happens inside the module, outside of it, you only read them).

I'm also not sure there's more than meets the eye to the surgical precision with which you placed the assignment in two places of the check_faults() function 😀. But the fact it's two places is bad in itself, and this function really needs stuff removed, not added (it needs a refactor).

Instead, please set last_erpm_sign inside motor_data_update(). You'll have to pass whatever data you need for the condition. Seems to me you need d->state.state and check it's equal to STATE_RUNNING and keep updating the var for as long as that holds true. But I might have missed a detail in how you placed those assignments, it's not entirely obvious (which is the point I'm trying to make).

I'd call the variable erpm_last_running_sign.

src/motor_control.c Outdated Show resolved Hide resolved
src/motor_control.c Outdated Show resolved Hide resolved
src/motor_control.c Outdated Show resolved Hide resolved
} else {
mc->parking_brake_active = false;
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

I like this change to the logic (where the ALWAYS/NEVER cases are handled in configure), it's easier to understand this way 👍.

But is there a reason you put this into the "brake logic" branch, meaning it's not evaluated when there's regular current requested? I'm not sure of the implications right now...

@lukash
Copy link
Owner

lukash commented Dec 25, 2024

Forgot to mention, the changelog record:

Fix: don't let board roll downhill after jumping off at low speed

Will be out of context and not really clear in the changelog. I'd also incline more towards marking it as a feature, as it's not a bug that it's fixing per se. What about something like:

Feature: Parking Brake: Brake immediately if the board would roll the opposite way (e.g. downhill when one jumps off while going uphill)

@surfdado
Copy link
Contributor Author

Reposting the updated PR against the testing branch

If rider jumps off the board and the board changes direction after
jumping off, it is assumed that the parking brake should be on.

Feature: Parking Brake: Brake immediately if the board would roll the opposite way (e.g. downhill when one jumps off while going uphill)
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.

3 participants