Skip to main content

Robot

Inherits from: ABC Abstract base class for all robot implementations. Provides core functionality including sensor management, optional WebSocket/REST servers, safety monitoring, and automatic cleanup. All robot implementations should inherit from this class and implement the abstract methods. Attributes: sensors (dict): Dictionary of attached sensors keyed by name server_port (int): Port for WebSocket/REST server enable_websocket (bool): Whether to enable WebSocket endpoint enable_rest (bool): Whether to enable REST endpoints

init

Robot.__init__(server_port: int = 4774, enable_websocket: bool = False, enable_rest: bool = False, client_timeout: float = 30.0) -> None
No docstring provided.
Arguments
server_port (int)
int
No description provided.
enable_websocket (bool)
bool
No description provided.
enable_rest (bool)
bool
No description provided.
client_timeout (float)
float
No description provided.
Returns
returns
None

addSensor

Robot.addSensor(name: str, sensor: Sensor) -> None
Add an external sensor to the robot.
Arguments
name (str)
str
required
Unique identifier for the sensor
sensor (Sensor)
Sensor
required
Sensor object to add (e.g. Camera, IMU, Lidar)
Returns
Note
None
The sensor will be accessible via self.sensors[name]

getImage

Robot.getImage(camera_name: str = '', image_type: Optional[str] = None) -> Optional[Image]
Return the image of camera.
Arguments
camera_name (str)
str
Name of the camera to get image from. If empty, uses the first available camera.
image_type (Optional[str])
Optional[str]
Deprecated parameter for image type selection. Use camera_name instead.
Returns
Optional[Image]
Optional[Image]
The requested image, or None if camera not found
Note
Optional[Image]
The image_type parameter is deprecated and will be removed. Use specific camera names instead.

getState

Robot.getState() -> dict
Get the state of the robot.
Returns
dict
dict
Current state of the robot including position, orientation, velocity, and other relevant state information
Raises
NotImplementedError
Must be implemented by subclasses

getPosition

Robot.getPosition() -> Optional[Position]
Get the position of the robot in the world frame, in meters.
Returns
Optional[Position]
Optional[Position]
Current position of the robot in world coordinates, or None if position is unavailable
Raises
NotImplementedError
Must be implemented by subclasses

getOrientation

Robot.getOrientation() -> Optional[Orientation]
Get the orientation of the robot in the world frame.
Returns
Optional[Orientation]
Optional[Orientation]
Current orientation of the robot in world coordinates, or None if orientation is unavailable
Raises
NotImplementedError
Must be implemented by subclasses

moveByVelocity

Robot.moveByVelocity(linear_velocity: Velocity, angular_velocity: Velocity, frame: str = 'body') -> None
Move the robot by a given velocity in m/s. Due to different form factors for robots, there is no guarantee that the robot will exactly move at the given velocity. Hence, it is recommended to use feedback and state data to ensure that the robot is moving as expected. We also recommend referring to the robot specific documentation for more information on how to use this method.
Arguments
linear_velocity (Velocity)
Velocity
required
Linear velocity in m/s
angular_velocity (Velocity)
Velocity
required
Angular velocity in rad/s
frame (str)
str
Reference frame for velocity (“body” or “world”)
Returns
returns
None
Raises
NotImplementedError
Must be implemented by subclasses

stop

Robot.stop() -> None
Soft e-stop for the robot. Should stop the robot from moving gracefully. For example, a drone would hover in place, a quadruped would stop moving but remain standing. Note: This method is automatically called when the program exits, is interrupted, or receives termination signals. Subclasses should implement this method to ensure safe robot shutdown.
Returns
returns
None
Raises
NotImplementedError
Must be implemented by subclasses

cleanup

Robot.cleanup() -> None
Cleanup the robot resources. Stops monitoring threads and cleans up resources. Called automatically during robot shutdown but can be called manually if needed.
Returns
returns
None