Skip to content

Latest commit

 

History

History
116 lines (66 loc) · 3.43 KB

robot_base.md

File metadata and controls

116 lines (66 loc) · 3.43 KB

RobotBase

from tdw.add_ons.robot_base import RobotBase

Abstract base class for robots.


Class Variables

Variable Type Description Value
NON_MOVING float If a joint has moved less than this many degrees (revolute or spherical) or meters (prismatic) since the previous frame, it is considered to be not moving for the purposes of determining which joints are moving. 0.001

Fields

  • initial_position The initial position of the robot.

  • initial_rotation The initial rotation of the robot.

  • robot_id The ID of this robot.

  • static Static robot data.

  • dynamic Dynamic robot data.

  • commands These commands will be appended to the commands of the next communicate() call.

  • initialized If True, this module has been initialized.


Functions

__init__

RobotBase()

RobotBase(robot_id=0, position=None, rotation=None)

Parameter Type Default Description
robot_id int 0 The ID of the robot.
position Dict[str, float] None The position of the robot. If None, defaults to {"x": 0, "y": 0, "z": 0}.
rotation Dict[str, float] None The rotation of the robot in Euler angles (degrees). If None, defaults to {"x": 0, "y": 0, "z": 0}.

get_initialization_commands

self.get_initialization_commands()

This function gets called exactly once per add-on. To re-initialize, set self.initialized = False.

Returns: A list of commands that will initialize this add-on.

on_send

self.on_send(resp)

This is called after commands are sent to the build and a response is received.

Use this function to send commands to the build on the next frame, given the resp response. Any commands in the self.commands list will be sent on the next frame.

Parameter Type Default Description
resp List[bytes] The response from the build.

before_send

self.before_send(commands)

This is called before sending commands to the build. By default, this function doesn't do anything.

Parameter Type Default Description
commands List[dict] The commands that are about to be sent to the build.

get_early_initialization_commands

self.get_early_initialization_commands()

This function gets called exactly once per add-on. To re-initialize, set self.initialized = False.

These commands are added to the list being sent on communicate() before any other commands, including those added by the user and by other add-ons.

Usually, you shouldn't override this function. It is useful for a small number of add-ons, such as loading screens, which should initialize before anything else.

Returns: A list of commands that will initialize this add-on.

joints_are_moving

self.joints_are_moving()

self.joints_are_moving(joint_ids=None)

Parameter Type Default Description
joint_ids List[int] None A list of joint IDs to check for movement. If None, check all joints for movement.

Returns: True if the joints are moving.

reset

self.reset()

self.reset(position=None, rotation=None)

Reset the robot.

Parameter Type Default Description
position Dict[str, float] None The position of the robot.
rotation Dict[str, float] None The rotation of the robot.