Welcome to Transbot SE repository
3.7.Control motor
Control motor
Control motor1. Experimental goals2. Experiment preparation3. Experimental results3.1jetson motherboard/Raspberry Pi 4B3.2 Raspberry Pi 54. Program source code
1. Experimental goals
Control the forward and reverse rotation of the motor on the Transbot SE, and control the movement speed of the motor by controlling the PWM duty cycle of the motor.
2. Experiment preparation
The position of the red box in the picture below is the interface of motor MOTOR A on the left and motor B on the right. The motor interface has an anti-reverse connection function and can be connected to the motor using the Transbot SE motor cable.

Transbot_Lib library function needed to control the motor of Transbot SE:
set_motor(index, speed)Parameter explanation: Control the motor PWM pulse to control the motor speed. This function does not use the encoder speed measurement function.
index: Corresponding ID number: MOTOR_A = 1, MOTOR_B= 2, speed: Control the motor speed.
index=[1, 2], speed=[-100, 100]
Return value: None.
3. Experimental results
Since this function controls the rotation of the motor by modifying the PWM duty cycle, it can only be used to test whether the motor is working normally. This function is rarely used in actual use.
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 temp directory in docker to view it. 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

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/5.motor.ipynb