Introduction: A.B.C(Automatic Ball Collector)
Been tired of picking Ball while playing Tennis, this is what you will Love. This is Tennis Ball Collector which is programmed to collect a ball in a tennis court, allowing you to focus on your game only.It sees the world around it through a camera where image processing has a vital role to play.Though this is in it's early phase but after some evolution, it will be ready to be brought in court.
Step 1: Parts Required
6.Tin plate(4cm width)(2 Nos)
7.small wooden cube block(2 Nos)
8.screw( approx 20)
9.Motor Driver(L298N) (2)
10.Raspberry pi(preferably pi 3)
12.Li po battery(12 v)
Step 2: Building Chassis
Start by creating the frame which is made from a piece of acrylic sheet. According to your required size of bot or( 40 cm X 40cm)cut the acrylic sheet.You can use a hack saw to cut sheet.Mark a line parallel to width approx 5 cm along the length. Use a heat gun to fold the 5 cm strip to make it incline. Heat it so it has (1mm-2mm) ground clearance. Drill holes in the sheet to attach motors at the positions shown in fig. attach wheels on the motors too.
Now it's time for adding flap. Cut an acrylic sheet of appropriate size so that it could collect the ball easily. Stick two wooden blocks of size as shown and at the position as in fig. Put two tin strips to the block with the help of nail. Carefully place the tin strips according to the size of the flap you have cut.Place two motors at the ends of tin strip along with motor brackets. Drill holes to attach motor. Attach motor brackets on a wheel of appropriate size as shown in fig. Now drill holes in the flap to attach it to brackets. Here we have completed the chassis of the bot.
To store the balls you need something like a basket. With the plastic pipes you can make a frame as shown and mount it on chassis with the help of zip tags. You can use any rectangular frame according to your wish to make a basket. Cut an acrylic sheet and tie it to the frame using zip tags.
Step 3: Mounting the Electrical Components
Install two motor drivers, a raspberry pi and a web cam as shown in fig. Use double side tapes to attach components.
Step 4: Electric Connections
Do the connections as shown in fig.use jumper wires to make connections between pi and motor drivers.
connect only motors at back to upper motor drivers.connect right motors(facing bot from front) to out3 and out4 of upper motor drivers.similarly connect left motors to out1 and out2. li po is connected to upper motor driver on pins which is connected to lower motor driver.
Step 5: Logic for Detecting and Collecting Ball
Raspberry pi receives an image from webcam. We have set the image size to (450 X 300).You can consider screen as cartesian coordinate with centre at the top left corner.it is coded to get coordinates of the centre of the ball.
If x coordinate is in the range of 130 to 170 pin out 18 and 35 will be high while 16 and 37 will be low, this will make the bot to move forward. if x is less than 130 then the bot will have to move right for that pin 18 will 37 will be high while 16 and 35 will be low, this will make it move right. Similarly, pin commands are given for left movement.
In an else case when no ball is detected a clockwise rotation is made by pin out for the right turn. The bot will rotate until it detects a ball. also set a 5 sec time limit for the bot to stop if it doesn't detect any ball.
Step 6: The Code
Here is an attached code that we have used.