I have a certain point where I want the motor to know as its home position. How do I program it so that the motor returns back to that specific spot and then resets that to zero point? Using encoders and blocks by the way
You could rotate the unpowered motor axle to the desired physical position manually (literally by hand if safe/feasible or with a large handwheel for convenience),
OR
rotate the powered motor axle with joystick control (using your TeleOp OpMode or a simple utility OpMode for this purpose only).
Then you may run your actual competition OpMode (TeleOp or Auto), starting with a Stop_and_Reset_Encoder
Block for that motor.
This would be followed of course by your choice of:
Run_Using_Encoder
, or- the proper sequence for
Run_To_Position
==========
There’s a nice automated short-cut available, if your motor’s zero position is at one end of the mechanism’s range of motion, with a hard mechanical stop. (If it’s not, consider whether it could be.)
In that case, some teams initialize the OpMode by running the motor into the hard stop, at very low power, for a very short amount of time, under the RunMode called Run_Without_Encoder
. Then apply Stop_and_Reset_Encoder
, followed by RUE or RTP as described above.
This can give a fairly repeatable starting position, with little or no manual set-up.
Note: the motor should already be somewhat close to the hard stop, to reach it and press gently, within the short time limit.