Entities and Agents

Entities define objects that exist in the simulated world with a variety of properties. This simulator works on mixed Entity-Component (EC) and Entity-Component-System (ECS) architecture. Each entity aggregates a few core components with special cases aggregating any additional necessary components. Entity data purely exists in the components. Components can be categorized as Data Components, Data + Behavior Components, and Behavior Components.

Base Entity Class (WorldEntity)

All entities derive from the WorldEntity, which prescribes the requirement for some info component and state component. WorldEntity also provides a handful of utility functions to assist with the composition of each entity. Additional components can be added as desired, and this is demonstrated in the following concrete entities.

class rtd.sim.world.WorldEntity[source]

Bases: Options

A base class for entities. Allows for the management of components. Abstract methods such as defaultoptions must still be implemented. Requires options to be set up in a specific way to function (more details in the function comments below)

construct_components(component_name: str, *component_args)[source]

Takes in a component_name and constructs that component as self.component_name of type options[“components”], using component_args and options[“component_options”] defined for that component_name

Example:

options["components"]["state"] = GenericEntityState
options["component_options]["state"] = {"n_states": 5}
construct_components("state", BoxObstacleInfo())
# results in:
# self.state = GenericEntityState(BoxObstacleInfo(), n_states=5)
Parameters:
  • component_name (str) – name of component (e.g., ‘info’)

  • *component_args – additional arguments for constructing that component

static get_componentOptions(component) dict | None[source]

Takes in a component class or instance and returns either the defaultoptions of that class or the actual options of that instance if the component inherits from options. Otherwise returns None

Parameters:

component (Any) – class or instance of component to pull options from

Returns:

component_options – options of that component

Return type:

dict | None

static get_componentOverrideOptions(components: dict) dict[source]

Takes in a dict of components classes or instances. It saves the component type under options[“components”] and saves their options, if provided, under options[“component_options”]

# components can be either a class or an instance
components = {"info": EmptyInfoState, "state": GenericEntityState(n_states=5)}
get_componentOverrideOptions(components)
# results in:
# options["components"] = {"info": EmptyInfoState, "state": GenericEntityState}
# options["component_options"] = {"state": {"n_states": 5}}
Parameters:

components (dict) – names and class/instance of the corresponding component

reset_components()[source]

Resets every component

Example:

options["components"] = {"info": BoxObstacleInfo, "state": GenericEntityState}
options["component_options"] = {"state": {"n_states": 5}}
reset_components()
# equivalent to calling:
# self.info.reset()
# self.state.reset(n_states=5)

Box Obstacle Entity

class rtd.entity.box_obstacle.BoxObstacle(info: ~rtd.entity.box_obstacle.BoxObstacleInfo.BoxObstacleInfo = <class 'rtd.entity.box_obstacle.BoxObstacleInfo.BoxObstacleInfo'>, state: ~rtd.entity.components.GenericEntityState.GenericEntityState = <class 'rtd.entity.components.GenericEntityState.GenericEntityState'>, visual: ~rtd.entity.box_obstacle.BoxObstacleVisual.BoxObstacleVisual = <class 'rtd.entity.box_obstacle.BoxObstacleVisual.BoxObstacleVisual'>, collision: ~rtd.entity.box_obstacle.BoxObstacleCollision.BoxObstacleCollision = <class 'rtd.entity.box_obstacle.BoxObstacleCollision.BoxObstacleCollision'>, representation: ~rtd.entity.box_obstacle.BoxObstacleZonotope.BoxObstacleZonotope = <class 'rtd.entity.box_obstacle.BoxObstacleZonotope.BoxObstacleZonotope'>, **options)[source]

Bases: WorldEntity

A 3D box obstacle with an info, state, visual, and collision component

static defaultoptions() dict[source]
Returns:

options – default options of BoxObstacle

Return type:

dict

static make_box(center: tuple[float] = (0, 0, 0), dims: tuple[float] = (0, 0, 0), color: tuple[float] = (1, 0, 1)) BoxObstacle[source]

Creates a box obstacle with the specified parameters

Parameters:
  • center (tuple[float]) – x, y, z coordinate of the box center

  • dims (tuple[float]) – x, y, z dimensions of the box obstacle

  • color (tuple[float]) – r, g, b color of box

Returns:

box – BoxObtacle instance with specified parameters

Return type:

BoxObstacle

reset(**options)[source]

Armour Agent

class armour.ArmourAgent(info: ~armour.agent.ArmourAgentInfo.ArmourAgentInfo, state: ~armour.agent.ArmourAgentState.ArmourAgentState = <class 'armour.agent.ArmourAgentState.ArmourAgentState'>, visual: ~armour.agent.ArmourAgentVisual.ArmourAgentVisual = <class 'armour.agent.ArmourAgentVisual.ArmourAgentVisual'>, collision: ~armour.agent.ArmourAgentCollision.ArmourAgentCollision = <class 'armour.agent.ArmourAgentCollision.ArmourAgentCollision'>, controller: ~armour.agent.ArmourController.ArmourController = <class 'armour.agent.ArmourController.ArmourController'>, dynamics: ~armour.agent.ArmourIdealAgentDynamics.ArmourIdealAgentDynamics = <class 'armour.agent.ArmourIdealAgentDynamics.ArmourIdealAgentDynamics'>, **options)[source]

Bases: WorldEntity

The Agent with the robust controller for ARMOUR

static defaultoptions() dict[source]
Returns:

options – default options of armour agent

Return type:

dict

reset(**options)[source]
update(t_move) dict[source]

Updates the armour agent

Parameters:

t_move (float) – time to update for

Returns:

  • info (dict) – with keys:

  • <success> (bool) – whether the agent moved successfully

  • <t_check_step> (float) – time steps checked for

  • <checks> (dict[str, bool]) – with keys <joint_limits>, <control_inputs>, <ultimate_bound>