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:
- 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:
TypedDictType 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.
- 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:
- 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:
TypedDictType 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.
- 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.
- 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:
- 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
symaware.extra.ros.models.entities module
- class symaware.extra.ros.models.entities.Entity(id=-1, model=<factory>)[source]
Bases:
EntityAbstract 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 anAgentmodel (
DynamicalModel, default:<factory>) – Dynamical model associated with the entity. Must be a subclass ofPybulletDynamicalModel
- model: DynamicalModel
- class symaware.extra.ros.models.entities.F1tenth(id=-1, model=<factory>)[source]
Bases:
EntitySimple entity representing a [f1tenth](https://roboracer.ai/) car.
- Parameters:
id (
int, default:-1) – Identifier of the entity, if linked to anAgentmodel (
DynamicalModel, default:<factory>) – Dynamical model associated with the entity. Must be a subclass ofPybulletDynamicalModel
symaware.extra.ros.models.environment module
- class symaware.extra.ros.models.environment.Environment(ros_client, async_loop_lock=None)[source]
Bases:
EnvironmentEnvironment based on the PyBullet physics engine.
- Parameters:
ros_client (
RosClient|None) – Client used to connect to the ROS bridge to send and receive topic messagesasync_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.
- 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.
- 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.