Welcome to Transbot SE repository
3.5.Control PWM servo
Control PWM servo
Control PWM servo1. Experimental goals2. Experiment preparation3. Experimental results3.1jetson motherboard/Raspberry Pi 4B3.2 Raspberry Pi 51.4. Program source code4. Program source code
1. Experimental goals
Control the PWM servo platform on Transbot SE to rotate up, down, left, right and back.
2. Experiment preparation
The position in the red box in the picture below is the interface of the servo gimbal. There are two servo interfaces in total. The black interface is GND, the red interface is the positive pole of the 5V power supply, and the yellow interface is the signal, marked X and Y respectively. Two servo interfaces.

The servos that control the left and right are plugged into the X interface, and the servos that control the up and down are plugged into the Y interface. The servo interface must be plugged in according to the color and cannot be plugged in reverse.

Transbot_Lib library function needed for PWM servo gimbal:
set_pwm_servo(servo_id, angle)Parameter explanation: servo control, servo_id: corresponding ID number: X = 1, Y = 2, angle: corresponding servo angle value
servo_id=[1, 2],angle=[0, 180]
Return value: None.
3. Experimental results
3.1jetson motherboard/Raspberry Pi 4B
Please view the course video.
3.2 Raspberry Pi 5
Enter docker
Note: If you have a terminal that automatically starts docker, you can directly enter the docker terminal to run the command, and there is no need to manually start docker
Start docker manually
xxxxxxxxxx./run_docker.sh
Run jupyter lab program
xxxxxxxxxxcd
xxxxxxxxxxjupyter lab --allow-root

Taking the current IP address 192.168.2.118 as an example, open the browser of Raspberry Pi 5 or enter in the browser of your computer
xxxxxxxxxx192.168.2.118:8889

Enter the jupyter lab login interface after pressing Enter, enter the password yahboom, and then click login

Enter the Transbot/Samples directory

Double-click the code you want to run

Restart the kernel and clear all output before running

Click on the first code block, then click the run button to start running one by one

1.4. Program source code
4. Program source code
Turn on the power of the Transbot SE robot, and open Jetson Nano or the browser of the remote computer to enter the Jupyter lab editor.
Reference code path: Transbot/Samples/3.pwm_servo.ipynb