conversions.hpp#
Vehicle/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). | ||
kPolarisRearCameraFrame |
extern const char* const |
The rear camera's optical frame (the vehicle's ros_cameras.py publishes reolink_rear_camera). | ||
kNcomBytes |
constexpr size_t |
72 |
Bytes of an OxTS NCOM structure-A packet. |
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. |
ncom_position_mode#
The NCOM position mode of an RtkOptions::rtk ("fixed" 6, "float" 5, else 1); -1 for an unknown name.
apply_rtk#
Applies RtkOptions to an /oxts/fix: the status (RTK fixed or float: NavSatStatus GBAS_FIX, none: FIX) and, with sigma_h_m >= 0, the east and north covariance (sigma_h_m^2; up 2.25 times that).
ncom_packet#
One OxTS NCOM structure-A navigation packet (navigation status 4, locked) from an INS epoch of the game: the specific force and rate in the OxTS frame (x forward, y right, z down), latitude, longitude (the INS datum) and height, the north-east-down velocity, true heading, pitch and roll (from the UTM attitude and the zone's meridian convergence), and one status channel: 0 (GPS minute, satellites, position mode), 3 (position sigmas), 4 (velocity sigmas) or 5 (attitude sigmas). The three checksums are set. The vehicle runtime decodes it (acres_runtime_ncom_decode).
| Argument | Description |
|---|---|
v |
The INS payload values (kInsFields); the epoch must be georeferenced. |
gps_s |
GPS time of the packet, s since 6 January 1980 (the millisecond of the minute and channel 0's minute). |
channel |
The status channel: 0, 3, 4 or 5. |
o |
The receiver state. |
out |
The packet. |
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_cmd_json#
The implement command of the game's bridge (the JSON object of the key "implement", AcresRlBridge.h) from an acres_interfaces/ImplementCmd: only the fields named in its set.
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.
RtkOptions#
The simulated RTK receiver of the Polaris (the bridge parameters rtk, sigma_h_m, ncom): what the vehicle node's pose selector reads for its RTK state and its horizontal sigma (Vehicle/Runtime/Source/sensor_pose.cpp: FQuality wants the /oxts/fix covariance and NCOM packets with navigation status 4 and the position mode of status channel 0).
DbwReports#
The Polaris' drive-by-wire reports of one "dbw_report" line.