> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Robot

## 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**

```python theme={null}
Robot.__init__(server_port: int = 4774, enable_websocket: bool = False, enable_rest: bool = False, client_timeout: float = 30.0) -> None
```

*No docstring provided.*

<ResponseField name="Arguments">
  <ParamField query="server_port (int)" type="int">
    *No description provided.*
  </ParamField>

  <ParamField query="enable_websocket (bool)" type="bool">
    *No description provided.*
  </ParamField>

  <ParamField query="enable_rest (bool)" type="bool">
    *No description provided.*
  </ParamField>

  <ParamField query="client_timeout (float)" type="float">
    *No description provided.*
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### addSensor

```python theme={null}
Robot.addSensor(name: str, sensor: Sensor) -> None
```

Add an external sensor to the robot.

<ResponseField name="Arguments">
  <ParamField query="name (str)" type="str" required>
    Unique identifier for the sensor
  </ParamField>

  <ParamField query="sensor (Sensor)" type="Sensor" required>
    Sensor object to add (e.g. Camera, IMU, Lidar)
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="Note" type="None">
    The sensor will be accessible via self.sensors\[name]
  </ResponseField>
</ResponseField>

### getImage

```python theme={null}
Robot.getImage(camera_name: str = '', image_type: Optional[str] = None) -> Optional[Image]
```

Return the image of camera.

<ResponseField name="Arguments">
  <ParamField query="camera_name (str)" type="str">
    Name of the camera to get image from. If empty, uses the first available camera.
  </ParamField>

  <ParamField query="image_type (Optional[str])" type="Optional[str]">
    Deprecated parameter for image type selection. Use camera\_name instead.
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="Optional[Image]" type="Optional[Image]">
    The requested image, or None if camera not found
  </ResponseField>

  <ResponseField name="Note" type="Optional[Image]">
    The image\_type parameter is deprecated and will be removed. Use specific camera names instead.
  </ResponseField>
</ResponseField>

### getState

```python theme={null}
Robot.getState() -> dict
```

Get the state of the robot.

<ResponseField name="Returns">
  <ResponseField name="dict" type="dict">
    Current state of the robot including position, orientation, velocity, and other relevant state information
  </ResponseField>
</ResponseField>

<ResponseField name="Raises">
  <ParamField query="NotImplementedError" type="">
    Must be implemented by subclasses
  </ParamField>
</ResponseField>

### getPosition

```python theme={null}
Robot.getPosition() -> Optional[Position]
```

Get the position of the robot in the world frame, in meters.

<ResponseField name="Returns">
  <ResponseField name="Optional[Position]" type="Optional[Position]">
    Current position of the robot in world coordinates, or None if position is unavailable
  </ResponseField>
</ResponseField>

<ResponseField name="Raises">
  <ParamField query="NotImplementedError" type="">
    Must be implemented by subclasses
  </ParamField>
</ResponseField>

### getOrientation

```python theme={null}
Robot.getOrientation() -> Optional[Orientation]
```

Get the orientation of the robot in the world frame.

<ResponseField name="Returns">
  <ResponseField name="Optional[Orientation]" type="Optional[Orientation]">
    Current orientation of the robot in world coordinates, or None if orientation is unavailable
  </ResponseField>
</ResponseField>

<ResponseField name="Raises">
  <ParamField query="NotImplementedError" type="">
    Must be implemented by subclasses
  </ParamField>
</ResponseField>

### moveByVelocity

```python theme={null}
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.

<ResponseField name="Arguments">
  <ParamField query="linear_velocity (Velocity)" type="Velocity" required>
    Linear velocity in m/s
  </ParamField>

  <ParamField query="angular_velocity (Velocity)" type="Velocity" required>
    Angular velocity in rad/s
  </ParamField>

  <ParamField query="frame (str)" type="str">
    Reference frame for velocity ("body" or "world")
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

<ResponseField name="Raises">
  <ParamField query="NotImplementedError" type="">
    Must be implemented by subclasses
  </ParamField>
</ResponseField>

### stop

```python theme={null}
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.

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

<ResponseField name="Raises">
  <ParamField query="NotImplementedError" type="">
    Must be implemented by subclasses
  </ParamField>
</ResponseField>

### cleanup

```python theme={null}
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.

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>
