Automatic Catch Robot: Detects Distance
by RichardHuberjohn in Workshop > 3D Printing
4944 Views, 50 Favorites, 0 Comments
Automatic Catch Robot: Detects Distance
Goodmorning everyone,
I designed and built this robotic tennis ball launcher, intended to automatically catch and throw a projectile using data from sensors. This project was tailored to build experience with design and electronic integration of sensors, and to showcase how sensors can be used in real applications.
This Instructable highlights the design and build process of the robot, and while it is not the most polished product, I hope the documentation and process proves to be helpful to someone.
Supplies
Materials:
- 3D Printer Filament
- GT2 20 Tooth Pulley (5mm Bore)
- GT2 40 Tooth Pulley (5mm Bore)
- GT2 200mm Timing Belt
- 1" Rubber Grip Tape
- 5/16" Wooden Dowel
- (2x) 10x19x5mm Flanged Bearing
- (3x) 5x5mm M3 Standoff
- (4x) 5x50mm M3 Standoff
- (3x) 30mm M3 Bolt
- (10x) 18mm M3 Bolt
- 16mm M3 Bolt
- (4x) M3 Nut
- Small Cable Ties
- Double Sided Tape
- Mesh/Net Material
- ~1.5" Tennis Ball
Electronics:
- 540 Class Brushed DC Motor
- SG90 Micro Servo
- HC-SR04 Ultrasonic Sensor
- Micro Limit Switch
- Arduino Uno
- Adafruit Motor Shield V2
- (2x) Lever Wire Connectors
- Wires
Tools:
- 3D Printer
- Hex Screwdriver
- Wire Stripper
- Hammer
- Saw
- Cutting Instrument (Knife/Scissors)
- USB A to USB B Cable
Design Requirements
A large consideration for this project was using materials I already had on hand to reduce costs and time investment. So many design decisions are influenced by making a component I own work for this specific use case. However most of the components for this project are not difficult to purchase, and the design can also be modified to accommodate different constraints.
I also wanted to utilize my 3D printer to gain experience and dial in print settings. 3D printing also makes the project far more accessible to people who also have 3D printers, so I designed every part to fit on standard print beds without requiring supports.
For the functionality, the robot needs to be able to detect when it has a ball, hold the ball while spinning up a drum, and then release the ball to shoot it with variable power depending on a distance measurement. These functions come together to create a repeating cycle, essentially a game of catch.
However many of these function require data from the real world, and this is achieved through using sensors. Sensors come in many varieties, and we need two for this project. To measure distance, I chose to use an ultrasonic sensor, and to detect the presence of a ball, I opted to use a simple limit switch.
All of this has to be packaged into one compact unit, along with some quality of life features like a net to help catch balls, and accommodations for routing wires.
CAD
Designing the robot in CAD is a critical step to ensure components are laid out properly and is required for custom 3D printing. There are many CAD softwares to choose from such as Autodesk Fusion, Solidworks, and Onshape, any of which will work if you are designing this project yourself, or you can opt to download the STEP files below.
I designed the main body of the robot in two halves that connect in the middle. This makes printing the enclosed shell of the robot far easier, and isolates critical features to one side or the other. For example the ultrasonic sensor was designed to slot into the right side face, while the servo that holds the ball screws into the left side.
Prototyping
Before the CAD was fully developed, I decided to create a testbed to double check critical dimensions and functionality before the final prints. I printed the mostly complete right shell and temporary left shell with standard PLA at a low infill, however I did run out of filament during the print.
This protype still provided important knowledge though. I was able to test how the assembly went together and run the motor for the drum. Ultimately, I determined that I had to increase some hole diameters, increase the distance between the pullies, and lower the compression of the ball as it passes through the shooter.
Print Final Parts
After making adjustments to the CAD, I reprinted most of the parts using black SUNLU PLA+ 2.0 filament. This should make the whole assembly stronger, without drastically changing printing properties.
I also increased the infill percentage to 10%, which should provide plenty of rigidity while still keeping weight and material costs relatively low.
Assemble Drum
Starting with the most important component as it's what actually launches the ball, the drum consists of three main pieces, along with endcaps to mount it in place.
Begin by locating the GT2 40t pulley and pressing the side with the setscrews into the counterbore on the drum print. This should be a firm press fit, as it will transfer the torque from the pulley into the drum.
Then press a 5x50mm M3 standoff into the other end of the drum print until it is flush on the outside. This may also require some force with a hammer or other pressing technique.
Then wrap the drum in two strips of 1" grip tape. This will help carry the ball through by reducing slippage.
Finally, to prepare the endcaps, insert a 16mm and 30mm bolt into the endcap prints. On the 30mm bolt, thread on 3 5x5mm M3 standoffs, these will stabilize the 40t pulley.
Prepare Motor
To prepare the motor, locate the d-shaft adapter and press it onto the motor shaft, ensuring the rotation matches the d profile.
Then simply slide the 20t pulley over the adapter and tighten both setscrews until firmly affixed. One of the setscrews should be on the flat side of the adapter to properly transfer the torque from the motor.
*My adapter is still printed from regular PLA as it worked fine without any changes.
Attach Drum and Motor
On the right side shell, insert a 10x19x5mm flange bearing into the hole, along with the 30mm endcap.
Then locate the drum assembly and slide the pulley side over the standoffs and tighten the bolt until the endcap is solidly bolted to the drum. (Hold the drum in place while tightening so it doesn't spin in the bearing).
Slide the 200mm belt over the pulley and position it upwards to prepare it for the motor pulley. Then, while holding the motor, snag the belt with the pulley and pull the motor upwards to bolt it in with two 30mm M3 bolts. (Start with bolting one side of the motor then lifting the other side to fully attach it).
Insert Limit Switch
Locate the limit switch and ensure the ends of the wires are stripped, then insert them into the lever wire connector and lock them in place.
Then clip two more wires into the other end of the connector. This makes interfacing with the limit switch easier, as it now is attached to Arduino compatible pins.
Finally the limit switch and connect should slot snugly into the side of the right side shell. Ensure the wires fit tucked inside of the designated wire channels so the shell can slide together without interference.
Insert Ultrasonic Sensor
Start by bending the pins on the back of the sensor outwards, this prevents interference with the drum and makes wiring easier.
Then slide the ultrasonic sensor down the slot at the front of the shell until it is aligned. There is only one orientation that it can be inserted.
Attach Standoffs
Three 5x50mm standoffs are essentially the pins that hold the shell halves together. Insert them into their respective holes on the right side shell and secure them with three 18mm M3 bolts.
Attach Servo
Moving to the left side shell, the micro servo slides into a rectangular cutout that positions the arm at the correct spot to catch and release incoming balls.
Begin by feeding the servo wire through the hole at the bottom of the cutout, then pressing the servo in afterwards. The servo direction should be according to the side that the wires are on.
Then use an singular M2 screw to firmly secure the servo the the block in the left side shell.
Combine Halves
Slide the left shell onto the aluminum standoffs and carefully press the sides together, being careful to not pinch any wires.
Then install the three 18mm M3 bolts into the standoffs to solidify the entire assembly. And screw the last endcap into the left side of the drum.
Attach Net Rods
The net assembly serves to help redirect balls towards the opening at the top of the robot, and consists of two 150mm wooden dowels which I cut to size using a small saw.
After preparing the dowels, firmly insert them into the designated rod holders.
Then, insert 2 M3 hex nuts into the hexagonal slots on each side of the robot body. Afterwards, attach the rod holders to the outside of the shell using 4 18mm M3 bolts, which thread into the captive nuts.
Attach Net
I used this mesh/net material that came with the tennis balls, however there are a variety of solutions to create the actual net. It just needs to be supported by the net rods on either side.
I was able to stretch the material over both sides and slide it downwards the entire length of the rods. Then I used scissors to cut off the excess on the top.
Affix Electronics
To attach the Arduino with the Adafruit Motor Shield, I simply used a few layers of double sided tape. However some holes could easily be added to mount the Arduino using bolts.
I ended up flipping the orientation from what it is in the photo to help the limit switch wires reach the digital pins on the Arduino.
Add Feet
To add some grip to the bottom of the robot, cut some short strips of 1" wide grip tape to place in the divots on the bottom of the shell.
My tape was too thin to get proper traction so I added a layer of double sided tape in between the grip tape and robot to improve surface contact.
Wiring and Cable Management
Begin wiring by feeding four wires through the hole in the left side shell nearest to the ultrasonic senor and connecting them to the pins. Ensure the pins are bent far enough outwards to give the wires clearance above the spinning drum.
Connect the ultrasonic sensor to 5V, GND, and two digital pins for Echo and Trig.
Connect the limit switch sensor to GND and a digital input pin.
Connect the servo to one of the servo ports on the Adafruit Motor Shield.
Connect the motor to one of the motor ports on the Adafruit Motor Shield using the screw terminals.
Then restrict the wires using the built in cable tie holes in the left side shell, and by connecting separate wire bundles.
The motor shield also requires an external 12V source from a battery or power adapter when running the motor.
Write Test Programs
In order to ensure the functionality of each of the individual components, executing separate test programs is the safest option.
Check that the limit switch is returning a valid reading, you may have to check for HIGH or LOW on the digital input.
Check that the motor runs from the 12V power supply, and check whether FORWARD or BACKWARD is the correct direction.
Check that the servo functions accurately and determine what setpoints work for holding and releasing the ball. Note the position where the ball can rest on the servo arm while still activating the limit switch.
Check that the ultrasonic sensor is returning distance values that are accurate. You can also experiment with filtering before implementing on the final project.
Write Final Program
The final program consists of using logic to combine the functionality of the components you just tested.
The code should be checking for the limit switch input, which indicates the presence of a ball. It should be able to check the distance of a person standing in front of the robot using the ultrasonic sensor. Then, it can spin the motor to a desired speed based on the observed distance, before triggering the servo to release the ball, where the drum launches it forwards.
Full Operation
The robot is capable of shooting the tennis ball to a variety of distances, and all the components work together to feed the ball through the system.
The quick GIF showcases some of the robots capabilities, however note that in person the motor produces a substantial amount of noise. So perhaps it's less suitable for a relaxing game of catch.
Conclusion
In conclusion, this project was effective in providing experience with sensor design and integration. There were a few hurdles with printing and power draw from the motor. So if I were to redo this project, I would experiment with using a separate ESC for the motor, with better specs than the motor shield.
Another improvement I could imagine is utilizing a time-of-flight sensor for distance measurement and something like a beam break sensor for reliable object detection. However those sound like upgrades for a future project.
I hope this project was helpful and perhaps inspires you to take advantage of sensors in your own creations.