tbp.monty.frameworks.actions#

tbp.monty.frameworks.actions.action_samplers#

class ActionSampler(actions: list[type[Action]] | None = None)[source]#

Bases: object

An Action factory that samples from a set of available action types.

__init__(actions: list[type[Action]] | None = None)[source]#
sample(agent_id: AgentID, rng: numpy.random.RandomState) → Action[source]#

Sample a random action from the available action types.

Returns:

A random action from the available action types.

Return type:

Action

class ConstantSampler(absolute_degrees: float = 0.0, actions: list[type[Action]] | None = None, direction: tuple[float, float, float] | None = None, location: tuple[float, float, float] | None = None, rotation_degrees: float = 5.0, rotation_quat: tuple[float, float, float, float] | None = None, translation_distance: float = 0.004) → None[source]#

Bases: ActionSampler

An Action factory using constant, prespecified action parameters.

This Action factory samples actions with constant parameters. The values of action parameters used are set at initialization time and remain the same for all actions created by this factory. For example, if you specify rotation_degrees=5.0, all actions created by this factory that take a rotation_degrees parameter will have it set to 5.0.

When sampling an Action, only applicable parameters are used. For example, when sampling a MoveForward action, only the ConstantSampler’s translation_distance parameter is used to determine the action’s distance parameter.

__init__(absolute_degrees: float = 0.0, actions: list[type[Action]] | None = None, direction: tuple[float, float, float] | None = None, location: tuple[float, float, float] | None = None, rotation_degrees: float = 5.0, rotation_quat: tuple[float, float, float, float] | None = None, translation_distance: float = 0.004) → None[source]#
sample_look_down(agent_id: AgentID, rng: numpy.random.RandomState) → LookDown[source]#
Return type:

LookDown

sample_look_up(agent_id: AgentID, rng: numpy.random.RandomState) → LookUp[source]#
Return type:

LookUp

sample_move_forward(agent_id: AgentID, rng: numpy.random.RandomState) → MoveForward[source]#
Return type:

MoveForward

sample_move_tangentially(agent_id: AgentID, rng: numpy.random.RandomState) → MoveTangentially[source]#
Return type:

MoveTangentially

sample_orient_horizontal(agent_id: AgentID, rng: numpy.random.RandomState) → OrientHorizontal[source]#
Return type:

OrientHorizontal

sample_orient_vertical(agent_id: AgentID, rng: numpy.random.RandomState) → OrientVertical[source]#
Return type:

OrientVertical

sample_set_agent_pitch(agent_id: AgentID, rng: numpy.random.RandomState) → SetAgentPitch[source]#
Return type:

SetAgentPitch

sample_set_agent_pose(agent_id: AgentID, rng: numpy.random.RandomState) → SetAgentPose[source]#
Return type:

SetAgentPose

sample_set_sensor_pitch(agent_id: AgentID, rng: numpy.random.RandomState) → SetSensorPitch[source]#
Return type:

SetSensorPitch

sample_set_sensor_pose(agent_id: AgentID, rng: numpy.random.RandomState) → SetSensorPose[source]#
Return type:

SetSensorPose

sample_set_sensor_rotation(agent_id: AgentID, rng: numpy.random.RandomState) → SetSensorRotation[source]#
Return type:

SetSensorRotation

sample_set_yaw(agent_id: AgentID, rng: numpy.random.RandomState) → SetYaw[source]#
Return type:

SetYaw

sample_turn_left(agent_id: AgentID, rng: numpy.random.RandomState) → TurnLeft[source]#
Return type:

TurnLeft

sample_turn_right(agent_id: AgentID, rng: numpy.random.RandomState) → TurnRight[source]#
Return type:

TurnRight

class UniformlyDistributedSampler(actions: list[type[Action]] | None = None, max_absolute_degrees: float = 360.0, min_absolute_degrees: float = 0.0, max_rotation_degrees: float = 20.0, min_rotation_degrees: float = 0.0, max_translation: float = 0.05, min_translation: float = 0.05)[source]#

Bases: ActionSampler

An Action factory using uniformly distributed action creation parameters.

This Action factory samples actions with parameters that are uniformly distributed within a given range. The range of values for each parameter is set at initialization time and remains the same for all actions created by this factory.

When sampling an Action, only applicable parameters are used. For example, when sampling a MoveForward action, only the UniformlyDistributedSampler’s translation_high and translation_low parameters are used to determine the action’s distance parameter.

__init__(actions: list[type[Action]] | None = None, max_absolute_degrees: float = 360.0, min_absolute_degrees: float = 0.0, max_rotation_degrees: float = 20.0, min_rotation_degrees: float = 0.0, max_translation: float = 0.05, min_translation: float = 0.05)[source]#
sample_look_down(agent_id: AgentID, rng: numpy.random.RandomState) → LookDown[source]#
Return type:

LookDown

sample_look_up(agent_id: AgentID, rng: numpy.random.RandomState) → LookUp[source]#
Return type:

LookUp

sample_move_forward(agent_id: AgentID, rng: numpy.random.RandomState) → MoveForward[source]#
Return type:

MoveForward

sample_move_tangentially(agent_id: AgentID, rng: numpy.random.RandomState) → MoveTangentially[source]#
Return type:

MoveTangentially

sample_orient_horizontal(agent_id: AgentID, rng: numpy.random.RandomState) → OrientHorizontal[source]#
Return type:

OrientHorizontal

sample_orient_vertical(agent_id: AgentID, rng: numpy.random.RandomState) → OrientVertical[source]#
Return type:

OrientVertical

sample_set_agent_pitch(agent_id: AgentID, rng: numpy.random.RandomState) → SetAgentPitch[source]#
Return type:

SetAgentPitch

sample_set_agent_pose(agent_id: AgentID, rng: numpy.random.RandomState) → SetAgentPose[source]#
Return type:

SetAgentPose

sample_set_sensor_pitch(agent_id: AgentID, rng: numpy.random.RandomState) → SetSensorPitch[source]#
Return type:

SetSensorPitch

sample_set_sensor_pose(agent_id: AgentID, rng: numpy.random.RandomState) → SetSensorPose[source]#
Return type:

SetSensorPose

sample_set_sensor_rotation(agent_id: AgentID, rng: numpy.random.RandomState) → SetSensorRotation[source]#
Return type:

SetSensorRotation

sample_set_yaw(agent_id: AgentID, rng: numpy.random.RandomState) → SetYaw[source]#
Return type:

SetYaw

sample_turn_left(agent_id: AgentID, rng: numpy.random.RandomState) → TurnLeft[source]#
Return type:

TurnLeft

sample_turn_right(agent_id: AgentID, rng: numpy.random.RandomState) → TurnRight[source]#
Return type:

TurnRight

tbp.monty.frameworks.actions.actions#

class Action(agent_id: AgentID) → None[source]#

Bases: Protocol

An action that can be taken by an agent.

Actions are generated by the MotorSystem and are executed by an Actuator.

classmethod action_name() → str[source]#

Generate the action name based on the class.

Used in static configuration, e.g., FakeAction.action_name().

Return type:

str

Returns:

The action name in snake_case.

__init__(agent_id: AgentID) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

agent_id: AgentID#

The ID of the agent that will take this action.

property name: str#

Used for checking action name on an Action instance.

class LookDown(agent_id: AgentID, rotation_degrees: float, constraint_degrees: float = 90.0) → None[source]#

Bases: Action

Rotate the agent downwards by a specified number of degrees.

static sample(agent_id: AgentID, sampler: LookDownActionSampler, rng: numpy.random.RandomState) → LookDown[source]#
Return type:

LookDown

__init__(agent_id: AgentID, rotation_degrees: float, constraint_degrees: float = 90.0) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: LookDownActuator) → None[source]#
Return type:

None

class LookDownActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_look_down(agent_id: AgentID, rng: numpy.random.RandomState) → LookDown[source]#
Return type:

LookDown

class LookDownActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_look_down(action: LookDown) → None[source]#
Return type:

None

class LookUp(agent_id: AgentID, rotation_degrees: float, constraint_degrees: float = 90.0) → None[source]#

Bases: Action

Rotate the agent upwards by a specified number of degrees.

static sample(agent_id: AgentID, sampler: LookUpActionSampler, rng: numpy.random.RandomState) → LookUp[source]#
Return type:

LookUp

__init__(agent_id: AgentID, rotation_degrees: float, constraint_degrees: float = 90.0) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: LookUpActuator) → None[source]#
Return type:

None

class LookUpActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_look_up(agent_id: AgentID, rng: numpy.random.RandomState) → LookUp[source]#
Return type:

LookUp

class LookUpActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_look_up(action: LookUp) → None[source]#
Return type:

None

class MoveForward(agent_id: AgentID, distance: float) → None[source]#

Bases: Action

Move the agent forward by a specified distance.

static sample(agent_id: AgentID, sampler: MoveForwardActionSampler, rng: numpy.random.RandomState) → MoveForward[source]#
Return type:

MoveForward

__init__(agent_id: AgentID, distance: float) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: MoveForwardActuator) → None[source]#
Return type:

None

class MoveForwardActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_move_forward(agent_id: AgentID, rng: numpy.random.RandomState) → MoveForward[source]#
Return type:

MoveForward

class MoveForwardActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_move_forward(action: MoveForward) → None[source]#
Return type:

None

class MoveTangentially(agent_id: AgentID, distance: float, direction: tuple[float, float, float]) → None[source]#

Bases: Action

Move the agent tangentially.

Moves the agent tangentially to the current orientation by a specified distance along a specified direction.

static sample(agent_id: AgentID, sampler: MoveTangentiallyActionSampler, rng: numpy.random.RandomState) → MoveTangentially[source]#
Return type:

MoveTangentially

__init__(agent_id: AgentID, distance: float, direction: tuple[float, float, float]) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: MoveTangentiallyActuator) → None[source]#
Return type:

None

class MoveTangentiallyActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_move_tangentially(agent_id: AgentID, rng: numpy.random.RandomState) → MoveTangentially[source]#
Return type:

MoveTangentially

class MoveTangentiallyActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_move_tangentially(action: MoveTangentially) → None[source]#
Return type:

None

class OrientHorizontal(agent_id: AgentID, rotation_degrees: float, left_distance: float, forward_distance: float) → None[source]#

Bases: Action

Move the agent in the horizontal plane.

Moves the agent in the horizontal plane, compensating for the horizontal motion with a rotation in the horizontal plane.

static sample(agent_id: AgentID, sampler: OrientHorizontalActionSampler, rng: numpy.random.RandomState) → OrientHorizontal[source]#
Return type:

OrientHorizontal

__init__(agent_id: AgentID, rotation_degrees: float, left_distance: float, forward_distance: float) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: OrientHorizontalActuator) → None[source]#
Return type:

None

class OrientHorizontalActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_orient_horizontal(agent_id: AgentID, rng: numpy.random.RandomState) → OrientHorizontal[source]#
Return type:

OrientHorizontal

class OrientHorizontalActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_orient_horizontal(action: OrientHorizontal) → None[source]#
Return type:

None

class OrientVertical(agent_id: AgentID, rotation_degrees: float, down_distance: float, forward_distance: float) → None[source]#

Bases: Action

Move the agent in the vertical plane.

Moves the agent in the vertical plane, compensating for the vertical motion with a rotation in the vertical plane.

static sample(agent_id: AgentID, sampler: OrientVerticalActionSampler, rng: numpy.random.RandomState) → OrientVertical[source]#
Return type:

OrientVertical

__init__(agent_id: AgentID, rotation_degrees: float, down_distance: float, forward_distance: float) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: OrientVerticalActuator) → None[source]#
Return type:

None

class OrientVerticalActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_orient_vertical(agent_id: AgentID, rng: numpy.random.RandomState) → OrientVertical[source]#
Return type:

OrientVertical

class OrientVerticalActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_orient_vertical(action: OrientVertical) → None[source]#
Return type:

None

class SetAgentPitch(agent_id: AgentID, pitch_degrees: float) → None[source]#

Bases: Action

Set the agent pitch rotation in degrees.

Note that unless otherwise changed, the sensors maintain identity orientation with regard to the agent. So this will also adjust the pitch of the agent’s sensors with regard to the environment.

static sample(agent_id: AgentID, sampler: SetAgentPitchActionSampler, rng: numpy.random.RandomState) → SetAgentPitch[source]#
Return type:

SetAgentPitch

__init__(agent_id: AgentID, pitch_degrees: float) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: SetAgentPitchActuator) → None[source]#
Return type:

None

class SetAgentPitchActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_set_agent_pitch(agent_id: AgentID, rng: numpy.random.RandomState) → SetAgentPitch[source]#
Return type:

SetAgentPitch

class SetAgentPitchActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_set_agent_pitch(action: SetAgentPitch) → None[source]#
Return type:

None

class SetAgentPose(agent_id: AgentID, location: tuple[float, float, float], rotation_quat: tuple[float, float, float, float]) → None[source]#

Bases: Action

Set the agent pose.

Set the agent pose to absolute location coordinates and orientation in the environment.

static sample(agent_id: AgentID, sampler: SetAgentPoseActionSampler, rng: numpy.random.RandomState) → SetAgentPose[source]#
Return type:

SetAgentPose

__init__(agent_id: AgentID, location: tuple[float, float, float], rotation_quat: tuple[float, float, float, float]) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: SetAgentPoseActuator) → None[source]#
Return type:

None

class SetAgentPoseActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_set_agent_pose(agent_id: AgentID, rng: numpy.random.RandomState) → SetAgentPose[source]#
Return type:

SetAgentPose

class SetAgentPoseActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_set_agent_pose(action: SetAgentPose) → None[source]#
Return type:

None

class SetSensorPitch(agent_id: AgentID, pitch_degrees: float) → None[source]#

Bases: Action

Set the sensor pitch rotation.

Note that this does not update the pitch of the agent. Imagine the body associated with the eye remaining in place while the eye moves.

static sample(agent_id: AgentID, sampler: SetSensorPitchActionSampler, rng: numpy.random.RandomState) → SetSensorPitch[source]#
Return type:

SetSensorPitch

__init__(agent_id: AgentID, pitch_degrees: float) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: SetSensorPitchActuator) → None[source]#
Return type:

None

class SetSensorPitchActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_set_sensor_pitch(agent_id: AgentID, rng: numpy.random.RandomState) → SetSensorPitch[source]#
Return type:

SetSensorPitch

class SetSensorPitchActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_set_sensor_pitch(action: SetSensorPitch) → None[source]#
Return type:

None

class SetSensorPose(agent_id: AgentID, location: tuple[float, float, float], rotation_quat: tuple[float, float, float, float]) → None[source]#

Bases: Action

Set the sensor pose.

Set the sensor pose to absolute location coordinates and orientation in the environment.

static sample(agent_id: AgentID, sampler: SetSensorPoseActionSampler, rng: numpy.random.RandomState) → SetSensorPose[source]#
Return type:

SetSensorPose

__init__(agent_id: AgentID, location: tuple[float, float, float], rotation_quat: tuple[float, float, float, float]) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: SetSensorPoseActuator) → None[source]#
Return type:

None

class SetSensorPoseActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_set_sensor_pose(agent_id: AgentID, rng: numpy.random.RandomState) → SetSensorPose[source]#
Return type:

SetSensorPose

class SetSensorPoseActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_set_sensor_pose(action: SetSensorPose) → None[source]#
Return type:

None

class SetSensorRotation(agent_id: AgentID, rotation_quat: tuple[float, float, float, float]) → None[source]#

Bases: Action

Set the sensor rotation relative to the agent.

static sample(agent_id: AgentID, sampler: SetSensorRotationActionSampler, rng: numpy.random.RandomState) → SetSensorRotation[source]#
Return type:

SetSensorRotation

__init__(agent_id: AgentID, rotation_quat: tuple[float, float, float, float]) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: SetSensorRotationActuator) → None[source]#
Return type:

None

class SetSensorRotationActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_set_sensor_rotation(agent_id: AgentID, rng: numpy.random.RandomState) → SetSensorRotation[source]#
Return type:

SetSensorRotation

class SetSensorRotationActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_set_sensor_rotation(action: SetSensorRotation) → None[source]#
Return type:

None

class SetYaw(agent_id: AgentID, rotation_degrees: float) → None[source]#

Bases: Action

Set the agent body yaw rotation.

static sample(agent_id: AgentID, sampler: SetYawActionSampler, rng: numpy.random.RandomState) → SetYaw[source]#
Return type:

SetYaw

__init__(agent_id: AgentID, rotation_degrees: float) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: SetYawActuator) → None[source]#
Return type:

None

class SetYawActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_set_yaw(agent_id: AgentID, rng: numpy.random.RandomState) → SetYaw[source]#
Return type:

SetYaw

class SetYawActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_set_yaw(action: SetYaw) → None[source]#
Return type:

None

class TurnLeft(agent_id: AgentID, rotation_degrees: float) → None[source]#

Bases: Action

Rotate the agent to the left.

static sample(agent_id: AgentID, sampler: TurnLeftActionSampler, rng: numpy.random.RandomState) → TurnLeft[source]#
Return type:

TurnLeft

__init__(agent_id: AgentID, rotation_degrees: float) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: TurnLeftActuator) → None[source]#
Return type:

None

class TurnLeftActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_turn_left(agent_id: AgentID, rng: numpy.random.RandomState) → TurnLeft[source]#
Return type:

TurnLeft

class TurnLeftActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_turn_left(action: TurnLeft) → None[source]#
Return type:

None

class TurnRight(agent_id: AgentID, rotation_degrees: float) → None[source]#

Bases: Action

Rotate the agent to the right.

static sample(agent_id: AgentID, sampler: TurnRightActionSampler, rng: numpy.random.RandomState) → TurnRight[source]#
Return type:

TurnRight

__init__(agent_id: AgentID, rotation_degrees: float) → None[source]#

Initialize the action with the agent ID.

Parameters:

agent_id (AgentID (str)) – The ID of the agent that will take this action.

act(actuator: TurnRightActuator) → None[source]#
Return type:

None

class TurnRightActionSampler(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
sample_turn_right(agent_id: AgentID, rng: numpy.random.RandomState) → TurnRight[source]#
Return type:

TurnRight

class TurnRightActuator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
actuate_turn_right(action: TurnRight) → None[source]#
Return type:

None