symaware.extra.ros.models package

Submodules

symaware.extra.ros.models.dynamical_model module

class symaware.extra.ros.models.dynamical_model.AckermannDriveModel(ID, topic=None, message_type=None, compression=None, latch=False, throttle_rate=0, queue_size=0, reconnect_on_close=True)[source]

Bases: RosClientDynamicalModel[TMessage]

Dynamical model using the AckermannDrive type messages as a control input.

static control_input_to_array(steering_angle=0.0, steering_angle_velocity=0.0, speed=0.0, acceleration=0.0, jerk=0.0)[source]
Return type:

ndarray

property subinputs_dict: AckermannDriveModelSubinputs

The input of a system is the composition of subinputs.

Example

A car input [vx, vy, vz, s] is composed by the velocity and the steering angle.

>>> from symaware.base import DynamicalModel
>>> class CarModel(DynamicalModel):
...     @property
...     def subinputs_dict(self):
...         return {
...             "velocity": self._control_input[:3],
...             "steering_angle": self._control_input[3]
...         }
...

Important

The order of the subinputs in the list must be the same as the order of the subinputs in the input vector

class symaware.extra.ros.models.dynamical_model.AckermannDriveModelSubinputs[source]

Bases: TypedDict

Type definition for Ackermann drive model sub-inputs.

Parameters:
  • steering_angle – The angle of the steering, in radians.

  • steering_angle_velocity – The velocity of the steering angle, in radians per second.

  • speed – The speed of the vehicle, in meters per second.

  • acceleration – The acceleration of the vehicle, in meters per second squared.

  • jerk – The jerk of the vehicle, in meters per second cubed.

acceleration: float
jerk: float
speed: float
steering_angle: float
steering_angle_velocity: float
class symaware.extra.ros.models.dynamical_model.OdometryModel(ID, topic=None, message_type=None, compression=None, latch=False, throttle_rate=0, queue_size=0, reconnect_on_close=True)[source]

Bases: RosClientDynamicalModel[TMessage]

Dynamical model using the odometry type messages as a control input.

static control_input_to_array(position_x=0.0, position_y=0.0, position_z=0.0, orientation_x=0.0, orientation_y=0.0, orientation_z=0.0, orientation_w=0.0, speed_linear_x=0.0, speed_linear_y=0.0, speed_linear_z=0.0, speed_angular_x=0.0, speed_angular_y=0.0, speed_angular_z=0.0)[source]
Return type:

ndarray

property subinputs_dict: OdometryModelSubinputs

The input of a system is the composition of subinputs.

Example

A car input [vx, vy, vz, s] is composed by the velocity and the steering angle.

>>> from symaware.base import DynamicalModel
>>> class CarModel(DynamicalModel):
...     @property
...     def subinputs_dict(self):
...         return {
...             "velocity": self._control_input[:3],
...             "steering_angle": self._control_input[3]
...         }
...

Important

The order of the subinputs in the list must be the same as the order of the subinputs in the input vector

class symaware.extra.ros.models.dynamical_model.OdometryModelSubinputs[source]

Bases: TypedDict

Type definition for odometry model sub-inputs.

Parameters:
  • position – Position vector (x, y, z) in meters.

  • orientation – Orientation quaternion (qx, qy, qz, qw).

  • speed_linear – Linear velocity vector (vx, vy, vz) in meters per second.

  • speed_angular – Angular velocity vector (wx, wy, wz) in radians per second.

orientation: ndarray
position: ndarray
speed_angular: ndarray
speed_linear: ndarray
class symaware.extra.ros.models.dynamical_model.RosClientDynamicalModel(ID, control_input, topic='', message_type=None, compression=None, latch=False, throttle_rate=0, queue_size=0, reconnect_on_close=True)[source]

Bases: DynamicalModel, Generic[TMessage]

Base dynamical model that interfaces with ROS client.

_publisher: object | None
_ros: RosClient | None
initialise(ros_client=None)[source]

Initialise ROS client and create publisher.

property is_publisher: bool

Return True if ROS client is initialized.

property message_type: type[TMessage] | None

ROS message type.

property topic: str

ROS topic name.

class symaware.extra.ros.models.dynamical_model.TwistDriveModel(ID, topic=None, message_type=None, compression=None, latch=False, throttle_rate=0, queue_size=0, reconnect_on_close=True)[source]

Bases: RosClientDynamicalModel[TMessage]

Dynamical model using the twist type messages as a control input.

static control_input_to_array(linear_x=0.0, linear_y=0.0, linear_z=0.0, angular_x=0.0, angular_y=0.0, angular_z=0.0)[source]
Return type:

ndarray

property subinputs_dict: TwistDriveModelSubinputs

The input of a system is the composition of subinputs.

Example

A car input [vx, vy, vz, s] is composed by the velocity and the steering angle.

>>> from symaware.base import DynamicalModel
>>> class CarModel(DynamicalModel):
...     @property
...     def subinputs_dict(self):
...         return {
...             "velocity": self._control_input[:3],
...             "steering_angle": self._control_input[3]
...         }
...

Important

The order of the subinputs in the list must be the same as the order of the subinputs in the input vector

class symaware.extra.ros.models.dynamical_model.TwistDriveModelSubinputs[source]

Bases: TypedDict

Type definition for twist drive model sub-inputs.

Parameters:
  • linear – Linear velocity vector (vx, vy, vz) in meters per second.

  • angular – Angular velocity vector (wx, wy, wz) in radians per second.

angular: ndarray
linear: ndarray

symaware.extra.ros.models.entities module

class symaware.extra.ros.models.entities.Entity(id=-1, model=<factory>)[source]

Bases: Entity

Abstract class for the entities using meant to communicate with ROS. The implementation can be empty, since they only need to transmit the control input to the real robot.

Parameters:
  • id (int, default: -1) – Identifier of the entity, if linked to an Agent

  • model (DynamicalModel, default: <factory>) – Dynamical model associated with the entity. Must be a subclass of PybulletDynamicalModel

initialise(ros_client=None)[source]
model: DynamicalModel
class symaware.extra.ros.models.entities.F1tenth(id=-1, model=<factory>)[source]

Bases: Entity

Simple entity representing a [f1tenth](https://roboracer.ai/) car.

Parameters:
  • id (int, default: -1) – Identifier of the entity, if linked to an Agent

  • model (DynamicalModel, default: <factory>) – Dynamical model associated with the entity. Must be a subclass of PybulletDynamicalModel

symaware.extra.ros.models.environment module

class symaware.extra.ros.models.environment.Environment(ros_client, async_loop_lock=None)[source]

Bases: Environment

Environment based on the PyBullet physics engine.

Parameters:
  • ros_client (RosClient | None) – Client used to connect to the ROS bridge to send and receive topic messages

  • async_loop_lock (AsyncLoopLock | None, default: None) – Async loop lock to use for the environment

__LOGGER = <Logger symaware.extra.ros.models.ROS.Environment (WARNING)>
_add_entity(entity)[source]

Add an entity to the environment, initialising it. The actual implementation should be done in the derived class, based on the simulated environment API. The entity’s initialise_entity() function should be called within this function with the appropriate arguments.

Parameters:

entity (Entity) – entity to initialise

get_entity_state(entity)[source]

Get the state of an entity in the environment. The actual implementation should be done in the derived class, based on the simulated environment API.

Parameters:

entity (Entity) – entity to get the state of

Returns:

ndarray – State of the entity within the environment

initialise()[source]

Initialise the simulation, allocating the required resources. Should be called when the simulation has been set up and is ready to be run. Some environment implementations may call it automatically when the environment is created. It is their responsibility to ensure that the method is idempotent.

property ros: RosClient

ROS client instance.

step()[source]

It can be called repeatedly step the environment forward in time, updating the state of all the entities.

stop()[source]

Terminate the simulation, releasing the resources. Should be called when the simulation has been running manually and needs to be stopped. Some environment implementations may call it automatically when the environment is destroyed. It is their responsibility to ensure that the method is idempotent.

Warning

Depending on the simulator implementation, calling this method may invalidate all the entities previously added to the environment. In that case, entities and the environment should be recreated from scratch.

Module contents