# Streaming Mocap Data into ROS by OSC

[ROS](https://www.ros.org/) is an open-source framework for developing robotic applications. It allows you to connect sensors, control systems, visualization tools, and more within a unified architecture.

Motion data captured with MOVIN TRACIN and MOVIN Studio can be streamed in real time or played back from recorded files within a ROS 2 environment. The data can then be retargeted to a robot model, allowing you to visualize its movement in RViz2 or integrate it directly into your robot control pipeline for further development.

### Prerequisites

Before integrating with ROS, please make sure your environment is properly set up as described below.

* **ROS 2:**
  * Humble (tested)
* **Required ROS 2 Packages:**
  * `robot_state_publisher`
  * `rvix2`
  * `xacro`
  * `tf2_ros`
* **Required pip Packages:**
  * `numpy`
  * `scipy`
  * `movin-sdk-python` (Required for BVH file loading and real-time mode)

{% stepper %}
{% step %}

### Download Motion-Player-ROS

```
cd ~/ros2_ws/src
git clone https://github.com/MOVIN3D/Motion-Player-ROS
```

* Navigate to the `src` folder of your ROS 2 workspace and clone the [Motion-Player-ROS repository](https://github.com/MOVIN3D/Motion-Player-ROS).
  {% endstep %}

{% step %}

### Install MOVIN SDK Python

```
pip install git+https://github.com/MOVIN3D/MOVIN-SDK-Python.git
```

* Before proceeding, check that all required packages from the [#prerequisites](#prerequisites "mention") section are installed.
* The `movin-sdk-python` package is necessary for BVH file loading and real-time live streaming.
  * For more information about MOVIN-SDK-Python, please refer to the [repository link](https://github.com/MOVIN3D/MOVIN-SDK-Python).
    {% endstep %}

{% step %}

### Build the Package

```
cd ~/ros2_ws
colcon build --packages-select motion_player
```

* Move to the root of your workspace and build the `motion_player` package.
  {% endstep %}

{% step %}

### Source the Workspace

```
source ~/ros2_ws/install/setup.bash
```

* After building, source the `install/setup.bash` file in your terminal session.
  * This step is required for ROS to recognize the `motion_player` package.
    {% endstep %}

{% step %}

### Run Real-Time Mode

```
ros2 launch motion_player realtime.launch.py
```

* Launch real-time mode to receive motion data from MOVIN Studio.
* In real-time mode, you can:
  * Real-time Retargeting: Retargeting motion data instantly to a robot model
  * Real-time Visualization: Visualize both the mocap skeleton and the retargeted robot motion simultaneously in RViz2

```
ros2 launch motion_player realtime.launch.py port:=11235 human_height:=1.80 skeleton_offset_x:=1.5
```

* You can customize parameters as needed:&#x20;

<table><thead><tr><th width="175.76953125">Argument</th><th width="169.12890625">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>port</code></td><td><code>11235</code></td><td>UDP port to listen for OSC mocap data</td></tr><tr><td><code>robot_type</code></td><td><code>unitree_g1</code></td><td>Target robot type (<code>unitree_g1</code> or <code>unitree_g1_with_hands</code>)</td></tr><tr><td><code>human_height</code></td><td><code>1.75</code></td><td>Human height in meters for scaling</td></tr><tr><td><code>skeleton_offset_x</code></td><td><code>1.0</code></td><td>X offset to place skeleton beside robot</td></tr><tr><td><code>urdf_file</code></td><td>(package default)</td><td>Path to custom URDF file</td></tr><tr><td><code>rviz_config</code></td><td>(package default)</td><td>Path to custom RViz config file</td></tr></tbody></table>

You may also run the node directly using the `--realtime` flag:

```
ros2 run motion_player motion_player --realtime --ros-args -p port:=11235 -p human_height:=1.8
```

{% endstep %}

{% step %}

### Start OSC Streaming in MOVIN Studio&#x20;

<figure><img src="/files/CrznIvoTXFBkoqlDsOXg" alt=""><figcaption></figcaption></figure>

* Start OSC streaming in MOVIN Studio.
* Please check that the port number configured in ROS matches the port number set in MOVIN Studio.
  {% endstep %}
  {% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.movin3d.com/movin-studio-usage-guide/live-streaming/streaming-mocap-data-into-ros-by-osc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
