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

Allow IsPowered to return negative power percentages. #3703

Merged
merged 2 commits into from
Mar 19, 2024

Conversation

randhid
Copy link
Member

@randhid randhid commented Mar 18, 2024

I am pretty sure this was not written expecting that PowerPct would always return positive. Just an oversight on taking the absolute value of the power percentage.

Still need to fix tests, but it should be returning negative percentages even when on now.

Please

  • Test on hardware after I rebase - I will add the app image label to this pr.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Mar 18, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 18, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 18, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 18, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 18, 2024
@randhid randhid added appimage-ignore-tests Build AppImage of PR and ignore tests static-ignore-tests Build static binaries from PR and ignore tests and removed appimage-ignore-tests Build AppImage of PR and ignore tests labels Mar 18, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 19, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 19, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 19, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 19, 2024
@randhid
Copy link
Member Author

randhid commented Mar 19, 2024

It's way worse now, but I don't have the bandwidth for a full factor of this code - and there will need to be some consideration for when we set the pins versus the locks.

Copy link
Member

@JohnN193 JohnN193 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -214,7 +219,6 @@ func (m *Motor) setPWM(ctx context.Context, powerPct float64, extra map[string]i
}

powerPct = math.Max(math.Abs(powerPct), m.minPowerPct)
Copy link
Member

Choose a reason for hiding this comment

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

[nit] I don't think we need this line anymore, since we moved the min logic to the top

Copy link
Member Author

Choose a reason for hiding this comment

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

no but I'm not going to touch more in this pr. It will be merged in messy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Edit - no I'm msitaken. This is now the only thing making the pwmPinPower positive. otherwise the pin will crash when you set it to negative.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Mar 19, 2024
Copy link
Contributor

@martha-johnston martha-johnston left a comment

Choose a reason for hiding this comment

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

lgtm assuming hardware tests pass

@randhid randhid merged commit c6ba80a into viamrobotics:main Mar 19, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone static-ignore-tests Build static binaries from PR and ignore tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants