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 brake checks for erpm sign now #34

Open
wants to merge 1 commit into
base: testing
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.

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

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)
mc->parking_brake_active = true;
} else if (mc->parking_brake_mode == PARKING_BRAKE_NEVER || state == STATE_RUNNING) {
mc->parking_brake_active = false;
void motor_control_apply(MotorControl *mc, const MotorData *md, RunState state, float time) {
Copy link

@JJJ JJJ Jan 14, 2025

Choose a reason for hiding this comment

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

const MotorData *motor is used elsewhere, though I personally think *md is best:

void torque_tilt_update(TorqueTilt *tt, const MotorData *motor, const RefloatConfig *config) {

static void atr_update(ATR *atr, const MotorData *motor, const RefloatConfig *config) {

ATR *atr, const MotorData *motor, const RefloatConfig *config, float proportional

void torque_tilt_update(TorqueTilt *tt, const MotorData *motor, const RefloatConfig *config);


(*m used in other places, so maybe it isn't important, yet?)

void motor_data_reset(MotorData *m) {

void motor_data_configure(MotorData *m, float frequency) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to be consistent within the line of code I changed, so *md makes sense. But idk why you would even bother commenting on stuff like this. I could care less. Let Lukas name it however he wants.

Copy link

Choose a reason for hiding this comment

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

idk why you would even bother commenting on stuff like this

Because that is how contributing to open-source software works, and how the code gets better over time.

The world reviews requests for progress, and iterates forward together.

I could care less

That's your problem; don't make it mine.

Copy link
Owner

Choose a reason for hiding this comment

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

It would be nice to have those consistent, but I'm not gonna spend time going over them to try to unify everything. Sometimes it's a balance of a short name that'll keep the lines from wrapping vs. the name being descriptive enough.

And I'm not gonna bug the PR author with such a small thing if the name is not outright bad.

If you want, @JJJ, you can post a PR unifying all the names of these arguments, I'll merge it 😁

void motor_control_apply(MotorControl *mc, const MotorData *md, RunState state, float time) {
if (mc->parking_brake_mode == PARKING_BRAKE_IDLE) {
if (state != STATE_RUNNING &&
(md->abs_erpm_smooth < 50 || md->last_erpm_sign != md->erpm_sign)) {
Copy link

Choose a reason for hiding this comment

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

Is 50 an approximation?

Should this be variable/configurable eventually?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. this isn't part of my PR
  2. but PLEASE not another parameter for something as mundane as this. 50 seems just fine, if you have arguments why it should be different let's hear them

Copy link

Choose a reason for hiding this comment

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

if you have arguments why it should be different let's hear them

I'm not arguing, or suggesting – I'm asking, while reviewing/observing.

this isn't part of my PR

You're touching this line-of-code and suggesting a change to the surrounding behavior. While we're all here now, look at it, consider it, understand whether 50 is a problem.

It stands out to me as a code-smell that may be contributing to the parking brake feature not behaving as intended, because 50 erpm is unlikely to just be the magic value that makes it work perfectly.

I'm not trying to block your progress or be a jerk, so chill with the defensiveness eh?

Copy link
Owner

Choose a reason for hiding this comment

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

I put the 50 there. Seemed to work well to me. This value will not be configurable, it's supposed to represent "0" with a small amount of leeway for erpm noise.

@@ -30,6 +30,7 @@ typedef struct {
float abs_erpm_smooth;
float last_erpm;
int8_t erpm_sign;
int8_t last_erpm_sign; // last erpm sign prior to footpads disengaging
Copy link

Choose a reason for hiding this comment

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

@lukash is probably going to tell you to delete your code comment 😂 because none of the others have them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need more comments, not less

Copy link

Choose a reason for hiding this comment

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

I agree, but not everyone does

Copy link
Owner

Choose a reason for hiding this comment

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

This comment is good, because it's not clear what "last" means in the variable name. It's totally fine this one has a comment and the others don't.

If I was to be extra nitpicky, saying just "... prior to disengaging" would be a bit better.

@lukash
Copy link
Owner

lukash commented Jan 16, 2025

@surfdado thanks for addressing the review, but the actual most important comment was not addressed: #32 (comment)

We need well-structured code more than we need e.g. comments.

Also, is this working well for you? In situations when I had to jump off the board when it wouldn't go up a steep hill, most of the time I'd push the board on the tail just a bit before disengaging, making it shoot downhill. I don't think this implementation would catch it, as it would start the reverse before disengaging.

What I was imagining when we discussed it was last_erpm_sign with a delay, e.g. 1 second. Maybe even 0.5s would do. Not entirely sure about it, I'd have to test it, it'd obviously be a bit harder to implement and this PR is an improvement already, so just something for you to consider if you'd like.

@surfdado
Copy link
Contributor Author

yes, this feature works as it should now for me - it no longer shoots downhill for me on steep climbs when I need to dismount. But of course, if you're already sliding backwards by the time you jump off this feature won't work - and I don't really see a good way around that. A timer based implementation seems hacky to my but if you'd like to do it that way please go ahead.

@lukash
Copy link
Owner

lukash commented Jan 21, 2025

Yes, it would not be pretty and could be considered hacky. I just wanted to bring it up, I won't go testing or doing it now, maybe sometime later, after I see how your implementation does.

Meanwhile, my one remaining point blocking the PR remains without an answer... 😞

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