irsim.msg.messages#

ROS-style, dependency-free messages for simulation snapshots. Used for exchanging data with ROS and other simulators, and for logging and playback.

The classes in this module are plain dataclasses. They intentionally do not depend on ROS, which keeps them usable in regular Python, learning, and batch simulation workflows while providing familiar topic names and message shapes.

Classes#

Message

Base class that provides JSON-compatible message serialization.

Header

Version-neutral metadata shared by all IR-SIM messages.

Point

ROS geometry_msgs/Point-shaped Cartesian position.

Vector3

ROS geometry_msgs/Vector3-shaped Cartesian vector.

Quaternion

ROS geometry_msgs/Quaternion-shaped orientation.

Pose

ROS geometry_msgs/Pose-shaped position and orientation.

PoseWithCovariance

ROS geometry_msgs/PoseWithCovariance-shaped pose.

Twist

ROS geometry_msgs/Twist-shaped linear and angular velocity.

TwistWithCovariance

ROS geometry_msgs/TwistWithCovariance-shaped velocity.

Odometry

ROS nav_msgs/Odometry-shaped object pose and velocity.

LaserScan

Shared sensor_msgs/LaserScan fields for a LiDAR snapshot.

ContactState

One contact of an object in the last step (collision_mode: contact).

ObjectState

Topic-shaped messages and simulator metadata for one object.

WorldState

Complete point-in-time state of an IR-SIM environment.

Module Contents#

class irsim.msg.messages.Message[source]#

Base class that provides JSON-compatible message serialization.

to_dict() → dict[str, Any][source]#

Return the complete message as JSON-compatible built-in values.

class irsim.msg.messages.Header[source]#

Bases: Message

Version-neutral metadata shared by all IR-SIM messages.

ros_type: ClassVar[str] = 'std_msgs/Header'#
seq: int = 0#
stamp: float = 0.0#
frame_id: str = 'world'#
class irsim.msg.messages.Point[source]#

Bases: Message

ROS geometry_msgs/Point-shaped Cartesian position.

ros_type: ClassVar[str] = 'geometry_msgs/Point'#
x: float = 0.0#
y: float = 0.0#
z: float = 0.0#
class irsim.msg.messages.Vector3[source]#

Bases: Message

ROS geometry_msgs/Vector3-shaped Cartesian vector.

ros_type: ClassVar[str] = 'geometry_msgs/Vector3'#
x: float = 0.0#
y: float = 0.0#
z: float = 0.0#
class irsim.msg.messages.Quaternion[source]#

Bases: Message

ROS geometry_msgs/Quaternion-shaped orientation.

ros_type: ClassVar[str] = 'geometry_msgs/Quaternion'#
x: float = 0.0#
y: float = 0.0#
z: float = 0.0#
w: float = 1.0#
classmethod from_yaw(yaw: float) → Quaternion[source]#

Create a planar quaternion from a yaw angle in radians.

to_yaw() → float[source]#

Return the planar yaw angle in radians, from a normalized copy.

Raises:

ValueError – If the quaternion is zero and defines no rotation.

class irsim.msg.messages.Pose[source]#

Bases: Message

ROS geometry_msgs/Pose-shaped position and orientation.

ros_type: ClassVar[str] = 'geometry_msgs/Pose'#
position: Point#
orientation: Quaternion#
class irsim.msg.messages.PoseWithCovariance[source]#

Bases: Message

ROS geometry_msgs/PoseWithCovariance-shaped pose.

ros_type: ClassVar[str] = 'geometry_msgs/PoseWithCovariance'#
pose: Pose#
covariance: numpy.ndarray#
class irsim.msg.messages.Twist[source]#

Bases: Message

ROS geometry_msgs/Twist-shaped linear and angular velocity.

ros_type: ClassVar[str] = 'geometry_msgs/Twist'#
linear: Vector3#
angular: Vector3#
class irsim.msg.messages.TwistWithCovariance[source]#

Bases: Message

ROS geometry_msgs/TwistWithCovariance-shaped velocity.

ros_type: ClassVar[str] = 'geometry_msgs/TwistWithCovariance'#
twist: Twist#
covariance: numpy.ndarray#
class irsim.msg.messages.Odometry[source]#

Bases: Message

ROS nav_msgs/Odometry-shaped object pose and velocity.

ros_type: ClassVar[str] = 'nav_msgs/Odometry'#
header: Header#
child_frame_id: str = ''#
pose: PoseWithCovariance#
twist: TwistWithCovariance#
classmethod from_object(obj: Any, *, stamp: float = 0.0, seq: int = 0, frame_id: str = 'world') → Odometry[source]#

Capture an object’s planar pose and body-frame velocity.

classmethod from_msg(msg: Any) → Odometry[source]#

Adopt any ROS-compatible nav_msgs/Odometry-shaped message.

Only the planar fields IR-SIM uses are read, so native ROS messages and partial stand-ins are both accepted. Header metadata is left out, since its layout is ROS-version specific and belongs to the receiver.

Parameters:

msg – An object exposing pose.pose and twist.twist.

Returns:

An independent, validated IR-SIM odometry message.

Return type:

Odometry

Raises:
  • TypeError – If msg does not expose ROS odometry pose and twist.

  • ValueError – If any planar value is not finite.

to_state_velocity(obj: Any) → tuple[numpy.ndarray, numpy.ndarray][source]#

Convert this odometry into state and velocity arrays for obj.

The inverse of from_object(): the planar pose replaces the first three state values, and the body-frame twist is mapped onto the velocity layout of the object’s kinematics. obj is only read, so a caller can validate several updates before applying any of them.

Ackermann steering is carried as a yaw rate, which is zero whenever the car is not moving. A stopped car therefore conveys no steering angle, and obj keeps the one it already had.

Parameters:

obj – The simulation object whose layout the arrays must match.

Returns:

The new (state, velocity) arrays for obj.

Return type:

tuple

Raises:

ValueError – If obj has fewer than three state values, an Ackermann object has no steering value, or the orientation defines no rotation.

class irsim.msg.messages.LaserScan[source]#

Bases: Message

Shared sensor_msgs/LaserScan fields for a LiDAR snapshot.

ros_type: ClassVar[str] = 'sensor_msgs/LaserScan'#
header: Header#
angle_min: float#
angle_max: float#
angle_increment: float#
time_increment: float#
scan_time: float#
range_min: float#
range_max: float#
ranges: numpy.ndarray#
intensities: numpy.ndarray#
classmethod from_sensor(sensor: Any, *, stamp: float = 0.0, seq: int = 0, frame_id: str | None = None, use_inf: bool = False) → LaserScan[source]#

Capture a LiDAR sensor without sharing its mutable arrays.

By default ranges are the sensor’s own finite values, range_max for a miss, so snapshots used for learning are unchanged. With use_inf=True a beam without a usable return becomes +inf when nothing came back within range_max and -inf when the return was too close to measure, as Gazebo publishes it under REP 117, so ROS consumers read the scan as they would a real driver’s.

class irsim.msg.messages.ContactState[source]#

Bases: Message

One contact of an object in the last step (collision_mode: contact).

normal points from the partner toward the object, point is the world-frame contact point, depth the overlap that was pushed apart (zero or negative for a resting contact) and force the contact force in newtons along the normal.

ros_type: ClassVar[str] = 'irsim_msgs/ContactState'#
other_id: int = -1#
other: str = ''#
point: Point#
normal: Vector3#
depth: float = 0.0#
force: float = 0.0#
classmethod from_report(report: Any) → ContactState[source]#

Serialize an object’s ContactReport.

class irsim.msg.messages.ObjectState[source]#

Bases: Message

Topic-shaped messages and simulator metadata for one object.

In collision_mode: contact the state also carries what a contact sensor reports: the net contact_force, one ContactState per contact, and how long the object has been touching (contact_time) or free (air_time).

header: Header#
id: int#
name: str#
role: str#
kinematics: str | None#
shape: str#
odom: Odometry#
scan: LaserScan | None#
goal: numpy.ndarray | None#
static: bool#
arrive: bool#
collision: bool#
collision_ids: list[int] = []#
scans: list[LaserScan] = []#
contact_force: Vector3#
contact_time: float = 0.0#
air_time: float = 0.0#
contacts: list[ContactState] = []#
classmethod from_object(obj: Any, *, stamp: float = 0.0, seq: int = 0, frame_id: str = 'world', use_inf: bool = False) → ObjectState[source]#

Capture an object as conventional odom and scan topics.

use_inf is passed to LaserScan.from_sensor().

property sensors: list[LaserScan]#

Return all LiDAR messages as a compatibility alias for scans.

class irsim.msg.messages.WorldState[source]#

Bases: Message

Complete point-in-time state of an IR-SIM environment.

header: Header#
name: str#
status: str#
step_time: float#
objects: list[ObjectState] = []#
classmethod from_env(env: Any, frame_id: str = 'world', use_inf: bool = False) → WorldState[source]#

Capture the current state and sensor data from an environment.

use_inf is passed to every LaserScan.from_sensor().

property robots: list[ObjectState]#

Return the robot messages in this snapshot.

property obstacles: list[ObjectState]#

Return the obstacle messages in this snapshot.