# FT Sensor Calibration

## Calibrating the FT sensor

The zero of the ankle FT sensor (ATI Mini58) can be set with 

```bash
ros2 run kanagroo_constrained_dynamics_ros calibrate_ft_sensor.sh        # pick a sensor interactively
ros2 run kanagroo_constrained_dynamics_ros calibrate_ft_sensor.sh --all  # zero every FT sensor found
```

Run it **on the robot** (it talks to the hardware directly via the EtherCAT
master — it is not a ROS node).

- **Warm up first.** The strain gauges drift with temperature, so use and
  calibrate the sensor only after the robot has been powered on for ~30 minutes,
  once it is thermally settled — otherwise the zero keeps drifting as it warms up.
- **Calibrate unloaded.** Zeroing makes the sensor read **zero for whatever wrench
  is applied at that moment**. That load is baked into the new zero and subtracted
  from every later reading, so do it with **no (or very little) load** on the foot
  — foot in the air, nothing pressing on it.
- **Rarely needed.** A good zero holds; this is a once-in-a-while operation (after
  warm-up, a hardware change, or visible drift), not a routine step.

How it works: the script finds the `FTSensor` EtherCAT slaves,
and for each one switches it to PRE-OP, writes the *update-offset*
command to SDO object `0xFB01`, switches it back to OP,
then polls the status code (`0x6010`) until the board reports the
calibration finished.

```{note}
**Allow up to ~10 s per sensor.** The completion poll
(`check_calibration_status`) is currently unreliable — the FT firmware does not
report the status bits dependably — so the script may print "complete"
immediately or loop on a stale value rather than tracking the real progress.
The offset update itself still takes time on the board, so just give it ~10 s
before trusting the new zero (or power-cycling), regardless of what the script
prints.
```
