Skip to content

API Reference

Robot Configuration

MOZ1RobotConfig

Main configuration class for setting robot parameters.

Constructor Parameters:

ParameterTypeDefaultDescription
realsense_serialsstr"0000000000,0000000000,0000000000"RealSense camera serial numbers (comma-separated)
camera_resolutionsstr"320*240,320*240,320*240"Camera resolutions, format "width*height"
no_cameraboolFalseSkip camera initialization (for testing)
structurestr"wholebody"Robot configuration type
robot_control_hzint120Control loop frequency (Hz), should match robot control system settings
enable_soft_realtimeboolFalseEnable soft real-time scheduling, requires running scripts/setup_rtprio.sh first
bind_cpu_idxsOptional[Sequence[int]]NoneCPU binding index list, e.g., [5] means bind to CPU core 5, index starts from 0

Supported Robot Structures:

  • dualarm: Dual arm configuration (left arm + right arm)
  • wholebody_without_base: Whole body configuration without mobile base (dual arms + torso)
  • wholebody: Whole body configuration with mobile base (dual arms + torso + base)

Configuration Examples:

python
from mozrobot import MOZ1RobotConfig

# Basic dual arm configuration
config = MOZ1RobotConfig(
    realsense_serials="123456789,987654321,555666777",
    camera_resolutions="640*480,640*480,640*480",
    structure="dualarm",
    robot_control_hz=120
)

# Test configuration without camera
config_no_cam = MOZ1RobotConfig(
    no_camera=True,
    structure="dualarm"
)

# Whole body configuration
config_wholebody = MOZ1RobotConfig(
    structure="wholebody",
    robot_control_hz=120
)

# High-performance real-time configuration
config_realtime = MOZ1RobotConfig(
    structure="dualarm",
    robot_control_hz=120,
    enable_soft_realtime=True,  # Enable soft real-time scheduling
    bind_cpu_idxs=[5]  # Bind to CPU core 5
)

Robot Control

MOZ1Robot

Main robot control class providing connection, control, and data acquisition functions.

Constructor:

python
MOZ1Robot(config: MOZ1RobotConfig)

Core Methods:

Connection Management

python
connect() -> None

Establish connection to the robot system.

  • Exception: Raises RuntimeError on connection failure
python
disconnect() -> None

Disconnect from the robot system.

python
is_robot_connected -> bool

Property to check robot connection status.

  • Returns: True if robot is connected, otherwise False
  • Usage: Check connection status before sending commands to ensure robot communication is normal

Robot Control

python
enable_external_following_mode() -> None

Enable external following control mode.

  • Important: Must activate external following mode before using send_action
  • Function: Activates the robot's external control receiver, making commands sent by send_action effective
  • Exception: Raises RobotDeviceNotConnectedError if robot is not connected
python
send_action(action: Dict) -> Dict

Send control commands to the robot.

  • Parameters:
    • action: Action command dictionary, data units are SI units (radians, meters, seconds)
  • Returns: Sent action command confirmation
  • Important Requirements:
    1. Call Frequency: send_action calls must maintain a stable frequency, consistent with the robot_control_hz initialization parameter
    2. Trajectory Continuity: Sent trajectories must satisfy continuity constraints, avoiding large sudden changes in acceleration and jerk
    3. Exclusive Control Mode: Each execution structure (left arm/right arm/torso) can only choose one of axis space control or Cartesian space control at the same time
    4. Prerequisite: Must call enable_external_following_mode() method first
  • Exception: Raises RuntimeError if robot is not connected or sending fails
python
reset_robot_positions(left_arm_joints: Optional[List] = None,
                     right_arm_joints: Optional[List] = None,
                     torso_joints: Optional[List] = None,
                     gripper_positions: Optional[List] = None) -> bool

Asynchronously reset robot to specified positions.

  • Parameters:
    • left_arm_joints: Left arm joint target positions (optional)

    • right_arm_joints: Right arm joint target positions (optional)

    • torso_joints: Torso joint target positions (optional)

    • gripper_positions: Gripper positions (optional)

      Data units are SI units (radians, meters)

  • Returns: True if reset command was sent successfully
  • Important: This method is asynchronous. After calling, you need to manually sleep and wait for the robot to complete the reset action
  • Recommendation: Wait 3-5 seconds after reset to ensure the robot has stabilized at the position. Specific time depends on robot speed set in MovaX
  • Exception: Raises RobotDeviceNotConnectedError if robot is not connected

Status Monitoring

python
capture_observation() -> Dict

Capture current robot state, including images and joint data.

  • Returns: Dictionary containing observation data, data units are SI units (radians, meters, seconds)
  • Camera Update Frequency: RealSense cameras update image data at 30Hz
  • Data Content: Contains robot joint states, Cartesian positions, gripper states, and camera images
  • Rotation Representation: All rotation data uses rotation vector representation
  • Base Control: When robot is configured as wholebody, the base uses velocity control mode, returning current velocity state [vx, vy, wz]
  • Exception: Raises RuntimeError if robot is not connected or data capture fails

Additional Methods

python
control_hz -> int

Check the robot's control frequency

  • Returns: Currently effective robot control frequency

Robot Control