mebo2_nabot.Robot
The main class that represents a single Mebo 2.0 or Nabot AI robot toy and it’s functions.
Movement
Methods for moving the robot.
- class mebo2_nabot.Robot
- arm_down(steps, sleep=0.1)
Lower arm for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.1)
- arm_up(steps, sleep=0.1)
Raise arm for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.1)
- backward(steps, sleep=0.5)
Move backward for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.5)
- claw_close(steps)
Close claw by specified number of steps.
- Parameters:
steps (int) – Number of movement steps
- claw_led_off()
Turn off the claw LED.
- claw_led_on()
Turn on the claw LED.
- claw_open(steps)
Open claw by specified number of steps.
- Parameters:
steps (int) – Number of movement steps
- forward(steps, sleep=0.5)
Move forward for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.5)
- get_battery()
Query and return an estimated battery charge percentage
- Returns:
Percent estimated battery charge remaining
- Return type:
int
- get_joint_positions() dict[Position, int]
Query and return current joint positions.
- Returns:
Current positions of all joints
- Return type:
dict
- left(steps, sleep=0.5)
Move left for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.5)
- right(steps, sleep=0.5)
Move right for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.5)
- send_joint_values(joint_dict: dict[Command, int])
Send multiple joint/motor commands.
- Parameters:
joint_dict (dict) – Dictionary mapping joint/motor names to their command values
- set_joint_positions(goal: dict[Position, float], max_loops=15, max_speed=20, stop_threshold=3, min_goal_threshold=5)
Move joints to specified positions with smooth motion control.
- Parameters:
goal (dict) – Target joint positions (e.g., {robot.Position.ARM: 60, robot.Position.CLAW: 30})
max_loops (int) – Maximum control loop iterations
max_speed (int) – Maximum movement speed per loop
stop_threshold (int) – Difference threshold to stop motion
min_goal_threshold (int) – Ignore small goal differences
- set_speed(speed)
Set default movement speed.
- Parameters:
speed (int) – Speed value (0-100)
- stop()
Stop all movement.
- toggle_claw_led()
Toggle claw LED on and off.
- wrist_down(steps, sleep=0.1)
Move wrist down for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.1)
- wrist_left(steps, sleep=0.1)
Rotate wrist left for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.1)
- wrist_right(steps, sleep=0.1)
Rotate wrist right for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.1)
- wrist_up(steps, sleep=0.1)
Move wrist up for specified number of steps.
- Parameters:
steps (int) – Number of movement steps
sleep (float, optional) – Time between steps (default 0.1)
- class mebo2_nabot.Robot.Command(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Enum of available commands and their strings.
- ACEAA = '!ACEAA'
Used only for init
- ARM_QUERY = 'ARM=?'
- ARM_UP = 'G'
- BAT = 'BAT=?'
- BCQAA = '!BCQAA'
Used only for init
- CAL_ALL = 'D_'
- CAL_ARM = 'DE'
- CAL_CLAW = 'Dg'
- CAL_WRIST_ROTATE = 'DQ'
- CAL_WRIST_UD = 'DI'
- CCIAA = '!CCIAA'
Used only for init
- CLAW_LED_STATE = 'claw_led_state()'
- CLAW_POSITION = 'N'
- CLAW_QUERY = 'CLAW=?'
- EYE_LED_STATE = 'eye_led_state()'
- GET_SSID = 'get_ssid()'
- INIT_ALL = '!CVVDSAAAAAAAAAAAAAAAAAAAAAAAAYtBQfA4uAAAAAAAAAAQfAoPAcXAAAA'
Used only for init
- LIGHT_OFF = 'RAAAAAAAac'
- LIGHT_ON = 'RAAAAAAAad'
- QUERY_EVENT = '*'
Exact function unknown
- QUERY_REG = ''
Exact function unknown
- REBOOT_CMD = 'DE'
- SAVE_REG = 'REG=FLUSH'
Exact function unknown
- SET_REG = ''
Exact function unknown
- VERSION_QUERY = 'VER=?'
- VIDEO_FLIP = 'video_flip(0)'
- VIDEO_MIRROR = 'video_mirror(0)'
- WHEEL_LEFT_FORWARD = 'F'
- WHEEL_LEFT_SPEED = 'F'
- WHEEL_RIGHT_FORWARD = 'E'
- WHEEL_RIGHT_SPEED = 'E'
- WRIST_ROTATE_LEFT = 'I'
- WRIST_ROTATE_QUERY = 'WRIST_ROTATE=?'
- WRIST_UD_QUERY = 'WRIST_UD=?'
- WRIST_UD_UP = 'H'
- enum mebo2_nabot.Robot.Position(value)
Enum representing joint positions with their associated commands.
Valid values are as follows:
- ARM = <Position.ARM: ('ARM_QUERY', 'ARM_UP')>
- WRIST_UD = <Position.WRIST_UD: ('WRIST_UD_QUERY', 'WRIST_UD_UP')>
- WRIST_ROTATE = <Position.WRIST_ROTATE: ('WRIST_ROTATE_QUERY', 'WRIST_ROTATE_LEFT')>
- CLAW = <Position.CLAW: ('CLAW_QUERY', 'CLAW_POSITION')>
The
Enumand its members also have the following methods:- property query_command
Return the associated Command enum that queries the position
- property control_command
Return the associated Command enum that controls the joint
Video and Audio
Methods for accessing the robot’s camera, microphone, and speaker.
- class mebo2_nabot.Robot.Camera
Class for capturing video from the camera.
Uses OpenCV to capture the RTSP video stream from robot.
- close()
Close camera connection.
- open()
Open camera connection.
- read()
Read a frame from camera.
- Returns:
Video frame or None if capture fails
- Return type:
numpy.ndarray
- class mebo2_nabot.Robot.Microphone(rate, buffer_size=4000)
Class for handling audio input from the microphone.
Uses ffmpeg to capture the RTSP audio stream.
- Parameters:
rate (int) – Audio sample rate
channels (int) – Number of audio channels
buffer_size (int) – Size of audio buffers to read in bytes (default 4000)
- close()
Close microphone stream.
- open()
Open microphone stream.
- read()
Generator that yields audio buffers from microphone.
- Yields:
numpy.ndarray – Buffers of audio data
- class mebo2_nabot.Robot.Speaker(**kwargs)
Class for handling audio output to the robot’s speaker.
Uses ffmpeg to stream audio to the robot over UDP.
- Optional args:
rate (int): Audio sample rate channels (int): Number of audio channels input_format (str): Audio input format channel_layout (str): Audio channel layout
- close()
Stop ffmpeg and close audio stream.
- open()
Start ffmpeg and open audio stream for writing.
- send_array(array, buffer_size=128)
Stream audio data from numpy array to robot’s speaker. Requires audio format information passed to instance of class.
- Parameters:
array (numpy.ndarray) – Array to play
buffer_size (int) – Size of buffers to send in bytes (default is 128)
- Raises:
ValueError – If required parameters are missing
- send_file(file)
Stream an audio file to the robot’s speaker. Audio format can usually be detected by ffmpeg.
- Parameters:
file (str) – Path of audio file
- write(data)
Write numpy data to open stream. Requires audio format information passed to instance of class.
- Parameters:
data (bytes) – Audio data to write
- Raises:
ValueError – If required parameters are missing