tbp.monty.frameworks.actions#

tbp.monty.frameworks.actions.action_samplers#

class ActionSampler(rng: Generator | None = None, actions: List[Type[Action]] | None = None)[source]#

Bases: ABC

Declares the interface for an abstract Action factory.

Used to generate Actions by sampling from a set of available action types.

sample(agent_id: str) Action[source]#

Sample a random action from the available action types.

Returns:

A random action from the available action types.

abstract sample_look_down(agent_id: str) LookDown[source]#
abstract sample_look_up(agent_id: str) LookUp[source]#
abstract sample_move_forward(agent_id: str) MoveForward[source]#
abstract sample_move_tangentially(agent_id: str) MoveTangentially[source]#
abstract sample_orient_horizontal(agent_id: str) OrientHorizontal[source]#
abstract sample_orient_vertical(agent_id: str) OrientVertical[source]#
abstract sample_set_agent_pitch(agent_id: str) SetAgentPitch[source]#
abstract sample_set_agent_pose(agent_id: str) SetAgentPose[source]#
abstract sample_set_sensor_pitch(agent_id: str) SetSensorPitch[source]#
abstract sample_set_sensor_pose(agent_id: str) SetSensorPose[source]#
abstract sample_set_sensor_rotation(agent_id: str) SetSensorRotation[source]#
abstract sample_set_yaw(agent_id: str) SetYaw[source]#
abstract sample_turn_left(agent_id: str) TurnLeft[source]#
abstract sample_turn_right(agent_id: str) TurnRight[source]#
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, rng: Generator | None = None, rotation_degrees: float = 5.0, rotation_quat: Tuple[float, float, float, float] | None = None, translation_distance: float = 0.004, **kwargs)[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 ConstantCreator’s translation_distance parameter is used to determine the action’s distance parameter.

sample_look_down(agent_id: str) LookDown[source]#
sample_look_up(agent_id: str) LookUp[source]#
sample_move_forward(agent_id: str) MoveForward[source]#
sample_move_tangentially(agent_id: str) MoveTangentially[source]#
sample_orient_horizontal(agent_id: str) OrientHorizontal[source]#
sample_orient_vertical(agent_id: str) OrientVertical[source]#
sample_set_agent_pitch(agent_id: str) SetAgentPitch[source]#
sample_set_agent_pose(agent_id: str) SetAgentPose[source]#
sample_set_sensor_pitch(agent_id: str) SetSensorPitch[source]#
sample_set_sensor_pose(agent_id: str) SetSensorPose[source]#
sample_set_sensor_rotation(agent_id: str) SetSensorRotation[source]#
sample_set_yaw(agent_id: str) SetYaw[source]#
sample_turn_left(agent_id: str) TurnLeft[source]#
sample_turn_right(agent_id: str) TurnRight[source]#
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, rng: Generator | None = None, **kwargs)[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 UniformlyDistributedCreator’s translation_high and translation_low parameters are used to determine the action’s distance parameter.

sample_look_down(agent_id: str) LookDown[source]#
sample_look_up(agent_id: str) LookUp[source]#
sample_move_forward(agent_id: str) MoveForward[source]#
sample_move_tangentially(agent_id: str) MoveTangentially[source]#
sample_orient_horizontal(agent_id: str) OrientHorizontal[source]#
sample_orient_vertical(agent_id: str) OrientVertical[source]#
sample_set_agent_pitch(agent_id: str) SetAgentPitch[source]#
sample_set_agent_pose(agent_id: str) SetAgentPose[source]#
sample_set_sensor_pitch(agent_id: str) SetSensorPitch[source]#
sample_set_sensor_pose(agent_id: str) SetSensorPose[source]#
sample_set_sensor_rotation(agent_id: str) SetSensorRotation[source]#
sample_set_yaw(agent_id: str) SetYaw[source]#
sample_turn_left(agent_id: str) TurnLeft[source]#
sample_turn_right(agent_id: str) TurnRight[source]#

tbp.monty.frameworks.actions.actions#

class Action(agent_id: str)[source]#

Bases: ABC

An action that can be taken by an agent.

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

abstract act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod action_name() str[source]#

Generate action name based on class.

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

Returns:

The action name in snake_case.

abstract classmethod sample(agent_id: str, sampler: ActionSampler) Action[source]#

Uses the sampler to sample an instance of this action.

property name: str#

Used for checking action name on an Action instance.

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

Bases: Action

Rotate the agent downwards by a specified number of degrees.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) LookDown[source]#

Uses the sampler to sample an instance of this action.

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

Bases: Action

Rotate the agent upwards by a specified number of degrees.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) LookUp[source]#

Uses the sampler to sample an instance of this action.

class MoveForward(agent_id: str, distance: float)[source]#

Bases: Action

Move the agent forward by a specified distance.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) MoveForward[source]#

Uses the sampler to sample an instance of this action.

class MoveTangentially(agent_id: str, distance: float, direction: Tuple[float, float, float])[source]#

Bases: Action

Move the agent tangentially.

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

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) MoveTangentially[source]#

Uses the sampler to sample an instance of this action.

class OrientHorizontal(agent_id: str, rotation_degrees: float, left_distance: float, forward_distance: float)[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.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) OrientHorizontal[source]#

Uses the sampler to sample an instance of this action.

class OrientVertical(agent_id: str, rotation_degrees: float, down_distance: float, forward_distance: float)[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.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) OrientVertical[source]#

Uses the sampler to sample an instance of this action.

class SetAgentPitch(agent_id: str, pitch_degrees: float)[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 agent’s sensors with regard to the environment.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) SetAgentPitch[source]#

Uses the sampler to sample an instance of this action.

class SetAgentPose(agent_id: str, location: Tuple[float, float, float], rotation_quat: Tuple[float, float, float, float])[source]#

Bases: Action

Set the agent pose.

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

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) SetAgentPose[source]#

Uses the sampler to sample an instance of this action.

class SetSensorPitch(agent_id: str, pitch_degrees: float)[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.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) SetSensorPitch[source]#

Uses the sampler to sample an instance of this action.

class SetSensorPose(agent_id: str, location: Tuple[float, float, float], rotation_quat: Tuple[float, float, float, float])[source]#

Bases: Action

Set the sensor pose.

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

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) SetSensorPose[source]#

Uses the sampler to sample an instance of this action.

class SetSensorRotation(agent_id: str, rotation_quat: Tuple[float, float, float, float])[source]#

Bases: Action

Set the sensor rotation relative to the agent.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) SetSensorRotation[source]#

Uses the sampler to sample an instance of this action.

class SetYaw(agent_id: str, rotation_degrees: float)[source]#

Bases: Action

Set the agent body yaw rotation.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) SetYaw[source]#

Uses the sampler to sample an instance of this action.

class TurnLeft(agent_id: str, rotation_degrees: float)[source]#

Bases: Action

Rotate the agent to the left.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) TurnLeft[source]#

Uses the sampler to sample an instance of this action.

class TurnRight(agent_id: str, rotation_degrees: float)[source]#

Bases: Action

Rotate the agent to the right.

act(actuator: Actuator) None[source]#

Execute the action using the provided actuator.

classmethod sample(agent_id: str, sampler: ActionSampler) TurnRight[source]#

Uses the sampler to sample an instance of this action.

tbp.monty.frameworks.actions.actuator#

class Actuator[source]#

Bases: ABC

An actuator that can execute actions.

An actuator is responsible for executing actions generated by the MotorSystem. An environment implementation will pass the actuator to the action’s act() method and the action will select the appropriate actuate method to call.

For example, the LookDown action will call actuate_look_down() on the actuator.

abstract actuate_look_down(action: LookDown) None[source]#
abstract actuate_look_up(action: LookUp) None[source]#
abstract actuate_move_forward(action: MoveForward) None[source]#
abstract actuate_move_tangentially(action: MoveTangentially) None[source]#
abstract actuate_orient_horizontal(action: OrientHorizontal) None[source]#
abstract actuate_orient_vertical(action: OrientVertical) None[source]#
abstract actuate_set_agent_pitch(action: SetAgentPitch) None[source]#
abstract actuate_set_agent_pose(action: SetAgentPose) None[source]#
abstract actuate_set_sensor_pitch(action: SetSensorPitch) None[source]#
abstract actuate_set_sensor_pose(action: SetSensorPose) None[source]#
abstract actuate_set_sensor_rotation(action: SetSensorRotation) None[source]#
abstract actuate_set_yaw(action: SetYaw) None[source]#
abstract actuate_turn_left(action: TurnLeft) None[source]#
abstract actuate_turn_right(action: TurnRight) None[source]#