Welcome to DOFBOT Pro repository
6. DOFBOT Up Down Left Right Movement
DOFBOT Up Down Left Right Movement
1. Experimental Approach
This experiment controls the DOFBOT to move up, down, left, and right, then return to an upright state. By simultaneously controlling servos 3 and 4 at different angles, we achieve the up and down swinging function. Then we control servo 1 for left and right movement, and finally return to the upright state.
2. Code Content
Code path:
~/dofbot_pro/dofbot_ctrl/scripts/06.left_right.ipynb
xxxxxxxxxx#!/usr/bin/env python3#coding=utf-8import timefrom Arm_Lib import Arm_Device# Create robotic arm objectArm = Arm_Device()time.sleep(.1)xxxxxxxxxxdef main(): # Let the servos return to center position Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 500) time.sleep(1) while True: # Control servos 3 and 4 for up and down movement Arm.Arm_serial_servo_write(3, 0, 1000) time.sleep(.001) Arm.Arm_serial_servo_write(4, 180, 1000) time.sleep(1) # Control servo 1 for left and right movement Arm.Arm_serial_servo_write(1, 180, 500) time.sleep(.5) Arm.Arm_serial_servo_write(1, 0, 1000) time.sleep(1) # Control servos to return to initial position Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 1000) time.sleep(1.5)try : main()except KeyboardInterrupt: print(" Program closed! ") passxxxxxxxxxxdel Arm # Release the Arm objectOpen the program file from jupyter lab, and click the "Run entire notebook" button on the jupyter lab toolbar, you can see the DOFBOT moving up, down, left, and right.

To exit, click the stop button on the toolbar.
