-
Notifications
You must be signed in to change notification settings - Fork 25
Stop the motors in simulation when the pivot hits the hard limits #96
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
base: master
Are you sure you want to change the base?
Conversation
Sets default values for Optional fields to Optional.empty() and updates getMechanismY to safely handle absent robotToMechanism by returning the input value.
Introduces speedometer simulation support to ShooterConfig and Shooter, including configuration methods and visualization updates. Implements a proper sysId routine for velocity-based shooter mechanisms. Updates closed-loop controller parameters and feedforward in ShooterSubsystem, and improves SmartMotorController feedforward calculation. Also fixes a typo in ElevatorConfig.
When the Pivot mechanism hits its lower or upper hard limit the sim previously only snapped the encoder position, allowing the simulated motor to keep driving past the limit. This change stops the motor by zeroing the DC motor angular velocity and clearing the duty cycle in both the lower- and upper-limit branches, and adds comments explaining the intent to prevent further movement past hard limits.
|
I was looking at this too! This is definitely a "hack". Does this work in your setup? My main concern is that it wont be able to get out of a hardstop if it exceeds it for whatever reason. |
thenetworkgrinch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not denied or accepted, just some more info needed
|
I'll test it a bit more to ensure it doesn't present problems. I've been able to successfully SysID (using my own routines) and it also obeys the limits when operating as a turret. One thing I'm noticing is that the Sim settings aren't shown when in LiveTuning. |
This pull request adds additional safety checks to the
simIteratemethod inPivot.javato ensure that the motor simulation does not exceed its configured hard limits. The main improvement is that the motor's angular velocity and duty cycle are now explicitly set to zero when a hard limit is reached, preventing further movement beyond the limit.Simulation safety improvements:
simIterate, when the mechanism reaches either the lower or upper hard limit, the motor's angular velocity is set to zero and the duty cycle is stopped, ensuring the simulated motor cannot move past its physical constraints.Note: Maybe this is a 'hack' solution, IDK. It at least stops the drifting behavior enough to make it act more like reality.