Control bus servo

1、Experiment goal

Use the slider to control the movement of the robotic arm, and read the angle value of the current joint of the robotic arm.

2、Experiment preparation

The position of the red box in the picture below is the interface of the bus servo. Servo1 and Servo2 interfaces are parallel interfaces, which have the same function. When connecting the robot arm, you only need to connect any one of them.

The red indicator D7 on the right is the indicator for the voltage of the robotic arm. If the indicator D7 is always on, it means that the power supply of the robotic arm is normal. If the indicator D7 is off, it means that the power supply of the robotic arm is abnormal.

image-20210906121708450

The Transbot_Lib library functions needed to control the bus servo have the following contents:

Robotic arm control reference system: set upright and upward clamping state, three servos are 180 degrees, 7/8 clockwise (down) to decrease, counterclockwise (up) to increase, and clamp loose to decrease , The clamping is increased.

Parameter explanation: control a bus servo, s_id: corresponding ID number: 7/8/9, run_time which is the running time of the servo, within the effective range, the smaller the time, the faster the servo rotates, the unit is milliseconds, and the minimum value is 0.

s_angle: Corresponding to the angle value of the servo, 7:[0, 225], 8:[30, 270], 9:[30, 180]

servo_id=7, s_angle=[0, 225]

servo_id=8, s_angle=[30, 270]

servo_id=9, s_angle=[30, 180]

Return value: None.

Parameter explanation: control three bus servos, angle_7, angle_8, and angle_9 control the angle values of the three servos, angle_7=[0, 225], angle_8=[30, 270], angle_9=[30, 180], run_time which is the running time of the servo, within the effective range, the smaller the time, the faster the servo will rotate, the unit is milliseconds, and the minimum value is 0.

Return value: None.

Parameter explanation: Turn off/on the torque of the bus servo, enable=[0, 1].

enable=0: turn off the torque of the servo, you can control the servo by hand, but the command cannot control the servo; enable=1: turn on the torque, servo can be controlled by command, and you can control the servo by hand.

Return value: None

Parameter explanation: read the angle of the bus servo, s_id represents the ID number of the servo to be read, s_id=[7-9]

Return value: Returns the current angle of the input ID, and returns -1 when reading error.

Parameter explanation: read the angles of three servos at one time [xx, xx, xx], if one of the servos is wrong, the one bit is -1

Return value: [angle_7, angle_8, angle_9]

 

3、Experimental operation and phenomenon

Please the video.

Note: Before running the program, please turn the three degrees of freedom of the robotic arm to the vertical upwards and then connect the robotic arm. Otherwise, the robot arm will stand up automatically when running the program for the first time.

4、Code

Code path: /home/pi/py_install_V3.2.5/py_install/Samples/6.arm_transbot.ipynb