MyAGV Plus API User Guide
Note: All APIs described below are Python APIs. Install the
pymycobotPython SDK package before usage. This document is adapted from the latest source code ofmyagvplusandmyagvplusapi.
1. System & Product Information
get_system_version()
- Function: Get the main firmware version number
- Return Value:
float(version number)
get_modify_version()
- Function: Get the secondary firmware version number (precision calibrated, returns the actual value directly)
- Return Value:
float(version number)
power_on()
- Function: Power on the robot (activate relays, enable all motors, initialize to speed control mode)
- Return Value:
int(1: Success, 0: Failure)
power_off()
- Function: Power off the robot (disable all motors and cut off relay power supply)
- Return Value:
int(1: Success, 0: Failure)
is_power_on()
- Function: Check if the chassis relay power supply of the robot is enabled
- Return Value:
int(1: Powered on, 0: Powered off)
get_robot_status()
- Function: Read hardware fault status information of the robot
- Return Value:
list[int][Battery Status, Gyroscope 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)
- Remarks:
- Charging state: Below 19.8V = Level 2 Low Battery; 19.8V–20.3V = Level 1 Warning; Above 20.3V = Level 0 Normal
- Non-charging state: Below 19.2V = Level 2 Low Battery; 19.2V–19.7V = Level 1 Warning; Above 19.7V = Level 0 Normal
get_all_msg()
- Function: Obtain all chassis status information and sensor readings in one call
- Return Value:
list- Index 0: (int) Battery status (0 Normal, 1 Abnormal)
- Index 1: (int) Gyroscope status (0 Normal, 1 Abnormal)
- Index 2: (int) Battery level (0 Normal, 1 Warning, 2 Critical Low)
- Index 3: (str) Charging status (binary format string)
- Index 4: (float) Primary battery voltage
- Index 5: (float) Secondary battery voltage
- Index 6: (list[float]) Parsed 18-byte gyroscope raw data
- Index 7: (float) High-precision primary battery voltage (if supported)
- Index 8: (float) High-precision secondary battery voltage (if supported)
2. Motion Control
Notes:
- Valid linear speed range for move commands: 0.01 ~ 1.60 m/s. Valid angular speed range for turn commands: 0.01 ~ 7.27 rad/s.
- Safety Interlock & Undervoltage Protection: If dual batteries drop below undervoltage threshold (<19.0V) or any motor locks up due to overload, background threads will automatically disable all motion. All subsequent motion commands will be intercepted.
move_forward(speed)
- Function: Translate the robot forward
- Return Value:
int(1: Success, -1: Failed / Intercepted)
move_backward(speed)
- Function: Translate the robot backward
- Return Value:
int(1: Success, -1: Failed / Intercepted)
move_left_lateral(speed)
- Function: Translate the robot to the left
- Return Value:
int(1: Success, -1: Failed / Intercepted)
move_right_lateral(speed)
- Function: Translate the robot to the right
- Return Value:
int(1: Success, -1: Failed / Intercepted)
turn_left(angular_speed)
- Function: Rotate counterclockwise in place
- Parameter:
angular_speed(float): Angular velocity - Return Value:
int(1: Success, -1: Failed / Intercepted)
turn_right(angular_speed)
- Function: Rotate clockwise in place
- Parameter:
angular_speed(float): Angular velocity - Return Value:
int(1: Success, -1: Failed / Intercepted)
stop()
- Function: Halt all robot movement
- Return Value:
int(1: Success, -1: Failed / Intercepted)
set_auto_report_state(state)
- Function: Enable/disable automatic low-level data reporting (ESP32 transmits data every 50ms)
- Parameter:
state(int): 0 = Disabled, 1 = Enabled - Return Value:
int(1: Success, 0: Failure)
get_auto_report_state()
- Function: Get current automatic reporting status
- Return Value:
int(0: Disabled, 1: Enabled)
get_auto_report_message()
- Function: Passively fetch parsed data from the latest automatic report frame
- Return Value:
list(data structure matches the return value ofget_all_msg)
3. Auxiliary Motor Control
set_motor_enable(motor_id, state)
- Function: Set the enable status of a motor
- Parameters:
motor_id(int): 1~4 for individual motors, 254 for all four motorsstate(int): 0 = Disabled, 1 = Enabled
- Return Value:
int(1: Success)
get_motor_enable_status()
- Function: Get enable status of all four motors
- Return Value:
list[int][m1, m2, m3, m4](0 = Disabled/Offline, 1 = Enabled/Online)
get_motor_status()
- Function: Read hardware fault codes of each DM motor (0 indicates normal operation)
- Return Value:
list[int][m1, m2, m3, m4]
clear_motor_error(motor_id)
- Function: Self-recovery interface to reset fault-locked motors
- Parameter:
motor_id(int): 1~4, 254 - Return Value:
int(1: Success)
get_motor_temps()
- Function: Get current temperature of each motor MOSFET
- Return Value:
list[float][m1, m2, m3, m4]
get_motor_velocity(motor_id)
- Function: Get current rotational speed of the specified motor
- Parameter:
motor_id(int): 1~4 - Return Value:
float(angular velocity in rad/s)
get_motor_torque(motor_id)
- Function: Get real-time output torque of the specified motor
- Parameter:
motor_id(int): 1~4 - Return Value:
float(torque in N·m)
get_motor_move_speeds()
- Function: Batch read linear travel speed of all four motors
- Return Value:
list[float][m1, m2, m3, m4]
get_motor_turn_speeds()
- Function: Batch read rotational speed of all four motors
- Return Value:
list[float][m1, m2, m3, m4]
get_motor_torques()
- Function: Batch read real-time output torque of all four motors
- Return Value:
list[float][m1, m2, m3, m4]
4. IO Control & Communication
set_led_mode(mode)
- Function: Switch LED operating mode
- Parameter:
mode(int): 0 = Battery indicator mode (default), 1 = Custom DIY mode - Return Value:
int(1: Success, 0: Failure)
set_led_color(brightness, color)
- Function: Set custom LED color (call
set_led_mode(1)first) - Parameters:
brightness(int): Brightness range 0 - 255color(tuple): RGB tuple(R, G, B)
- Return Value:
int(1: Success, 0: Failure)
set_fan_state(state)
- Function: Control cooling fan power state
- Parameter:
state(int): 0 = Fan off, 1 = Fan on
- Return Value:
int(1: Success, 0: Failure)
get_pin_input(pin)
- Function: Read digital input IO pin level
- Parameter:
pin(int): Pin number 0 - 6 - Return Value:
int(Current logic level; -1 = Read failure or invalid pin)
set_pin_output(pin, state)
- Function: Set digital output IO pin logic level
- Parameters:
pin(int): 0 - 6state(int): 0 = Low level, 1 = High level
- Return Value:
int(1: Success, 0: Failure)
set_communication_state(state)
- Function: Switch underlying communication mode. When set to
1(Socket), the physical serial port will be automatically released. - Parameter:
state(int): 0 = Serial communication (default), 1 = Socket network communication
- Return Value:
int(1: Success, -1: Failure)
get_communication_state()
- Function: Query current active communication mode
- Return Value:
int(0 = Serial, 1 = Socket)
5. WiFi & Bluetooth
get_wifi_ip()
- Function: Get LAN IP address of the connected WiFi network
- Return Value:
str(IP address; empty string on failure)
get_wifi_account()
- Function: Get SSID name of the connected WiFi network
- Return Value:
str(WiFi SSID; empty string on failure)
get_bluetooth_address()
- Function: Read MAC address of the local Bluetooth adapter
- Return Value:
str(Bluetooth MAC address; empty string on failure)
6. Usage Examples
6.1 Read MyAGV Plus 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)
# Fetch main firmware version
version = agv_plus.get_system_version()
print(version)
# Fetch full battery and chassis status data
print(agv_plus.get_all_msg())
6.2 AGV Motion & LED Control Demo
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 (relay activation + motor enable process, wait 6 seconds)
agv_plus.power_on()
# Switch LED to custom DIY mode and set solid red
agv_plus.set_led_mode(1)
agv_plus.set_led_color(255, (255, 0, 0))
# Move forward at 0.5 m/s
agv_plus.move_forward(0.5)
time.sleep(3)
# Rotate counterclockwise in place
agv_plus.turn_left(0.3)
time.sleep(2)
# Stop all movement
agv_plus.stop()
# Cut robot power and disable all motors
agv_plus.power_off()
6.3 Fetch Network Info & Switch to Socket Communication Mode
from pymycobot import MyAGVPlus
agv_plus = MyAGVPlus("/dev/ttyACM0", baudrate=921600, esp32_port='/dev/ttyCH341USB0', esp32_baud=115200, debug=True)
# Get connected WiFi SSID
account = agv_plus.get_wifi_account()
print(f"SSID: {account}")
# Get WiFi LAN IP address
ip = agv_plus.get_wifi_ip()
print(f"IP: {ip}")
# Switch communication mode to Socket
set_result = agv_plus.set_communication_state(1)
if set_result == 1:
print("Set communication mode to Socket successfully.")
6.4 Launch Socket Daemon for Seamless Remote Control
Socket mode enables zero-latency AGV control from any computer on the same local area network, ideal for secondary development.
Step 1: Launch network daemon on the AGV onboard controller (Jetson Nano / Raspberry Pi) Open terminal and execute:
python3 -m pymycobot.myagvplussocket_server # Or run standalone agv_socket_server.py
(Note: While running, the background process monitors communication status and occupies port 9000 on the physical serial port.)
Step 2: Switch communication mode via API
agv_plus.set_communication_state(1)
The underlying driver will immediately release ownership of the physical serial port! The background socket server takes over chassis communication once mode switches to 1.
Step 3: Remote control from a separate PC on the same LAN
from pymycobot.myagvplussocket import MyAGVPlusSocket
import time
# Connect to AGV LAN IP on port 9000
agv = MyAGVPlusSocket("192.168.1.132", 9000)
print(agv.get_motor_move_speeds()) # Remotely read motor speed data
agv.move_left_lateral(0.3) # Remote lateral left movement
time.sleep(2)
agv.stop()