Example with LeRobot
Add touch to ACT on LeFlexiTac's LeRobot fork, train it with and without touch on an SO-100/101 arm or from public data, then check that touch made the difference.
LeFlexiTac brings FlexiTac to LeRobot on SO-100/101 arms. Its lightest policy, ACT (Action Chunking with Transformers), is the shortest path to a first tactile policy: train it twice on the same demonstrations, once with touch and once without, and compare. The commands come from LeFlexiTac's docs, steps 08–10 of its reproduction guide, which also has them for Diffusion Policy, Pi0.5 and SmolVLA. If the two ever differ, follow LeFlexiTac's.
Why touch helps: Imitation learning with touch. How it enters ACT: Separate tactile encoder.
- Set up the arm, the sensor and a task
- Record demonstrations
- Train with and without touch
- Run both and compare
- Look at the dataset
- Train both policies, or download them
- Compare their predictions
Add touch to ACT
With a robot or without, the same three flags add touch to ACT in LeFlexiTac's fork of LeRobot:
--policy.use_tactile=true
--policy.tactile_features='["observation.tactile.primary"]'
--policy.n_tactile_tokens=4| Flag | What it does |
|---|---|
use_tactile | Adds the tactile branch: a small CNN that turns each tactile map into tokens, extra inputs that ACT's transformer reads alongside the image's. With false, the same command trains the vision-only twin, which ignores the tactile key. |
tactile_features | Names the tactile key in the dataset. Without it, the policy looks for observation.tactile, but LeFlexiTac's record command and its public dataset store the map as observation.tactile.primary. |
n_tactile_tokens | How many tokens each map becomes (1 by default). LeFlexiTac found 4 works best for ACT and SmolVLA: too few lose detail, too many add noise. |
How often it reads touch. ACT sees only the current frame, and by default runs all 100 actions it predicts before it looks again: at 30 fps, once every 3.3 seconds. A smaller --policy.n_action_steps lets it react to contact sooner, but runs the network more often and isn't sure to raise the success rate, so test it on your task. LeFlexiTac's Diffusion Policy runs 8 of its 16 actions at 10 fps, so it looks every 0.8 s.
With a robot
Set up the arm, the sensor and a task
Set up the arm, LeFlexiTac's tactile gripper (its Moving Jaw and Wrist Roll), one sensor and LeFlexiTac's LeRobot fork, as in Data collection.
Then pick a task where touch settles something the camera can't. LeFlexiTac's three are inserting a tube into a rack, a peg into a hole, and taking a pen out of a bag. Keep the camera's view of the goal clear: LeFlexiTac found that the camera must see the hole.
Record demonstrations
LeFlexiTac records 100 demonstrations for a task with
lerobot-record, at 30 frames per second. Two of its lines make the recording tactile:The tactile lines --robot.type=so_tactile_follower --robot.tactile_sensors='{primary: {"port": "/dev/ttyUSB0", "baud_rate": 2000000}}'Full record command Camera, arms, sensor and dataset
Record lerobot-record \ --robot.type=so_tactile_follower \ --robot.port=/dev/ttyACM0 \ --robot.id=follower_arm \ --robot.cameras='{top: {"type": "opencv", "index_or_path": 0, "width":640, "height":480, "target_width":224, "target_height":224, "fps":30}}' \ --robot.tactile_sensors='{primary: {"port": "/dev/ttyUSB0", "baud_rate": 2000000}}' \ --teleop.type=so100_leader \ --teleop.port=/dev/ttyACM1 \ --teleop.id=leader_arm \ --dataset.repo_id=${HF_USER}/tactile_pen_bag \ --dataset.num_episodes=100 \ --dataset.episode_time_s=50 \ --dataset.reset_time_s=5 \ --dataset.single_task="Grab the pen from the bag and place it in the basket next to it" \ --dataset.fps=30Before the first episode, it waits for the sensor's baseline calibration: keep the pad untouched until it finishes. It saves the sensor's settings and baseline with the dataset. Each frame of the dataset holds:
Key Shape What it holds observation.images.top224 × 224 × 3 The camera image, stored as video observation.tactile.primary12 × 32 The tactile map: PyFlexiTac's normalized, from 0 to 1 and scaled to each frame's peak (why)observation.state6 The follower's joint positions: 5 joints and the gripper action6 The target joint positions, from the leader arm Show the live tactile map to the operator: 3D-ViTac, another FlexiTac project, found it improved its demonstrations. Vary what touch has to resolve, such as where the object is and how it sits in the gripper, and look at the first episodes before you record the rest (Good data).
Train with and without touch
Train twice on the same dataset: once with the three touch flags, once with
--policy.use_tactile=false. Only those flags and the names differ. With no--steps, each run trains for 100,000 steps on a CUDA GPU.Full training commands With touch and vision only
Train with touch lerobot-train \ --dataset.repo_id=${HF_USER}/tactile_pen_bag \ --policy.type=act \ --policy.use_tactile=true \ --policy.tactile_features='["observation.tactile.primary"]' \ --policy.n_tactile_tokens=4 \ --policy.repo_id=${HF_USER}/act_tactile_pen_bag \ --output_dir=outputs/train/act_tactile_pen_bag \ --batch_size=32 \ --num_workers=8 \ --policy.device=cuda:0 \ --wandb.enable=trueTrain without touch lerobot-train \ --dataset.repo_id=${HF_USER}/tactile_pen_bag \ --policy.type=act \ --policy.use_tactile=false \ --policy.repo_id=${HF_USER}/act_baseline_pen_bag \ --output_dir=outputs/train/act_baseline_pen_bag \ --batch_size=32 \ --num_workers=8 \ --policy.device=cuda:0 \ --wandb.enable=trueRun both and compare
Give both policies the same trials, from the same object placements and starting poses, so touch is the only difference (Compare fairly has the full list). Roll each checkpoint out on the arm with the full record command from step 2, with these lines changed or added:
Run with touch --dataset.repo_id=${HF_USER}/eval_act_tactile_pen_bag \ --dataset.num_episodes=50 \ --dataset.episode_time_s=30 \ --dataset.reset_time_s=10 \ --policy.path=YOUR_CHECKPOINT_PATHLeFlexiTac's step 10 has the whole command. For the vision-only policy, also leave out
--robot.tactile_sensors, and give it its own--dataset.repo_idand checkpoint. Run ACT at the 30 fps you recorded at. Then evaluate the two side by side.
Without a robot
LeFlexiTac's public data and checkpoints let you try the learning half on a GPU:
No success rates have been published for the two checkpoints. Older LeFlexiTac datasets such as tactile_tube_100 were recorded before LeFlexiTac moved to PyFlexiTac: their maps are 16 × 32, from 0 to 100, so don't mix them with new recordings.
Look at the dataset
Load frames in Python. LeRobot downloads the dataset the first time:
Read a tactile map from lerobot.datasets.lerobot_dataset import LeRobotDataset ds = LeRobotDataset("Tna001/tactile_test_tube_pyflexitac") touch = ds[0]["observation.tactile.primary"] # a 12 × 32 tensor, from 0 to 1LeRobot's
lerobot-dataset-vizplays an episode's camera video, joint positions and actions, but not its touch.Train both policies, or download them
Run the two training commands with
--dataset.repo_id=Tna001/tactile_test_tube_pyflexitacand names of your own. Or skip training: the two checkpoints above were trained that way, for 100,000 steps with a batch size of 32.Compare their predictions
Run both policies on the same recorded frames and compare their actions with the demonstrated ones, then give the tactile one the wrong touch and see how much its actions change. There's no ready-made script for this yet. The published checkpoints trained on all 64 episodes, so to test on episodes a policy hasn't seen, train your own on part of them (
--dataset.episodestakes the list). And predictions on recorded frames show what a policy uses, not whether it succeeds: only trials on a robot show that.
Evaluate your tactile policy
A tactile policy can beat a vision-only one for reasons other than touch. Two questions settle that: did touch make the difference, and does the policy really use it? The examples come from LeFlexiTac, 3D-ViTac and Touch in the Wild, the open projects in Imitation learning with touch.
Most checks need trials on a robot. If you trained without one, you can still give the tactile policy the wrong touch on recorded frames. LeFlexiTac's public checkpoints trained on all 64 episodes, so train your own on part of them to keep some unseen.
Compare fairly
A higher success rate shows touch helped only if touch is the one thing that changed:
- The same demonstrations. Train both policies on one dataset, and switch touch off in the vision-only one with
--policy.use_tactile=false(touch flags). This vision-only twin is the one ablation LeFlexiTac's code supports directly. - The same training. Keep the steps, batch size, learning rate and seed. Most of LeFlexiTac's published pairs of ACT, Diffusion Policy and SmolVLA policies differ only in their tactile settings.
- The same evaluation. Give both the same number of trials, from the same object placements and starting poses.
- More than a success rate. Note the step at which each one fails and how, and what it does after contact: whether it tries again, adjusts, or presses on. 3D-ViTac and Touch in the Wild report success for every step of a task, not just the whole.
Does your policy use touch?
These checks show how the tactile policy uses touch:
- Give it the wrong touch. On recorded episodes it didn't train on, replace the tactile input during contact with zeros (no contact), or with frames from other moments, and compare the actions it predicts with those for the real input. If they barely change, the policy may rely only weakly on touch, at least in the states you tested. Touch may matter in just a few moments of contact, and zeros or swapped frames are inputs the policy never saw in training, so read the result with care. Policy Consensus runs this check through whole episodes: it adds noise to one sense at a time and tracks how much the actions change. On its marker task, vision leads the approach, and touch's influence rises sharply at contact while vision stays important (paper, Sec. IV-C).
- Watch the moments touch should decide. A missed grasp should lead to another try: in 3D-ViTac's egg task, when a person puts the egg back mid-grasp, the policy with touch grasps again ("Confirm the grasp" in Why touch matters). A tilted object should be straightened first: in Touch in the Wild's test-tube task, when a person knocks the tube tilted again, its policy reorients it before inserting.
- Check that touch reaches the policy. LeFlexiTac's Pi0.5 and SmolVLA keep running without their tactile tokens if the robot has no tactile sensor configured, so pass
--robot.tactile_sensorswhenever you run a tactile policy.
Best practices
Before you conclude that touch doesn't help, check these. They are specific to touch, beyond the usual imitation-learning advice:
| Topic | What to do |
|---|---|
| Signal quality | Before each session, press the pad and check that every row and column responds. Redo the baseline after mounting (Good data), and, as the readings drift with temperature, once the sensor has been on for more than 30 minutes, as LeFlexiTac advises: restarting lerobot-record, which also runs the rollouts, takes a new one. |
| Normalization | LeFlexiTac's maps keep the contact's shape but not its force (why). Its ACT also standardizes them with one mean and spread per column, computed over the whole dataset, so a column rarely pressed in training can give extreme values when it is. Look for std near 0 under observation.tactile.primary in the dataset's meta/stats.json. |
| Timing | Record at 30 fps. ACT runs at that rate; LeFlexiTac trains Diffusion Policy, Pi0.5 and SmolVLA with --policy.frame_stride=3 and runs them at 10 fps. Run a policy at the rate it was trained at, and process touch exactly as in the dataset: the same firmware, frame shape and normalization. |
| Feedback rate | How often a policy reads touch depends on how many actions it runs per prediction. By default, ACT reads it once per 100 actions: every 3.3 s at 30 fps (above). |
Where to go next
Language-conditioned policies: Pi0.5 and SmolVLA take the same use_tactile switch as ACT.
Refine a visuo-tactile policy in simulation, as VT-Refine does.
Learn reusable visuo-tactile features from large datasets, as Touch in the Wild does.