Collision Advoidance

From Waveshare Wiki
Jump to: navigation, search

Collision_avoidance

In this example, we'll collect an image classification dataset that will be used to help keep JetBot safe! We'll teach JetBot to detect two scenarios free and blocked. We'll use this AI classifier to prevent JetBot from entering dangerous territory.

Step 1. Collect data on JetBot
  • Access JetBot by going to https://<jetbot_ip_address>:8888, navigate to ~/Notebooks/collision_avoidance/.
  • Open data_collection.ipynb file and following notebook.
  • This model was trained on a limited dataset using the IMX219-160 Camera with wide-angle attachment.
  • You need to put the JetBot to different spaces for collecting data as more as possible.
JetBot AI Kit Manual 13.jpg
  • The more scene data the car collects, the better the obstacle avoidance effect will be. Therefore, it is very important to obtain as much different data as possible for the obstacle avoidance effect. Generally, at least 100 pictures are required for each situation.
  • Finally, run the program to package the pictures. After packaging, a dataset.zip compressed file will appear in the current directory.
JetBot AI Kit Manual 14.jpg
Step 2. Train neural network
  • Access JetBot by going to https://<jetbot_ip_address>:8888, navigate to ~/Notebooks/collision_avoidance/
  • Open and follow the tain_model.ipynb notebook.
  • If you already have the dataset.zip file you just compressed, you do not need to run this statement to decompress it, otherwise you will be prompted to overwrite the existing file.
JetBot AI Kit Manual 15.jpg
  • When the program runs here, the alexnet model will be downloaded, and the download time is a bit long. After downloading the program, an alexnet-owt-4df8aa71.pth file will appear in the /home/hetbot/.torch/models directory.
JetBot AI Kit Manual 16.jpg
  • Finally, run the program to train the neural network, and the running time is relatively long. After the training is completed, a best_mode.pth file will appear in the current directory.
JetBot AI Kit Manual 17.jpg
Step 3. Automatic Obstacle Avoiding
  • Access JetBot by going to https://<jetbot_ip_address>:8888, navigate to ~/Notebooks/collision_avoidance/
  • Open and follow the live_demo.ipynb notebook.
  • After running the program, the camera live image and a slider are displayed. Intermodulation represents the probability of encountering an obstacle, 0.00 means that there is no obstacle ahead, and 1.00 means that the obstacle ahead needs to be turned to avoid.
JetBot AI Kit Manual 18.jpg
  • Here, adjust the speed a little to avoid hitting the obstacles too fast. If obstacle avoidance cannot be achieved in some places, it is recommended to collect more data.
JetBot AI Kit Manual 19.jpg
  • [Note] Some statements may take a long time to run. There is a program running promptly in the upper right corner of JupyterLab. When the small dot is black, it means the program is running, and white means it is idle.
JetBot AI Kit Manual 20.jpg