conversions.hpp#
ROS/acres_sim/include/acres_sim/conversions.hpp Generated
Conversions between the game's stream frames and JSON lines and the vehicles' ROS 2 messages: the INS epoch to odometry, TF, ground truth, NavSatFix, Imu (the OxTS AV200 mounting on the Polaris) and TwistStamped; the DBW reports; the DBW and tractor commands to the RL bridge's JSON; a UTM reset pose to the game's reset command; the camera intrinsics and the Maxxum's mounts from the stream's hello. Everything here is a pure function (unit tested, test/test_conversions.cpp) and matches the Python bridge (acres_ros/sim_bridge.py) value for value.
| Name | Type | Unit | Default | Description |
|---|---|---|---|---|
Quat |
using |
std::array<double, 4> |
Quaternion x, y, z, w. | |
Vec3 |
using |
std::array<double, 3> |
Vector x, y, z. | |
kOxtsMount |
extern const Quat |
OxTS AV200 mounting on the Ranger (ds_localization v2b roll 0, pitch 180, yaw -90 deg; navroute.md A7): the IMU frame is the body frame rotated by Rz(-90) Ry(180), i.e. x = left, y = forward, z = down. | ||
kPolarisCameraFrame |
extern const char* const |
Frame of the Polaris' Reolink camera (purdue_ranger URDF and polaris_ranger.urdf.xacro). |
to_stamp#
A ROS time from seconds, as the Python bridge's stamp(): floor seconds, nanoseconds rounded half to even and capped at 999999999.
| Argument | Description |
|---|---|
seconds |
Time, s. |
Returns: The stamp.
quat_mul#
Hamilton product a * b.
| Argument | Description |
|---|---|
a |
Left quaternion. |
b |
Right quaternion. |
Returns: The product.
quat_from_rpy#
ROS fixed-axis roll, pitch, yaw (R = Rz Ry Rx) in radians to a quaternion.
| Argument | Description |
|---|---|
roll |
rad. |
pitch |
rad. |
yaw |
rad. |
Returns: The quaternion.
oxts_vector#
Body FLU vector to the OxTS IMU axes (x = left, y = forward, z = down).
| Argument | Description |
|---|---|
v |
Body vector. |
Returns: The vector in IMU axes.
ins_to_messages#
Converts one INS epoch (kInsFields float64) to its messages.
| Argument | Description |
|---|---|
v |
The payload values. |
stamp_s |
Frame stamp, simulation time s. |
frames |
The bridge's frames. |
out |
The messages. |
dbw_reports_from_json#
Converts a "dbw_report" line (AcresRlBridge.h) to the ds_dbw_msgs reports, with the constant fields the vehicle sends (ready, the steering limits 1000 deg/s and 487 deg, actuator temperatures -40 degC, NaN for the brake's torque, acceleration and input fields, infinite throttle and brake limits).
| Argument | Description |
|---|---|
line |
The parsed line. |
stamp |
Its world time (the report's vehicle time plus the stream's clock offset). |
Returns: The reports.
steering_cmd_json#
{"steering_cmd": {...}} of a SteeringCmd (ds_dbw_msgs field names and units, one to one).
throttle_cmd_json#
{"throttle_cmd": {...}} of a ThrottleCmd.
brake_cmd_json#
{"brake_cmd": {...}} of a BrakeCmd.
gear_cmd_json#
{"gear_cmd": {"cmd": n}} of a GearCmd, or nothing for gear 0 (none), which the Python bridge did not forward.
ulc_cmd_json#
{"ulc_cmd": {...}} of a UlcCmd.
reset_command#
The game's reset command for a UTM pose of base_footprint (frame utm, grid heading), converted with the INS's own georeference (the latest epoch's UTM and grid ENU of the same point), so the vehicle lands where odometry will report it.
| Argument | Description |
|---|---|
pose |
The pose (position x easting, y northing; orientation yaw counter-clockwise from UTM east). |
ins |
The latest INS epoch (kInsFields values). |
body_origin_flu_m |
The hello's body_origin_flu_m (the body origin seen from base_footprint), x and y. |
summary |
Optional log text. |
Returns: {"reset": {"x", "y", "yaw_deg", "speed", "restore_field"}} (world metres X east, Y south; Unreal yaw).
camera_info_from_hello#
Camera intrinsics from the stream's hello, when the camera is enabled and has them.
| Argument | Description |
|---|---|
hello |
The hello JSON. |
frame_id |
The camera's optical frame. |
Returns: The CameraInfo (plumb_bob, P from K), or nothing.
mount_transforms#
The Maxxum's static transforms from the hello's mounts: base_footprint to lidar, camera (and camera to camera_optical), imu_link and gnss_link.
| Argument | Description |
|---|---|
hello |
The hello JSON. |
frames |
The bridge's frames. |
lidar_frame |
LiDAR frame with the prefix. |
camera_optical_frame |
Camera optical frame with the prefix. |
Returns: The transforms (stamps zero, as the Python bridge sent them).
implement_state_json#
The Maxxum's implement state string: json.dumps of the observation's implement keys, in their fixed order.
| Argument | Description |
|---|---|
observation |
The RL observation line. |
Returns: The JSON text.
to_can_msg#
A can_msgs/Frame as ros2_socketcan's receiver publishes it (id without the flag bits, is_extended from the EFF flag, frame_id "can").
| Argument | Description |
|---|---|
frame |
The raw frame. |
stamp |
Header stamp. |
Returns: The message.
from_can_msg#
The raw frame of a can_msgs/Frame, as ros2_socketcan's sender writes it.
| Argument | Description |
|---|---|
msg |
The message. |
Returns: The frame (EFF, RTR and ERR flags from is_extended, is_rtr, is_error; dlc capped at 8).
VehicleFrames#
Frame names of one vehicle bridge.
VehicleFrames::base#
base_footprint with the prefix.
InsMessages#
The messages of one INS epoch. The georeferenced ones (odom, tf, truth, fix) are filled only when georef is true.
DbwReports#
The Polaris' drive-by-wire reports of one "dbw_report" line.