Target Line Patrol
From Waveshare Wiki
JetBot User Guide
- Log in JupyterLab
- Motor Driver
- Gamepad Control
- OLED Display
- Automatic Obstacle Avoiding
- Target Line Patrol
- Main Page
Step 1: Collect Data on JetBot
- In this chapter, we also need to use the steps of collecting data, patrolling, and running autonomously to realize the function of autonomous patrolling.
- Enter http://<jetbot_ip_address>:8888 in the browser address bar to connect to the car and find Notebooks/road_following/. Open the data_collection.ipynb file.
- After running the program, a demo video on youtube will be displayed.
- When the program runs here, the test image of the current camera will be displayed. The image on the right shows a green dot and blue line. Used to indicate the route the car should travel on. To facilitate subsequent operations, we will open the output window with a new window.
- The following procedure is similar to the gamepad control chapter. Modify the index to the label corresponding to the actual handle. Modify axes to the keys to be controlled.
- [Note] The axes button here must be simulated by Wie, that is, decimals can be output. If you use the gamepad we configured, you need to press the HOME button to switch the mode. Make the two indicators on.
- Modify the button value and set the corresponding button as the button to take a picture.
- Next, start collecting data, place the car at different positions on the line, control the arrow keys of the gamepad, and drag the green dot to the black line. The blue line is the direction in which the car should run. Then press the button to take a photo to collect pictures. Collect as many pictures of various situations as possible, count indicates the number of pictures that have been taken.
- [Note] It may be inconvenient to use the gamepad to control the position of the green dot. You can change the position by dragging the two sliders of steering and throttle.
- Finally, run the program to save the captured picture, and generate a zip compressed file in the current directory.
Step 2: Train the Neural Network
- Enter http://<jetbot_ip_address>:8888 in the browser address bar to connect to the car and find Notebooks/road_following/.
- If you use the data from the mobile phone in the previous section, you don't need to decompress it, and the image files are already in the current directory.
- If you need to decompress the file separately, you need to change road_following.zip to the corresponding ZIP file name, otherwise it will prompt that the file does not exist.
- Download the neural model, and it may takes a long time.
- Finally, the neural model is trained, and the best_steering_model_xy.pth file will be generated in the current directory.
Step 3: Autonomous Line Patrol
- Enter http://<jetbot_ip_address>:8888 in the browser address bar to connect to the car and find Notebooks /road_following, open the live_demo.ipynb file.
- Run the program to load the model, and open the camera to display the image in real time.
- There are four parameters in the program. You can change the value of the parameters by dragging the slider. If you need to implement the line patrol function, you need to adjust the parameters according to the actual situation to make the line patrol effect better.
- This output shows the current operation of jetbot, x, y represent the predicted x, y value of the current image, which can represent the rotation angle. speed represents the jetbot straight-line speed, and steering represents the steering speed.
- The car will rotate at the end of running the program. Start the jetbot by adjusting the speed gain slider. [Note], the speed value should be as small as possible, otherwise the speed will be too fast and it will easily rush out of the line. When the jetbot runs along the line, but the left and right swing is too large, the value of steering can be reduced, so that the jetbot moves more smoothly and the swing is smaller.