Arm_serial_servo_write6(S1, S2, S3, S4, S5, S6, time)
Function: Simultaneously control the angle to which the six servos of the robotic arm are to move.
Parameter explanation:
S1: Angle value of No. 1 servo 0~180.
S2: The angle value of No. 2 servo is 0~180.
S3: The angle value of No. 3 servo is 0~180.
S4: The angle value of No. 4 servo is 0~180.
S5: The angle value of servo No. 5 is 0~270.
S6: The angle value of servo No. 6 is 0~180.
Time: Controls the time the servo runs. Within the valid range, the servo rotates at the same angle. The smaller the input running time, the faster the servo moves. Entering 0 will cause the servo to run at the fastest speed.
Return value: None.
Code path: /home/jetson/Dofbot/3.ctrl_Arm/5.ctrl_all.ipynb
x
#!/usr/bin/env python3
#coding=utf-8
import time
from Arm_Lib import Arm_Device
# Creating a robotic arm object
Arm = Arm_Device()
time.sleep(.1)
x
# Simultaneously control the movement of six servos and gradually change angles
def ctrl_all_servo(angle, s_time = 500):
Arm.Arm_serial_servo_write6(angle, 180-angle, angle, angle, angle, angle,
s_time)
time.sleep(s_time/1000)
def main():
dir_state = 1
angle = 90
# Reset the servo to center
Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 500)
time.sleep(1)
while True:
if dir_state == 1:
angle += 1
if angle >= 180:
dir_state = 0
else:
angle -= 1
if angle <= 0:
dir_state = 1
ctrl_all_servo(angle, 10)
time.sleep(10/1000)
# print(angle)
try :
main()
except KeyboardInterrupt:
print(" Program closed! ")
pass
xdel Arm # Release the Arm object
Open the program file from jupyter lab and click the Run Entire Notebook button on the jupyter lab toolbar.
You can see that the six servos of the robotic arm rotate at the same time, and the robotic arm continuously changes its posture.
Click the Stop button on the toolbar to exit.