Cutebot & AI Lens Balls Tracking
19.4. Cutebot & AI Lens Balls Tracking#
To make a ball-tracking Cutebot with the AI Lens.
Steps to install the lithium battery pack:#
Assembly steps for bricks:
Steps of build-up:
Connections of the AI Lens:#
Connect the RJ11 cable with the AI Lens and the other end in Dupont connection to the circled place in the below picture (make sure you connect to the right connections).
Tips: the bricks holder here is flexible to be adjusted, we may manually adjust the angles of the AI Lens to meet the requirements of the functions that you want to achieve.
Click “Advanced” in the drawer to see more choices.
We need to add a package for programming. Click “Extensions” in the bottom of the drawer and search with “cutebot” in the dialogue box to download it.
We need to add a package for programming the AI Lens kit. Click “Extensions” in the bottom of the drawer and search with “https://github.com/elecfreaks/pxt-PlanetX-AI” in the dialogue box to download it.
Note: If you met a tip indicating that the codebase will be deleted due to incompatibility, you may continue as the tips say or build a new project in the menu.
In the “on start” brick, initialize the AI Lens and switch the function to the ball tracking mode.
In the “forever” brick, set to get one image form the AI Lens.
If there is a ball in the image, judge the size of the ball. If the size detected is below 100, it means the ball is far from the Cutebot, and then get the place of the ball with a value from the X aixs, if the value is below 80, it means the ball is on the left front side of the Cutebot, we need set the speed of the left wheel at 0% and the right wheel at 20% to make the car turn left. If the value of the X axis is over 144, it means the ball is on the right front side of the Cutebot, we need set the speed of the left wheel at 20% and the right at 0% to make the car turn right; or we set both of the wheels at 25%; If the size of the ball is not less than 100, it means the ball is near the Cutebot, now we set the Cutebot to stop moving.
You may also download it directly below:
The Cutebot goes for the ball if the AI Lens detects the ball and if the distance gets smaller enough, the Cutebot stops moving.