Components for Entities and Agents
Components can be categorized as Data Components, Data + Behavior Components, and Behavior Components. Components should have specific purposes such as holding intrinsic data, or defining entity dynamics. All behavior components transform entity data for use by either another component or system and may or may not update entity data at the same time.
Entity-component modeled components are behavior or data-behavior components which should be explicitly called by the entity update functions. Entity-component-system modeled components are behavior or data-behavior components which are used by a system which should be explicitly updated at any point of the simulation loop.
Base Components
- class rtd.entity.components.BaseControllerComponent[source]
Bases:
object
Base class for the controller of the agent. Stores a reference to the info and state components, as well as a container for the trajectories, and the number of inputs.
- abstract getControlInputs(**options)[source]
Abstract method which needs to be implemented to get the inputs
- abstract setTrajectory(trajectory: Trajectory)[source]
Abstract method which needs to be implemented to set the trajectory of the controller
- class rtd.entity.components.BaseDynamicsComponent[source]
Bases:
object
Base class for controlling the dynamics of an agent. Stores a reference to the info, state, and controller components.
- class rtd.entity.components.BaseInfoComponent[source]
Bases:
object
Base class for storing immutable parameters tied to an entity. Should be extended along with the Options mixin to add specific properties.
- class rtd.entity.components.BaseStateComponent[source]
Bases:
object
Base class for storing dynamic parameters tied to an entity. Should be extended along with the Options mixin to implement specific behaviors. Stores a refernce to the info component, as well as the number of states, and the internal state and time storage.
- abstract commit_state_data(time: float, state: list[float] | NDArray[Shape[N], float64])[source]
Abstract method which needs to be implemented to append a state and time to the state and time lists
- Parameters:
time (float) – time after last time to commit from
state (Vec) – state to commit at corresponding time
- abstract get_state(time: float) dict [source]
Abstract method which needs to be implemented. Returns a dict with the state at a certain time
- class rtd.entity.components.GenericEntityState(entity_info: BaseInfoComponent, **options)[source]
Bases:
BaseStateComponent
,Options
A generic entity state that stores an (n_states, :) matrix to keep track of the state at each point in time. New states can be appended by calling commit_state_data with the time interval and new state. A state at any moment can be retrieved by calling get_state. It will default to the most recent state.
- commit_state_data(time: float, state: list[float] | NDArray[Shape[N], float64])[source]
Takes in a state and appends it to the current state at time time + the most recent time
- Parameters:
time (float) – time after last time to commit from
state (Vec) – state to commit at corresponding time
- static defaultoptions() dict [source]
No default options, though common options for the state components are ‘n_states’ and ‘initial_state’.
- get_state(time: float = None) dict [source]
Gets the state at a specific time (defaults to most recent time), interpolating the values if needed
Box Obstacle Components
- class rtd.entity.box_obstacle.BoxObstacleInfo(**options)[source]
Bases:
BaseInfoComponent
,Options
An info component that stores the agent’s dimensions and color
- class rtd.entity.box_obstacle.BoxObstacleVisual(box_info: BoxObstacleInfo, box_state: GenericEntityState, **options)[source]
Bases:
PyvistaVisualObject
,Options
A visual component used to generate the plot data of the box obstacle
- create_plot_data(time: float = None) pyvista.Actor [source]
Generates the initial plot data
- Parameters:
time (float) – time of initial plot data
- Returns:
plot_data – pyvista actor object to plot
- Return type:
Actor
- class rtd.entity.box_obstacle.BoxObstacleCollision(box_info: BoxObstacleInfo, box_state: GenericEntityState)[source]
Bases:
DynamicCollisionObject
- getCollisionObject(time: float = None) CollisionObject [source]
Generates a CollisionObject for a given time time
- Parameters:
time (float) – time to get collision object at
- class rtd.entity.box_obstacle.BoxObstacleZonotope(box_info: BoxObstacleInfo, box_state: GenericEntityState)[source]
Bases:
object
- get_zonotope(state=None, time: float = None) zonopy.zonotope [source]
Returns zonotope of the BoxObstacle. Takes in either a state or time.
Armour Components
- class armour.agent.ArmourAgentCollision(arm_info: ArmourAgentInfo, arm_state: ArmourAgentState)[source]
Bases:
DynamicCollisionObject
- getCollisionObject(q: NDArray[Shape[N, M], float64] = None, time: float = None) CollisionObject [source]
Generates a CollisionObject for a given time time or configuration q (only one or none must be provided)
- class armour.agent.ArmourAgentInfo(robot: urchin.URDF, **options)[source]
Bases:
BaseInfoComponent
,Options
- class armour.agent.ArmourAgentState(arm_info: ArmourAgentInfo, **options)[source]
Bases:
BaseStateComponent
,Options
- commit_state_data(T_state: NDArray[Shape[N], float64], Z_state: NDArray[Shape[N, M], float64])[source]
method: commit_move_data(T_state,Z_state)
After moving the agent, commit the new state and input trajectories, and associated time vectors, to the agent’s state, time, input, and input_time properties.
- Parameters:
T_state (NpFvec) – times to commit states to
Z_state (NpFmat) – corresponding states for the times
- static defaultoptions() dict [source]
Abstract static method which needs to be implemented to provide the default options for any given class. Should return a dict
- get_state(time: NDArray[Shape[N], float64] = None) ArmRobotState [source]
Returns the state of the ArmourAgent at a specific time.
- joint_limit_check(t_check_step: float) bool [source]
Checks if joint limits did not exceed at any time.
- property position
- random_init(pos_range: NDArray[Shape[2, N], float64] = None, vel_range: NDArray[Shape[2, N], float64] = None, random_position: bool = True, random_velocity: bool = False, save_to_options: bool = False)[source]
Abstract method which needs to be implemented to initialize the starting state randomly
- property velocity
- class armour.agent.ArmourAgentVisual(arm_info: ArmourAgentInfo, arm_state: ArmourAgentState, **options)[source]
Bases:
PyvistaVisualObject
,Options
A visual component used to generate the plot data of the Armour agent
- create_plot_data(time: float = None) list[pyvista.Actor] [source]
Generate the trimesh meshes at the given time and converts them into actors
- class armour.agent.ArmourController(arm_info: ArmourAgentInfo, arm_state: ArmourAgentState, **options)[source]
Bases:
BaseControllerComponent
,Options
- static defaultoptions() dict [source]
Abstract static method which needs to be implemented to provide the default options for any given class. Should return a dict
- getControlInputs(**options)[source]
Abstract method which needs to be implemented to get the inputs
- setTrajectory(trajectory: Trajectory)[source]
Abstract method which needs to be implemented to set the trajectory of the controller
- class armour.agent.ArmourIdealAgentDynamics(arm_info: ArmourAgentInfo, arm_state: ArmourAgentState, arm_controller: ArmourController, **options)[source]
Bases:
BaseDynamicsComponent
,Options
Dynamics component that assumes the agent perfectly executes the reference trajectory
- controller_input_check(t_check_step) bool [source]
Check that the controller wasn’t giving bad torques
- class armour.agent.ArmourMexController(arm_info: ArmourAgentInfo, arm_state: ArmourAgentState, **options)[source]
Bases:
ArmourController