Skip to content

ROS 2 Workspace#

The folder Vehicle/ROS/ is a ROS 2 Humble workspace. The simulators give the topics of the real Polaris. Thus the vehicle software reads and writes the same interface in the simulator and on the vehicle.

Packages#

Package Language Function
acres_sim C++ sim_bridge: the vehicle bridge, the sensor stream and the simulator control of a simulator on ROS 2 topics and services.
acres_core_sim C++ core_sim: ACRES Core behind the local sockets of the game.
acres_vehicle C++ vehicle_node: the vehicle program of the run-time library on the topics of the Polaris.
acres_interfaces Messages The messages, services and the action of ACRES (Messages).
acres_description Python The URDF, the meshes and the RViz configuration of the Polaris.
vendor/ds_dbw_msgs, vendor/oxts_msgs, vendor/rslidar_msg Messages The message packages of the vehicle, so that recorded bags decode.
Env/ The conda environment ros2 (RoboStack), the DDS fence and the colcon defaults.
Tools/ Python Checks of the topics against recordings of the vehicle.

The package purdue_ranger of Dataspeed is proprietary. The repository does not contain it.

Data Flow#

The ROS 2 graph of one Polaris session: the three local sockets of the simulator, the node sim_bridge, the topic groups with their rates, the command topics, the services and the action, and the ROS 2 nodes that use them. LOCAL SOCKETS, 127.0.0.1 ROS 2 BRIDGE TOPICS, SERVICES, ACTION ROS 2 NODES Game or ACRES Core Sensor stream -SensorStream=5601 binary frames, TCP clock, INS, LiDAR, camera, barriers Vehicle bridge -RlPort=5556 JSON lines, TCP Simulator control channel -SimControl=5600 JSON lines, TCP Node sim_bridge Sensor reader The reader thread publishes the clock and the INS data. A second thread publishes the clouds and the images. Vehicle client publishes the reports sends each command immediately Control client A step reply waits for the barriers of all channels. frames reports commands requests Clock, 120 Hz /clock rosgraph_msgs/Clock Pose and INS, 100 Hz /vehicle/odom /tf /oxts/fix /oxts/imu /oxts/velocity /sim/ground_truth/odom Odometry, Imu, NavSatFix, TwistStamped LiDAR and camera /lidar/points PointCloud2, 10 Hz /camera/image_raw Image, 10 Hz /camera/camera_info CameraInfo Drive-by-wire reports, 50 Hz /vehicle/*/report ds_dbw_msgs /vehicle/vehicle_velocity /vehicle/dbw_enabled std_msgs/Bool Commands /vehicle/*/cmd ds_dbw_msgs /vehicle/enable /vehicle/disable /sim/reset PoseStamped Simulator control /sim/episode Episode, latched /step_simulation /simulate_steps /get_simulation_state /get_... /acres/record /acres/farm_state simulation_interfaces, acres_interfaces Subscribers RViz 2 ros2 bag record perception nodes Controller dbw_demo_driver or your node Client lockstep loop, task scoring
The bridge connects the three sockets of the simulator to the topics, the services and the action. Open the diagram
game or core_sim  --(vehicle bridge, sensor stream, control channel on 127.0.0.1)-->  sim_bridge
sim_bridge        --(topics of the Polaris: /vehicle/*, /oxts/*, /lidar/points)-->  vehicle_node
vehicle_node      --(/vehicle/steering/cmd, /vehicle/ulc/cmd, only with drive:=true)-->  sim_bridge

ROS 2 Topics and ROS 2 Services and Actions give each interface.

The Vehicle Node#

vehicle_node runs one control step of the run-time library each 0.1 s. The node has no numerical code. The pose, the scan, the plan, the command chain and the checks are in the library.

Mode Parameter Behavior
SHADOW default The node has no publisher on a command topic. It writes a record of each step and a status topic.
DRIVE drive:=true The node sends SteeringCmd and UlcCmd when the driver enabled the drive-by-wire.
Gear by wire gear:=node The node also sends GearCmd.
Skill server skills:=true The node is the server of the action /acres/skill.
Bag bag:=DIR The node reads a recording in the recorded order and has no subscription. SHADOW only.

The node never enables the drive-by-wire. The safety driver enables it. A second node on the same computer stops with an error.

The node reads /oxts/ncom, /vehicle/odom, /oxts/fix, /lidar/points, the steering, gear and wheel reports of ds_dbw_msgs, /vehicle/dbw_enabled and /safety_stop (best effort). It writes /acres_vehicle/status (one JSON text for each control step) and /acres_vehicle/verdicts, and, in DRIVE only, /vehicle/steering/cmd, /vehicle/ulc/cmd and /vehicle/gear/cmd. The record of a run is records.jsonl, events.log, result.json and commands.csv. The service /acres_vehicle/stop stops the run. ROS 2 Commands gives the parameters.

SHADOW. The node waits for a pose and the first LiDAR message, plans the mission from the pose and makes one control step each 0.1 s. The node writes a finding that stops the run as "would stop" in events.log, and the run continues.

DRIVE. The node sends SteeringCmd in curvature mode inside 0.2 1/m, and UlcCmd in velocity mode not above the speed cap. It sends no command before /vehicle/dbw_enabled is true, and it sends the last command again at 50 Hz. A lost pose, lost reports or a stop finding give the safe stop: ULC 0 m/s with the last curvature, then one release message. When the drive-by-wire goes off, the node sends one release message and then nothing. Ctrl-C gives the safe stop.

A second Ctrl-C stops the commands. A third ends the process.

Gear by wire (gear:=node, DRIVE only). A gear command is REVERSE or the forward gear, never PARK or NEUTRAL. The node shifts only when the vehicle stands (0.1 m/s). It waits for the report of the new gear before it sends a speed in the new direction. A reject, a fault or no report within gear.shift_timeout_s (4 s) gives the safe stop.

Model hook. A process sends chunks on /acres_vehicle/proposal (std_msgs/Float64MultiArray). The message has the number of chunks, then the chunks in the order of preference. Each chunk has n, dt_s, station0_m, step_m, t0_s, deadline_s, n offsets and n speeds. The library checks each chunk in the next control step.

The node loads the checker plug-in libacres_runtime_lean.so from the library folder (ACRES_RUNTIME_LEAN_PLUGIN names a different file). Without it, each verdict is "no checker" and the default chain drives.

Skills (skills:=true). The action /acres/skill (acres_interfaces/action/Skill) takes a skill and its arguments. The node publishes /acres/observation, /acres/events (latched) and /acres/clock. The client sends /acres/skill/heartbeat each 0.5 s or faster: a client with no heartbeat loses each skill after client_timeout_s. In DRIVE, the command between two skills, in a wait and in a stop, is ULC 0 m/s with the last curvature. The node plans a skill in a separate thread, so the control loop keeps its period.

python3 Vehicle/ROS/acres_vehicle/scripts/skill_client.py scout field=F56

Limits of the node: it has no contact input (it finds a contact only as the finding stall). The closed loop uses the pose source odom only. The crop mask of the Scout phase is not in the node.

Safety#

The environment ros2 keeps all ROS traffic on 127.0.0.1 (ROS_LOCALHOST_ONLY=1, ROS_DOMAIN_ID=77, Cyclone DDS on the loopback interface). Do not change these values. Vehicle/ROS/Env/check_dds_isolation.sh proves the fence.

Warning

Start each ROS 2 node of this workspace in a shell with the fence (source Vehicle/ROS/Env/setup_env.sh). The command topics have the names of the real Polaris. Outside the fence, a command can go to a real vehicle on the same network.

The DDS loopback fence: the simulator, the ROS 2 bridge and the ROS 2 nodes of the workstation exchange data on 127.0.0.1 only. The settings of the fence stop all DDS traffic to the LAN and to the Tailscale network, where the real Polaris is. Workstation DDS loopback fence interface lo, address 127.0.0.1, ROS domain 77 Game or ACRES Core local TCP sockets ROS 2 bridge sim_bridge TCP ROS 2 nodes controller, RViz 2, CLI ROS 2 bag record and play DDS between the nodes: UDP unicast Ethernet, Wi-Fi LAN tailscale0 Tailscale network 1, 2 1, 2 Real Polaris vehicle computer ROS 2 Humble Cyclone DDS ROS domain 0 drive-by-wire commands move the vehicle network network 3: other ports Settings of the Fence ROS/Env/dds_safety.sh sets them in each shell of the conda environment ros2 1 ROS_LOCALHOST_ONLY=1 The middleware selects only the interface lo. 2 CYCLONEDDS_URI=cyclonedds_localhost.xml No multicast. The only discovery peer is 127.0.0.1. 3 ROS_DOMAIN_ID=77 UDP ports 26660 to 26789. Domain 0 starts at 7400. RMW_IMPLEMENTATION=rmw_cyclonedds_cpp The middleware that reads the configuration file. ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST The same limit for ROS 2 Iron and later versions. unset ROS_STATIC_PEERS ROS_DISCOVERY_SERVER No peer or discovery server from the parent shell.
The settings of the fence keep the ROS 2 traffic inside the computer. Open the diagram

Do not start sim_drive.launch.py on the vehicle computer.

Procedure: Closed Loop with ACRES Core#

  1. Build the run-time library.

    Vehicle/Runtime/build.sh --no-tests
    
  2. Make the cost tables of the map.

    PYTHONPATH=Fast:Benchmark:Vehicle python -m acres_fleet.tables --conditions dry
    
  3. Build the workspace (Install ROS 2), and open a ROS 2 shell.

  4. Start the closed loop. Give the file dry.npz of the cache.

    ros2 launch acres_vehicle sim_drive.launch.py tables:=Game/Saved/Costs/<map hash>/v<version>/dry.npz mission:=F56
    
  5. To let the node drive, start it again with drive:=true.

ROS 2 Commands gives each launch argument.

Procedure: The Game on ROS 2#

  1. Start the game with the three sockets.

    Packaged/Linux/Acres.sh -VehicleDemo -Vehicle=polaris -SimControl=5600 -SensorStream=5601 -RlPort=5556
    
  2. In a ROS 2 shell, start the bridge with RViz.

    ros2 launch acres_sim sim_bridge.launch.py vehicle:=polaris rviz:=true
    

Tests#

Command Content
colcon test in Vehicle/ROS/ The unit tests of the packages.
python Vehicle/ROS/acres_sim/test/fake_game.py A stand-in of the game for the tests of the bridge without Unreal.
python Vehicle/ROS/Tools/check_topic_parity.py The topics of the simulator against those of the Polaris.