> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# ROS2 Communcation

In order to enable seemless integration of GRID into your current robotics stack, we support ROS2 support with Isaac. This enables users to both publish data from the simulation as well as receive commands into the simulation to execute.

## Publishing Simulation Data

In order to publish simulation data, we provide support for a list of message types the details of which are provided below:

| Message Type                | Configurable Parameters                                                                                                                                                        | Description                                                                                                                             |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| **RGBImage**                | `msg_type: "sensor_msgs/Image"`, <br /> `target: "name_of_rgb_camera"`, <br /> `msg_name: "name_of_topic"`                                                                     | RGB image frames                                                                                                                        |
| **DepthImage**              | `msg_type: "sensor_msgs/Image"`, <br /> `target: "name_of_depth_camera"`, <br /> `msg_name: "name_of_topic"`                                                                   | Depth image frames                                                                                                                      |
| **BasePose**                | `msg_type: "geometry_msgs/Pose"`, <br /> `target: "name_of_robot"`, <br /> `body_name: "name_of_body"`, <br /> `msg_name: "name_of_topic"`                                     | Pose of the robot’s base link                                                                                                           |
| **EndEffectorPose**         | `msg_type: "geometry_msgs/Pose"`, <br /> `target: "name_of_robot"`, <br /> `link_name: "name_of_link"`, <br /> `msg_name: "name_of_topic"`                                     | Pose of the end-effector link (e.g. `panda_hand`)                                                                                       |
| **JointState**              | `msg_type: "sensor_msgs/JointState"`, <br /> `target: "name_of_robot"`, <br /> `msg_name: "name_of_topic"`                                                                     | Current joint states of the robot                                                                                                       |
| **ContactForces**           | `msg_type: "geometry_msgs/Wrench"`, <br /> `target: "name_of_contact_sensor"`, <br /> `msg_name: "name_of_topic"`                                                              | Contact force/torque readings                                                                                                           |
| **LidarScan**               | `msg_type: "sensor_msgs/PointCloud2"`, <br /> `target: "name_of_lidar"`, <br /> `msg_name: "name_of_topic"`                                                                    | Point-cloud data from the LiDAR                                                                                                         |
| **ImuData**                 | `msg_type: "sensor_msgs/msg/Imu"`, <br /> `target: "name_of_imu"`, <br /> `msg_name: "name_of_topic"`                                                                          | IMU (accelerometer/gyroscope) measurements                                                                                              |
| **GPSOdometry**             | `msg_type: "nav_msgs/msg/Odometry"`<br />`target: "name_of_robot"`<br />`body_name: "root"`<br />`msg_name: "name_of_topic"`<br />`info: {}`                                   | Publishes full 6-DoF odometry (position, orientation, linear & angular velocity) of the robot’s root link, as from “GPS”.               |
| **Quaternion\_Z\_Relative** | `msg_type: "geometry_msgs/msg/Quaternion"`<br />`target: "name_of_height_sensor"`<br />`msg_name: "name_of_topic"`<br />`body_name: "root"`<br />`info: { art_body: "robot" }` | Computes and publishes the Z-axis–only relative orientation quaternion between the robot and the ground plane under a raycaster sensor. |
| **CameraInfo**              | `msg_type: "sensor_msgs/msg/CameraInfo"`<br />`target: "name_of_rgb_camera"`<br />`msg_name: "name_of_topic"`<br />`info: {}`                                                  | Publishes camera calibration data (image size, distortion coefficients D, intrinsic K, rectification R, projection P) flattened.        |

An example of how to publish simulation data using `env.yaml` is as follows:

```yaml theme={null}
comms:
  - name_of_camera_msg:
      type: RGBImage
      config:
        target: camera_rgb_0 # name of the camera sensor
        msg_name: /robot/camera_rgb_0 # name of the topic to publish data
```

## Subscribing to Commands

We also allow users to send commads to the robot in the simulation session. Here is the list of commands we support.

| ROS2 Msg Type            | Description                                             |
| ------------------------ | ------------------------------------------------------- |
| `sensor_msgs/JointState` | Command message to set robot joint positions            |
| `geometry_msgs/Twist`    | Command message to control base linear/angular velocity |
| `geometry_msgs/Pose`     | Command message to set end-effector delta pose          |

For each command, users need to specify the name of the topic to which they are publishing the specific message and the target command name from the `commands` entity specified in the `mdp.yaml`.
An example of how to use commands in `env.yaml` is as follows:

```yaml theme={null}
comms:
  - name_of_the_command_msg:
      type: Commands
      config:
        target: base_velocity # this is the name of the command 
        msg_name: /base_vel_cmd # this is the name of the topic to which the user is publishing
```

<Note>
  We are constantly updating our offering of supported message types, please let us know on our [Discord Community](https://discord.gg/yPtfUNDe5M) or reach out to us on our [email](mailto:info@generalrobotics.company).
</Note>
