Welcome to DOFBOT SE repository
6.DOFBOT up down left right
DOFBOT Up Down Left Right
1. Experiment Approach
This experiment controls the DOFBOT to swing up, down, left, and right, then returns to the upright state. By simultaneously controlling servos 3 and 4 at different angles, we achieve the up/down swinging function. Then we control servo 1 for left/right swinging, and finally return to the upright state.
2. Code Content
Code path: /home/yahboom/Dofbot/3.ctrl_Arm/6.left_right.ipynb
xxxxxxxxxx#!/usr/bin/env python3#coding=utf-8import timefrom Arm_Lib import Arm_Device# Create DOFBOT objectArm = Arm_Device()time.sleep(.1)xdef main(): # Reset servos 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 to move up and down 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 to move left and right Arm.Arm_serial_servo_write(1, 180, 500) time.sleep(.5) Arm.Arm_serial_servo_write(1, 0, 1000) time.sleep(1) # Reset servos 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! ") passdel Arm # Release Arm object