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 reset()[source]

Abstract method which needs to be implemented to reset each property

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.

abstract move(t_move: float)[source]

Abstract method which needs to be implemented to control the dynamics

abstract reset()[source]

Abstract method which needs to be implemented to reset each property

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.

abstract reset()[source]

Abstract method which needs to be implemented to reset each property.

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

Parameters:

time (float) – time to get the state at

Returns:

state – dict with keys time and state, with the time the state was requested at, and its corresponding state

Return type:

dict

abstract random_init()[source]

Abstract method which needs to be implemented to initialize the starting state randomly

abstract reset()[source]

Abstract method which needs to be implemented to reset the state and 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

Parameters:

time (float) – time to get the state at

Returns:

state – dict with keys time and state, with the time the state was requested at, and its corresponding state

Return type:

dict

random_init(state_range: tuple[float, float], save_to_options: bool = False)[source]

Randomly initializes the first state from the given range start_range[0]:start_range[1] (inclusive). Will save the initial state to options so that it will revert to this state when reset is called.

Parameters:
  • state_range (tuple[float, float]) – min and max values the state can take

  • save_to_options (bool) – whether to save the random state as initial_state

reset(**options)[source]

Resets the generic state component.

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

static defaultoptions() dict[source]

Default options for the BoxObstacleInfo

reset(**options)[source]

Resets this component

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

static defaultoptions() dict[source]

Default options for the BoxObstacleVisual

plot(time: float = None)[source]

Updates the plotdata of the BoxObstalce

Parameters:

time (float) – time of plot data

reset(**options)[source]

Resets this component

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

reset()[source]

Resets this component

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.

Parameters:
  • state (list[float]) – state to generate zonotope with

  • time (float) – time to generate zonotope with

reset()[source]

Resets this component

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)

reset()[source]

Not needed as collision objects are created on demand

class armour.agent.ArmourAgentInfo(robot: urchin.URDF, **options)[source]

Bases: BaseInfoComponent, Options

static defaultoptions() dict[source]

Sets the default options for the ArmourAgentInfo, such as M_min_eigenvalue, gravity, transmission_inertia, and buffer_dist.

reset(**options)[source]

Resets the ArmourAgentInfo

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.

Parameters:

t_check_step (float) – step size to check with

Returns:

check – whether limit was exceeded or not

Return type:

bool

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

reset(**options)[source]

Abstract method which needs to be implemented to reset the state and time

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

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

plot(time: float = None)[source]

Replaces the mesh of the actors to update their pose

reset(**options)[source]
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

reset(**options)[source]

Abstract method which needs to be implemented to reset each property

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

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

move(t_move: float)[source]

Abstract method which needs to be implemented to control the dynamics

reset(**options)[source]

Abstract method which needs to be implemented to reset each property

class armour.agent.ArmourMexController(arm_info: ArmourAgentInfo, arm_state: ArmourAgentState, **options)[source]

Bases: ArmourController