# RM75 Drag Trajectory Workflow

## Fixed Context

- Repo: `/home/mashiro/project/linkerhand-cpp-sdk`
- RM subproject: `/home/mashiro/project/linkerhand-cpp-sdk/RM`
- SDK root: `/home/mashiro/RM_API2/C++`
- Controller: `192.168.1.18:8080`
- Robot: RM75, 7 DOF, integrated 6D force, controller generation 3

## C++ Maintainer Map

| Purpose | Path |
| --- | --- |
| Robot abstraction | `RM/include/rm_control/interfaces/robot_arm.h` |
| RealMan SDK wrapper | `RM/include/rm_control/drivers/realman/realman_robot_arm.h`, `RM/src/drivers/realman/realman_robot_arm.cpp` |
| Drag-teach orchestration | `RM/include/rm_control/core/drag_teach_recorder.h`, `RM/src/core/drag_teach_recorder.cpp` |
| Trajectory storage and conversion | `RM/include/rm_control/modules/trajectory/trajectory_file_store.h`, `RM/src/modules/trajectory/trajectory_file_store.cpp` |
| Live record CLI | `RM/src/drag_teach_record_main.cpp` |
| Offline convert CLI | `RM/src/trajectory_convert_main.cpp` |

## Data Folders

Use this root:

```text
RM/data/trajectories/
├── csv/
├── vendor/
├── converted/
└── reports/
```

CSV is the source of truth. Vendor files are best-effort artifacts. Converted files hold generated C++ TCP waypoint tables.

## Build And Test

```bash
cd /home/mashiro/project/linkerhand-cpp-sdk
cmake -S RM -B RM/build -DCMAKE_BUILD_TYPE=Debug
cmake --build RM/build -j
ctest --test-dir RM/build --output-on-failure
```

These commands are safe: they do not move the robot.

## Record Drag Teach

Only run after explicit user confirmation and safety setup.

```bash
./RM/build/rm_drag_teach_record demo_pick_path 15 100
```

Default live behavior:

- Connects to `192.168.1.18:8080`.
- Starts six-dof force drag teach with position and orientation enabled.
- Enables singular wall by default.
- Samples current arm state every `100 ms`.
- Writes CSV to `RM/data/trajectories/csv/demo_pick_path.csv`.
- Attempts vendor save to `RM/data/trajectories/vendor/demo_pick_path_vendor.txt`.

## Convert CSV To C++

This is offline and safe.

```bash
./RM/build/rm_trajectory_convert RM/data/trajectories/csv/demo_pick_path.csv
```

Default output:

```text
RM/data/trajectories/converted/demo_pick_path_tcp_path.cpp
```

## Safety Rules

- Do not run live drag teach or replay unless the user explicitly requests it.
- First live run must be unloaded, low-speed/manual, with clear workspace and reachable E-stop.
- Keep CSV as the primary replay/conversion input.
- For TCP path reproduction, use CSV joint values as future IK references or validation data; do not assume TCP-only waypoints uniquely determine RM75 arm posture.
