Skip to content

Third-Party Middleware ROS2

SimOne provides ROS2 (Robot Operating System 2) middleware support. Through trans_ros (ROS2 Bridge), SimOne connects to the ROS2 ecosystem, enabling sensor data publishing and vehicle control command subscription. Developers can receive GPS, ground truth, radar, and other sensor data from the simulation environment directly within a ROS2 context, and send control commands via ROS2 Topics to drive the simulation Ego Vehicle. This is suitable for autonomous driving algorithm development and validation workflows based on ROS2.

Note

The data communication flow and interfaces for the ROS2 middleware are largely consistent with Third-Party Middleware ROS. The main differences lie in the runtime environment, build toolchain, and node API. For an overview of the overall data flow design, refer to the ROS documentation first.

1. Software Environment

Item Requirement
Programming Language C++ 14
ROS2 Distribution Eloquent
Python Version Python 3
Operating System Ubuntu

2. Build Environment

2.1 Install System Dependencies

sudo apt-get install uuid-dev libx11-dev libxrandr-dev libsdl2-dev clang libc++-dev libc++abi-dev

2.2 Configure ROS2 Environment

Add the following to ~/.bashrc (or run manually each session):

source /opt/ros/eloquent/setup.bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

2.3 Build the Project

Unlike ROS1 which uses catkin_make, the ROS2 Bridge is built directly with CMake:

cd [SimOne installation directory]/SimOneAPI/ROS2
mkdir build_release
cd build_release
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"
make -j$(nproc)

The build output is the trans_node executable located in the run/ directory.

3. Configuration File

Before running, configure config.ini. The main parameters are as follows:

Parameter Description
[BridgeIO] BridgeIO_IP SimOne server IP address
[HostVehicle] Vehicle_ID Ego Vehicle ID, default 0
[Sensor] ENABLED Enable physical sensors (camera/point cloud), 1 to enable
[Sensor] IMG_IP / IMG_PORT Camera stream receive address and port
[Sensor] PCD_IP / PCD_PORT / PCD_PORT_INFO Point cloud stream receive address and port
[ROS] GPS_Topic Topic name for GPS data publishing
[ROS] GroundTruth_Topic Topic name for obstacle ground truth publishing
[ROS] SensorDetection_Topic Topic name for sensor perception results
[ROS] Image_Topic Topic name for camera images
[ROS] PointCloud_Topic Topic name for LiDAR point cloud
[ROS] Radar_Topic Topic name for millimeter-wave radar
[ROS] LaneInfo_Topic Topic name for lane information
[MapBase] BASE_LATITUDE Map reference point latitude
[MapBase] BASE_LONGITUDE Map reference point longitude
[MapBase] BASE_ALTITUDE Map reference point altitude
[ROS] CTL_Topic Topic for subscribing to Ego Vehicle control commands (waypoint control)
[ROS] POSE_CTL_Topic Topic for subscribing to Ego Vehicle control commands (throttle/brake/steering control)
[ROS] ESP_CTL_Topic Topic for subscribing to Ego Vehicle control commands (ESP control)

4. Data Communication Interfaces

4.1 SimOne → ROS2 (Publish)

After registering callbacks via SimOneAPI, trans_node converts simulation data into ROS2 messages and publishes them to the corresponding Topics:

// Register GPS callback, publish to GPS Topic
SimOneAPI::SetGpsUpdateCB(pub_gps_cb);

// Register obstacle ground truth callback, publish to GroundTruth Topic
SimOneAPI::SetGroundTruthUpdateCB(pub_ground_truth_cb);

// Register sensor perception result callback
SimOneAPI::SetSensorDetectionsUpdateCB(&trans::pub_sensor_detections_cb);

// Register millimeter-wave radar callback
SimOneAPI::SetRadarDetectionsUpdateCB(pub_radar_detections_cb);

// Register lane information callback
SimOneAPI::SetSensorLaneInfoCB(pub_sensor_laneInfo_cb);

// When physical sensors are enabled, register camera and point cloud callbacks
SimOneAPI::SetStreamingImageUpdateCB(img_ip.c_str(), img_port, pub_image_cb);
SimOneAPI::SetStreamingPointCloudUpdateCB(pcd_ip.c_str(), pcd_port, pcd_port_info, pub_point_cloud_cb);

Supported message types (msg_gen package):

ROS2 Message Type Corresponding Simulation Data
msg_gen::gps Ego Vehicle GPS / pose
msg_gen::obstacle Obstacle ground truth
msg_gen::sensordetections Sensor perception results
msg_gen::radardetection Millimeter-wave radar targets
msg_gen::laneinfo Lane information
sensor_msgs::Image Camera image (physical sensor)
sensor_msgs::PointCloud2 LiDAR point cloud (physical sensor)

4.2 ROS2 → SimOne (Subscribe)

trans_node subscribes to control Topics and forwards ROS2 control messages to SimOneAPI to drive the simulation Ego Vehicle:

// Set waypoint control (SetPose)
pose_ctl = &SimOneAPI::SetPose;

// Set throttle/brake/steering control (SetDrive)
drive_ctl = &SimOneAPI::SetDrive;

5. Key Differences from ROS1

Item ROS (ROS1) ROS2
Distribution Melodic / Noetic Eloquent
Build Tool catkin_make Direct CMake build
Node Base Class ros::NodeHandle rclcpp::Node
Node Initialization ros::init() rclcpp::init()
Logging ROS_INFO(...) RCLCPP_INFO(this->get_logger(), ...)
Message Middleware rosidl (ROS1) rosidl + Fast-RTPS (DDS)
Project Structure catkin workspace Standalone CMake project

6. Workflow

6.1 Start the Simulation

(1) SimOne Simulation Side

  • Launch SimOne and create a new Use Case.
  • Create a new Ego Vehicle (load relevant sensors, set the control mode to Manual / API Control).
  • Run the Use Case (select the Ego Vehicle).

(2) ROS2 Side

cd [SimOne installation directory]/SimOneAPI/ROS2/run
./trans_node

6.2 Data Verification

  • Use ros2 topic echo /gps to view real-time GPS data output.
  • Use RViz2 to subscribe to the PointCloud2 Topic and observe real-time point cloud updates.
  • Use RViz2 to subscribe to the Image Topic to display real-time camera images.