2702 Recipes

Choosing a Strategy

Which homing strategy fits each kind of mechanism, the questions that decide it, a checklist for a reliable zero, and how to test it before competition.

Every strategy in this section works. The right one depends on the mechanism, on what can go wrong with it, and on how much complexity the team wants to maintain. In short:

  1. Start from the mechanism. Flywheels need no zero. Arms want an absolute encoder on the axle. Elevators and deployments zero against a hard stop. Turrets need a sensor or two encoders. Swerve steering uses an absolute encoder in each module.
  2. Use the simplest strategy that can't fail silently. Every sensor is one more part that can break. Add one when it removes a bigger risk, such as a belt that can slip.
  3. Plan for a lost zero. Decide how the robot notices it, and how it recovers during a match.

6.1 By mechanism

MechanismCommon choiceAlso worksNotes
Flywheel, rollersNoneThey hold a speed, not a position.
Arm or pivotAbsolute encoder on the axle, 1:1Start on a hard stopGravity feedforward needs the true angle. Keep the wrap point outside the travel (§3.4).
Wrist on an armAbsolute encoder on the wrist's axleStart on a hard stopIt reads the angle relative to the arm. Gravity acts on the arm's angle plus the wrist's (Mechanisms that need extra care).
ElevatorStart on the bottom stop, and re-zero there in the matchStall homing. A limit switch or hall effect sensor at the bottom.The drum turns many times, so a 1:1 absolute encoder doesn't fit.
Linear deployment (intake slide, hopper)Start on a hard stop, or home against itA limit switchIt often runs into its stop in normal use, which is a free chance to re-zero.
HoodStart on its hard stop, or home against itAbsolute encoderShort travel between two stops.
ClimberStart on a hard stopA limit switch at the stowed endHeavy loads make slips more likely. Re-zero when it is stowed.
Turret, less than one turnAbsolute encoder, geared to turn less than once over the travelHall effect sensorIf it has hard stops, stall homing also works.
Turret, more than one turnHall effect sensor plus rotor angle (§4.4), or two encoders (CRT)A known starting angleUsually no hard stop to home against.
Swerve steeringAbsolute encoder in each module (Anatomy)Turns forever, so it can't home against anything.

6.2 Questions that decide it

If the mechanism...Then
Rests on a hard stop at the start of every matchZero at a known starting position. Add a homing routine or a re-zero button as a backup.
Has to recover by itself if its motor controller reboots during a matchUse an absolute encoder as its feedback sensor (FusedCANcoder, SyncCANcoder, or RemoteCANcoder), or re-home during the match.
Moves less than one turn of a shaft you can reachPut an absolute encoder on that shaft.
Has a belt, chain, or hub that can slip between the motor and the mechanismAdd a sensor on the mechanism's side: an absolute encoder, or an index sensor to re-zero against.
Has no hard stops and travels more than one turnUse a hall effect sensor plus rotor angle, or two encoders.
Travels more than one turn and must know its angle the moment it powers upUse two encoders.

6.3 A checklist for a reliable zero

  1. Hard stops on every limited mechanism, with soft limits a little inside them (§2.3).
  2. A homed flag for every mechanism that can lose its zero, shown on the dashboard and in the logs.
  3. No motion on its own until homed. Only the homing routine runs before then.
  4. A way to re-zero from the driver station, behind a two-button combination.
  5. A watch for motor controller reboots. Check each motor's hasResetOccurred() every loop, and clear the homed flag when it returns true (§1.5).
  6. Absolute readings checked against the motor's position, with large disagreements logged.
  7. A pre-match checklist that includes "every mechanism on its stop" and "every homed indicator on".

6.4 Testing the zero

  1. Power-cycle test. Turn the robot off and on with each mechanism on its stop, in the middle of its travel, and near each end. Check the position it reports each time. Absolute encoders should be right everywhere. Mechanisms zeroed at a known start should only be trusted on their stop.
  2. Reboot test. With the robot disabled, restart one motor controller. Check that the code notices and clears the homed flag, or that the position recovers from the absolute encoder.
  3. Repeatability test. Home a mechanism ten times in a row. After each, move it to the same setpoint and measure where it really is. The spread is how repeatable the zero is.
  4. Margin test. For two encoders, log the miss in teeth across the whole travel (§5.6). For a hall effect sensor and rotor angle, check that the window plus backlash is well under one rotor turn of travel.
  5. Match logs. Log every zeroing event with its time and the size of the correction. A correction that is suddenly large means something slipped.

On this page