Skip to content
Work in progress. This library and its docs are new and still changing, and some parts are not yet tested on a real robot. Something wrong or unclear?Tell us with a short GitHub form.

TUR-01: Turret home switch (touch or magnetic) - homes at START

high prioritySimulator or real robotabout 40 minTurret

  • Your robot needs: Turret, and Turret home switch (touch or magnetic).
  • Starter bots that fit: none (it needs parts the starter bots do not have).
  • Library version: v0.17.0 or newer.
  • The docs it tests: Setting up a turret, Setting up a turret.

Why

A turret's motor encoder counts from where it was at INIT. A home switch tells the turret where it really is: it turns slowly to the switch at START, and sets its angle again every time it passes it, so a slipping belt is fixed during the match. Two kinds of switch work (a touch sensor and a magnetic switch); we have tested the magnetic one.

Safety

  • The turret moves by itself at START (slowly, at homingPower). Fingers and wires away from it.
  • Hard stops at the wire limits. Start with homingPower = 0.2 and homingTimeout = 5.

Setup

  • The switch on the robot and in the configuration: a touch sensor (e.g. REV Touch Sensor) as REV Touch Sensor, or a magnetic switch (e.g. REV Magnetic Limit Switch, a magnet on the turret) as a Digital Device.
  • .homeSwitch("turret_home") on the turret's line in Robot.java, and homeAngle in Tunables.Turret (how to find it).
  • Simulator: the V2 example robot (a magnetic switch at 0 degrees; commands in ILK-01).

Steps

  1. Turn the turret by hand about 30 degrees away from the switch. INIT. Read the lines Turret : home switch at ... deg: found at START and Turret homing : at START it turns ... slowly to find the switch. Nothing moves in INIT.
  2. START. The turret turns slowly toward the switch (homing: looking for the switch) and stops homing when it closes. Following and "aimed" wait until then.
  3. Point the turret with the stick to a mark you know (straight forward). Read the angle on the Driver Station. Measure the real angle.
  4. Turn the turret past the switch and back 5 times. The angle on the Driver Station stays right (the switch sets it again at each pass).
  5. Unplug the switch (power off first), power on, INIT, START: after homingTimeout seconds the turret stops and the Driver Station says homing failed: switch not found. Plug it back in.
  6. Rename the switch in the configuration (or leave it out): INIT says NO home switch and the start angle is used.

Pass rule

After homing, the angle on the Driver Station is within 2 degrees of the real angle (step 3) and still within 2 degrees after 5 passes (step 4), and step 5 stops within homingTimeout + 1 s (1 of 1).

Record

Write these down while you test. The report form has them as a list to fill in.

  • switch kind (touch or magnetic) and how it is configured
  • homeAngle, homingPower, homingTimeout you used
  • the angle error after homing and after 5 passes (degrees)
  • which way it turned to home, and whether you needed homeDirection
  • what step 5 and step 6 showed

If your robot is different

If homing turns the long way round, set homeDirection (+1 = counterclockwise, -1 = clockwise) and say so. A turret that starts ON the switch has nothing to look for: say what the screen showed. A CR servo turret with an encoder on a motor port homes the same way: say which you have.

Report your result

Pass, fail, or could not run: every result helps. The form opens on GitHub with this test filled in (a free GitHub account is needed). No student names, please.

Report result

No reports for this test yet: yours would be the first. Every test's reports.

All tests · Next: ODO-01 Odometry Tuner - directions, offsets and the loop check

Something wrong on this page? Tell us with a short GitHub form.