So my team is using a motor for our mobile goal clamp for High Stakes, but when the code ends, the motor is easily movable even by gravity. Is there a way to lock motors in place when code isn’t being run so it doesn’t mess with the transition from autonomous to controlled?
No. When Field Contol puts the robots in a match in the “disabled” state (e.g. the pause before Auton, the pause before Driver, and the pause after the match is over), the motors are put into “coast” mode as a safety feature. Given this is for safety, not just of the team, but also the volunteers, this is not able to be changed in user code.
If you want it to stay locked in place, you’ll need to create some sort of physical lock that meets your requirements.
You might want to look into the motor.setStopping() command. If you’re using block code, there should be something similar. You can choose between three “stopping” behaviors (how the robot behaved when it’s stopped)
“Coast”, which basically means that the motor will spin freely, until friction stops it, due to inertia. This is what you’d use for drivetrains, and may be what your motors are set to.
“Brake” will slow the motor down if it’s spinning but won’t hold it’s position.
Finally, “Hold”, will stop the motor if it’s spinning (similar to Brake), but will also hold it’s position where you stop it at.
Cheers!
Set your motor stopping to hold
Not that I know of. To lock a motor you need to supply it with power so it can move against any external forces. Without having code that actively locks it, the motor will be able to move.
To fix the autonomous, set the drivetrain brake mode to brake or hold, (look up how with your language) and have the auton stop a bit less than a second before the timer runs out. This will give the robot time to stop moving, and because the code is still “running” the motor should hold it’s position during the transition.
You should set the brake mode back to the default when driver control starts to prevent weird behaviors and uncontrollability for your driver.