Read the current position of the servo

 

1. API Introduction

The API corresponding to reading the angle of a single bus servo is:

Arm_serial_servo_read(id)

Function: Read the current angle value of the bus servo.

Parameter explanation:

id: The ID number of the servo to be read, ranging from 1 to 6. Each ID number represents a servo. The ID of the bottom servo is 1 and increases upwards. The ID of the top servo is 6.

Return value: The current angle of the corresponding ID servo. When ID=5, the angle range is 0~270, and otherwise it is 0~180.

2. Start Docker

After entering the Raspberry Pi 5 desktop, open a terminal and run the following command to start the container corresponding to Dofbot:

Access Jupyter Lab within Docker:

3. Code content

Code path:/root/Dofbot/3.ctrl_Arm/4.read_servo.ipynb

Open the program file from jupyter lab and click the Run entire notebook button on the jupyter lab toolbar. Jupyter lab will print out the angle values of the six servos of the current robotic arm.

To exit, click the Stop button on the toolbar.