Control Robot Movement
Through the movement control API provided by MyAGVPlus, you can conveniently control the omnidirectional Mecanum wheel chassis to translate, move backward, and rotate in place.
1 API Description
Translation-based movement commands require a speed parameter, and its valid range is 0.01 to 1.60 (m/s). For safety reasons, if the speed setting goes out of bounds, the system will trigger a warning and automatically intercept the command at the underlying layer. The parameter for in-place rotation commands is angular_speed.
Common movement APIs are as follows:
move_forward(speed): Control the robot to translate forwardmove_backward(speed): Control the robot to translate backwardmove_left_lateral(speed): Control the robot to translate laterally to the leftmove_right_lateral(speed): Control the robot to translate laterally to the rightturn_left(angular_speed): Control the robot to rotate left in place (counterclockwise)turn_right(angular_speed): Control the robot to rotate right in place (clockwise)stop(): Emergency brake to stop all movements; the underlying layer will instantly issue a 0-speed command
Safety Notice: An automatic protection process runs in the system's background. If severe undervoltage (<19.0V) or motor overcurrent stall occurs, the system will automatically ignore new speed commands and lock the motors. Please promptly check the error logs for
BACKGROUND VOLTAGE DETECTED!orSTALL DETECTED!.
2 Simple Demo
Create a new Python file named control_move.py and enter the following code:
from pymycobot.myagvplus import MyAGVPlus
import time
# Initialize the MyAGVPlus object
agv = MyAGVPlus('/dev/myagvplus_controller', baudrate=921600, esp32_port='/dev/ttyACM0', esp32_baud=115200, debug=True)
# Power on the robot (turns on the relay and enables motors, wait about 6 seconds for motors to fully start)
agv.power_on()
speed = 0.5 # Set uniform translation speed to 0.5 m/s
angular_speed = 0.5 # Set rotation angular speed to 0.5 rad/s
print("Translating forward...")
agv.move_forward(speed)
time.sleep(2)
agv.stop()
time.sleep(1)
print("Rotating left in place...")
agv.turn_left(angular_speed)
time.sleep(2)
agv.stop()
time.sleep(1)
print("Translating laterally to the right...")
agv.move_right_lateral(speed)
time.sleep(2)
agv.stop()
# After running, safely turn off the robot power and disable motors
agv.power_off()