MyAGV Plus API User Guide
Note: All APIs below are Python APIs. Please install the
pymycobotPython SDK package before use. This documentation is adapted based on the latestmyagvplusandmyagvplusapisource code.
1. System & Product Information
get_system_version()
- Description: Get the main firmware version number.
- Return Value:
float(version number)
get_modify_version()
- Description: Get the sub-firmware modification version number.
- Return Value:
float(version number)
power_on()
- Description: Power on the robot (turn on relay, enable all motors, and initialize to velocity control mode).
- Return Value:
int(1: Success, 0: Failure)
power_off()
- Description: Power off the robot (disable all motors and turn off relay power).
- Return Value:
int(1: Success, 0: Failure)
is_power_on()
- Description: Check whether the robot chassis relay power is turned on.
- Return Value:
int(1: Power ON, 0: Power OFF)
get_robot_status()
- Description: Read robot hardware status and error information.
- Return Value:
list[int][battery_status, gyro_status, battery_level]- Battery status: 0-Normal, 1-Abnormal
- Gyroscope status: 0-Normal, 1-Abnormal
- Battery level: 0-Normal, 1-Warning (<=19.6V), 2-Low Battery (<19.0V)
- Note: While charging: <19.8v 1="" 2="" is="" level="" (low="" battery),="" 19.8v–20.3v="" (warning),="">20.3V is Level 0 (Normal).19.8v>
- Note: While discharging: <19.2v 1="" 2="" is="" level="" (low="" battery),="" 19.2v–19.7v="" (warning),="">19.7V is Level 0 (Normal).19.2v>
get_all_msg()
- Description: Retrieve all chassis status information and sensor readings in a single call.
- Return Value:
list0: (int) Battery status (0: Normal, 1: Abnormal)1: (int) Gyroscope status (0: Normal, 1: Abnormal)2: (int) Battery level (0: Normal, 1: Warning, 2: Low Battery)3: (str) Charging status (binary string format)4: (float) Main battery voltage5: (float) Sub-battery voltage6: (list[float]) Parsed 18-byte gyroscope raw data7: (float) High-precision main battery voltage (if supported)8: (float) High-precision sub-battery voltage (if supported)
2. Motion Control
Note:
movespeed range: 0.01 ~ 1.60 m/s;turnangular speed range: 0.01 ~ 7.27 rad/s.- Safety Interlock & Undervoltage Protection: If dual-battery undervoltage (<19.0V) or motor stall/overload occurs, the background thread automatically locks all motion, and subsequent movement commands will be intercepted.
move_forward(speed)
- Description: Translate the robot forward.
- Return Value:
int(1: Success, -1: Failure / Intercepted)
move_backward(speed)
- Description: Translate the robot backward.
- Return Value:
int(1: Success, -1: Failure / Intercepted)
move_left_lateral(speed)
- Description: Translate the robot laterally to the left.
- Return Value:
int(1: Success, -1: Failure / Intercepted)
move_right_lateral(speed)
- Description: Translate the robot laterally to the right.
- Return Value:
int(1: Success, -1: Failure / Intercepted)
turn_left(angular_speed)
- Description: Rotate in place counter-clockwise (turn left).
- Parameters:
angular_speed(float): Angular velocity in rad/s. - Return Value:
int(1: Success, -1: Failure / Intercepted)
turn_right(angular_speed)
- Description: Rotate in place clockwise (turn right).
- Parameters:
angular_speed(float): Angular velocity in rad/s. - Return Value:
int(1: Success, -1: Failure / Intercepted)
stop()
- Description: Stop all motion immediately.
- Return Value:
int(1: Success, -1: Failure / Intercepted)
set_auto_report_state(state)
- Description: Set ESP32 background auto-reporting switch state (ESP32 reports data every 50ms).
- Parameters:
state(int): 0-Disable, 1-Enable - Return Value:
int(1: Success, 0: Failure)
get_auto_report_state()
- Description: Get active ESP32 auto-report state.
- Return Value:
int(0: Disabled, 1: Active)
get_auto_report_message()
- Description: Passively retrieve the latest captured automatic reporting data packet.
- Return Value:
list(same data structure asget_all_msg)
3. Motor Auxiliary Control
set_motor_enable(motor_id, state)
- Description: Enable or disable target wheel motor torque.
- Parameters:
motor_id(int): 1~4 for individual motor ID, 254 for all motors.state(int): 0-Disable, 1-Enable
- Return Value:
int(1: Success)
get_motor_enable_status()
- Description: Read enable state of all wheel motors.
- Return Value:
list[int][m1, m2, m3, m4](0-Disabled/Offline, 1-Enabled/Online)
get_motor_status()
- Description: Read hardware error status codes of all DM wheel motors (0 means normal).
- Return Value:
list[int][m1, m2, m3, m4]
clear_motor_error(motor_id)
- Description: Clear motor error code and self-heal by resetting and re-enabling target motor.
- Parameters:
motor_id(int): 1~4 or 254 - Return Value:
int(1: Success)
get_motor_temps()
- Description: Read temperature sensors on wheel motor MOS controllers.
- Return Value:
list[float][m1, m2, m3, m4]
get_motor_velocity(motor_id)
- Description: Read real-time angular velocity of target motor.
- Parameters:
motor_id(int): 1~4 - Return Value:
float(angular speed in rad/s)
get_motor_torque(motor_id)
- Description: Read real-time output torque of target motor.
- Parameters:
motor_id(int): 1~4 - Return Value:
float(torque in N·m)
get_motor_move_speeds()
- Description: Read real-time linear speed translation of all 4 wheels.
- Return Value:
list[float][m1, m2, m3, m4]
get_motor_turn_speeds()
- Description: Read real-time angular speed translation of all 4 wheels.
- Return Value:
list[float][m1, m2, m3, m4]
get_motor_torques()
- Description: Read feedback output torque values of all 4 motors.
- Return Value:
list[float][m1, m2, m3, m4]
4. IO Control & Communication
set_led_mode(mode)
- Description: Set active LED display mode.
- Parameters:
mode(int): 0-Battery level mode (default), 1-DIY mode - Return Value:
int(1: Success, 0: Failure)
set_led_color(brightness, color)
- Description: Set DIY LED strip brightness and RGB color (requires calling
set_led_mode(1)first). - Parameters:
brightness(int): Brightness 0 ~ 255color(tuple): RGB tuple(R, G, B)
- Return Value:
int(1: Success, 0: Failure)
set_fan_state(state)
- Description: Turn internal chassis cooling fans on or off.
- Parameters:
state(int): 0 - Fan Off, 1 - Fan On
- Return Value:
int(1: Success, 0: Failure)
set_pump_state(state)
- Description: Set suction pump state (Command 0x43).
- Parameters:
state(int): 0 - Close suction pump, 1 - Open suction pump
- Return Value:
int(1: Success, -1: Failure)
set_pump_io(pin, state)
- Description: Set suction pump control IO pin voltage level (Command 0x44).
- Parameters:
pin(int): Pin index (2 or 5)state(int): 0 - Low level (Pump Working/Open), 1 - High level (Pump Closed)
- Return Value:
int(1: Success, -1: Failure)
get_pin_input(pin)
- Description: Read voltage input levels from target IO pin ports.
- Parameters:
pin(int): Pin index 0 ~ 6 (0 reads all input pins) - Return Value:
int(Current level state; -1 for read failure or invalid pin)
set_pin_output(pin, state)
- Description: Write voltage output levels to target IO pin ports.
- Parameters:
pin(int): 0 ~ 6state(int): 0 - Low level, 1 - High level
- Return Value:
int(1: Success, 0: Failure)
set_communication_state(state)
- Description: Toggle robot communication protocol channel state. When switched to
1(Socket), physical serial ports are safely released. - Parameters:
state(int): 0-Serial Communication (default), 1-Socket Communication
- Return Value:
int(1: Success, -1: Failure)
get_communication_state()
- Description: Get active communication protocol channel mode.
- Return Value:
int(0: Serial, 1: Socket)
5. WiFi & Bluetooth
get_wifi_ip()
- Description: Get robot network adapter active local IP.
- Return Value:
str(IP address string, returns empty string on failure)
get_wifi_account()
- Description: Get connected router SSID account name.
- Return Value:
str(SSID string, returns empty string on failure)
get_bluetooth_address()
- Description: Read adapter Bluetooth MAC address.
- Return Value:
str(Bluetooth MAC address string, returns empty string on failure)
6. Usage Examples
6.1 Get AGVPlus System Information
from pymycobot import MyAGVPlus
# Initialize MyAGVPlus instance
agv_plus = MyAGVPlus("/dev/ttyACM0", baudrate=921600, esp32_port='/dev/ttyCH341USB0', esp32_baud=115200, debug=True)
# Get main firmware version number
version = agv_plus.get_system_version()
print(f"System Version: {version}")
# Get all battery and chassis status messages
print(agv_plus.get_all_msg())
6.2 Motion Control & LED Settings
import time
from pymycobot import MyAGVPlus
agv_plus = MyAGVPlus("/dev/ttyACM0", baudrate=921600, esp32_port='/dev/ttyCH341USB0', esp32_baud=115200, debug=True)
# Power on robot (includes relay powering on and motor enabling, takes approx 6s)
agv_plus.power_on()
# Switch LED to DIY mode and set color to Red
agv_plus.set_led_mode(1)
agv_plus.set_led_color(255, (255, 0, 0))
# Move AGVPlus forward at 0.5 m/s
agv_plus.move_forward(0.5)
time.sleep(3)
# Turn left in place
agv_plus.turn_left(0.3)
time.sleep(2)
# Stop all motion
agv_plus.stop()
# Power off robot relay and disable motors
agv_plus.power_off()
6.3 Get Network Info & Switch Communication Mode to Socket
from pymycobot import MyAGVPlus
agv_plus = MyAGVPlus("/dev/ttyACM0", baudrate=921600, esp32_port='/dev/ttyCH341USB0', esp32_baud=115200, debug=True)
# Get AGVPlus WiFi SSID account
account = agv_plus.get_wifi_account()
print(f"SSID: {account}")
# Get AGVPlus IP address
ip = agv_plus.get_wifi_ip()
print(f"IP: {ip}")
# Set active communication mode to Socket mode
set_result = agv_plus.set_communication_state(1)
if set_result == 1:
print("Set communication mode to Socket successfully.")
6.4 Start & Control Remotely via Socket Daemon
Socket mode allows controlling the AGV with zero latency from any PC connected to the same LAN.
Step 1: Start the network daemon process on the AGV board (Jetson Nano / Raspberry Pi) Open a terminal on the AGV and run:
python3 -m pymycobot.myagvplussocket_server # or run specific agv_socket_server.py
(Note: While the daemon is running, it automatically detects the communication state and manages port 9000.)
Step 2: Switch communication state in code
agv_plus.set_communication_state(1)
The SDK immediately releases physical serial ports! The background socket server detects mode 1 and takes over chassis control.
Step 3: Control remotely from another PC on the network
from pymycobot.myagvplussocket import MyAGVPlusSocket
import time
# Connect to AGV IP on port 9000
agv = MyAGVPlusSocket("192.168.1.132", 9000)
print(agv.get_motor_move_speeds()) # Read speed info remotely
agv.move_left_lateral(0.3) # Control left lateral move remotely
time.sleep(2)
agv.stop()