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#
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.
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.
Do not start sim_drive.launch.py on the vehicle computer.
Procedure: Closed Loop with ACRES Core#
-
Build the run-time library.
-
Make the cost tables of the map.
-
Build the workspace (Install ROS 2), and open a ROS 2 shell.
-
Start the closed loop. Give the file
dry.npzof the cache. -
To let the node drive, start it again with
drive:=true.
ROS 2 Commands gives each launch argument.
Procedure: The Game on ROS 2#
-
Start the game with the three sockets.
-
In a ROS 2 shell, start the bridge with RViz.
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. |