BangBang Motor Controller not working as expected – vastly overshooting target no matter the setpoint

I am coding a BangBang control loop for the flywheel on our team’s shooter, but no matter what I set the setpoint as (I have tested values from 10 to 10,000), the flywheel always spins up to around 14,000 according to the dashboard. Is there a reason for this? Thanks!

ShootBangBang Class:


Instantiating the BangBang loop, feed forward, and shooter motor:
ShootBall Command:

Calling Shoot Ball in the robot container:

The constants for the feed forward obtained through SysId

2 Likes

It looks to me like your feed forward constants aren’t in the same units as your measurement. Try separating the feed forward from the bang bang controller and only run one at a time, until you can ensure both work independently.

2 Likes

That has been fixed, but now I still need to multiply the feed forward drastically lower (.0015*) and it is effected by battery voltage

this means that your feedforward units are wrong; you should fix the units, not fudge it by an arbitrary constant…

2 Likes

We did fix the units, and re characterized the shooter, but it did not fix the issue

Saying that you fixed the units doesn’t help us figure out what issue is remaining.

You need to log your telemetry (setpoints, measurements, outputs) and figure out where in the signal stack things are going wrong.


these are the new constants

That’s not what I asked you to share, though. We need to see your measurements, setpoints, and outputs.

Also, there is no position constant. kP is a proportional feedback constant.

How would I find that?

Do you know what each of those terms means? If not you might want to take some time reading some introductory material.

1 Like

If I were you, I would start by only setting the feed forward.

Set it to 1023 / max measured velocity in native units when you manually apply full power to your flywheel.

See Phoenix-Examples-Languages/Constants.java at master · CrossTheRoadElec/Phoenix-Examples-Languages (github.com) and Phoenix-Examples-Languages/Robot.java at master · CrossTheRoadElec/Phoenix-Examples-Languages (github.com)

and make sure to read Motor Controller Closed Loop — Phoenix documentation (ctre-phoenix.com) in its entirety.

Once your feed forward is good, then you can consider tuning P/I/D.

And when looking at the examples above, keep in mind that while the CTRE Magnetic Encoder have 4096 units per rotation, the Talon FX Integrated Sensor have only 2048 (so you may need to adapt the examples).

See Bring Up: Talon FX/SRX Sensors — Phoenix documentation (ctre-phoenix.com)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.