Auto-Tracking Turret
While being a member of the Autonomous Surface Vehicle team for Old Dominion University, one of the challenges for the Roboboat competition for 2013 was to have our autonomous boat find a set of rings on the side of a pond and have a device that shoots foam darts through the rings. After the competition I thought it would be a good challenge to make a turret, so I started designing and built a prototype turret.
While there were lots of ways to create the turret, I wanted to just quickly create prototype of a turret from parts that were readily available to me in both the team's intelligent machine lab and at my home. The advantage to this prototype was that we could begin writing code for the turret while the finalized design was being created smaller and machined to the specific needs of the boat (mainly focusing on the ease of integration with the boat hull and the weight).
The main parts that were necessary was the two motor and bearing assemblies which I took off of a past student's thesis boat that was being used to pivot two propeller shafts in a circular motion.
The main parts that were necessary was the two motor and bearing assemblies which I took off of a past student's thesis boat that was being used to pivot two propeller shafts in a circular motion.
After taking very rough measurements of the few components that were custom made I created some quick sketches of how the turret would be laid out in the quickest, easiest, and cheapest methods possible. Fabricating wood is much quicker for me to do myself than waiting for a machine shop and since this was only suppose to be a prototype I could justify a primitive appearance.
And following the rough sketches made during some extra boring lectures I drew a 3D model in SolidWorks. I have been using Autodesk Inventor since my first year of high school (about 6 years) so I really wanted to get used to some new software, which was much easier than I thought it was going to be.
I neglected some of the fine detail in the drawing to save some time and to avoid some of the frustration that comes along with using new software (when you have an alternative that would take less time).
I neglected some of the fine detail in the drawing to save some time and to avoid some of the frustration that comes along with using new software (when you have an alternative that would take less time).
After creating the drawing I finalized what I wanted for my dimensions and on my next visit to my parents home I went ahead and cut up some scrap lumber and cut some PVC rods for the shafts. I also got some bolts, washers, and nuts for the assembly that were especially useful when keeping the motor and bearing far enough away to create tension on the chain that connects the gears on both parts.
Using some leftover screws and wood glue I pieced together the main assembly. Even though I had four clamps, I still could have used another pair of hands.
Using some leftover screws and wood glue I pieced together the main assembly. Even though I had four clamps, I still could have used another pair of hands.
I decided that it would just be easier to mount the whole metal bracket to the bottom piece of wood, so I just bored spots for the screws that already were attached to the bracket and then I drilled out holes to thread the bolts into the board. I wasn't overly careful when I first started screwing in the bolts because I accidentally started to warp the board by over tightening the bolts.
I was planning on running the code through this PC104 but it turns out that it doens't have much processing power. OpenCV was struggling a bit on the machine so we just ended up running wire from the microcontroller to a laptop. Our thought was to try to control the entire thing with a quad-core UDOO.
The center box that houses one of the motor-bearing assemblies was created to have lots of extra room in order to help balance the turret. Once I added all the components (mainly the big lead acid battery) I could get it to be standing straight for the most part. If it had very quick acceleration from the motors it may have had issues with balance but since we had only under-powered motor drivers at the time to control the large stepper motors it was not a problem.
The last few weeks of the semester were caotic so rigging up the control of the turret was put on hold for a bit. I made a suggestion to my friend, and ASV team member Aaron Casson, that we should just go all out and finish the prototype after our last final exam of the semester (which was difficult to not keep working when you're that close).
Another friend of mine who had just recently graduated with his electrical engineering degree had wrote some code to detect rings for the 2013 competition so after our last final was over Aaron and I decided in our zombie-like sleep deprived state to finish up the turret, or at least make impressive advancements on the prototype.
We cranked the bottom stepper motor driver to give full juice since it has to rotate all of the weight. Aaron was concerned about overheating of the driver so he added little heat sinks and I created a fan mount with some spare bolts and duct tape (it even had a a diagonal piece to prevent wires getting into the fan). Later I looked up the data sheet and it showed that the drivers did have a protective shutdown in the case that it overheated so it probably would have been fine without the extra cooling.
The last few weeks of the semester were caotic so rigging up the control of the turret was put on hold for a bit. I made a suggestion to my friend, and ASV team member Aaron Casson, that we should just go all out and finish the prototype after our last final exam of the semester (which was difficult to not keep working when you're that close).
Another friend of mine who had just recently graduated with his electrical engineering degree had wrote some code to detect rings for the 2013 competition so after our last final was over Aaron and I decided in our zombie-like sleep deprived state to finish up the turret, or at least make impressive advancements on the prototype.
We cranked the bottom stepper motor driver to give full juice since it has to rotate all of the weight. Aaron was concerned about overheating of the driver so he added little heat sinks and I created a fan mount with some spare bolts and duct tape (it even had a a diagonal piece to prevent wires getting into the fan). Later I looked up the data sheet and it showed that the drivers did have a protective shutdown in the case that it overheated so it probably would have been fine without the extra cooling.
The cannon device made from PVC and a solenoid was the design solution for firing the nerf darts during the 2013 Roboboat competition. Unfortunately we did not have a turret to aim at the target but instead loaded several barrels with four nerf darts each and attempted a "spread-shot" towards the rings which may have worked if we did not have faulty code.
We used the 12V lead-acid battery to power the system. We ran serial commands from a program built in C++ to the Arduino on the turret which controlled the output to the stepper motors. Later I added a remote control that the Arduino would interpret and use to control the motor output direction and speed. There was a relay on top of the battery that allowed for us to "trip" the switch that opened the solenoid that held back the pressurized PVC tube, effectively it was a fire switch. The PVC could hold quite a bit of pressure, we stopped after 90psi but it could have kept going if we were willing to risk PVC shrapnel. The camera was being controlled with a later 2013 build of openCV and the camera itself was a $2 webcam from eBay that Aaron figured out the camera pin-out and spliced into a standard USB wire. The switches on the turret were originally created for debugging purposes and act mainly as manual control of the direction of rotation for each stepper while the larger switch is used to fire the cannon and the single black toggle is used to kill master power to the turret.
The logic of the code was fairly simple aside from the algorithms used in the openCV libraries that most people just take for granted. The openCV function would search for a target of some sort, we test both a ring and a color. Once it would find the target it would try to center the target in its field of view, or at least very close to the center but get's slightly adjusted when we calibrate for the cannon trajectory path. If the target is to the left or right of that calibrated center then the C++ function sends the bits through a serial connection to the Arduino which then interprets the data as which direction it wants to move the lower stepper. The same process is followed for adjusted up or down with the upper stepper. One the target is in the correct location for x_amount of time then the arduino flips the relay actuator which releases the pre-pressurized PVC cylinder to fire the cannon with the nerf darts.
Unfortunately a day after we started fine tuning the turret we found out that the ring challenge was no longer a part of the Roboboat competition for the next year, so sadly we had to start working on new challenges for the team.
**Update** After a few weeks of seeing the turret just sitting around we decided to clean it up the wiring a bit so that we could do some more tests (really just playing at this point).Here is an album..
The logic of the code was fairly simple aside from the algorithms used in the openCV libraries that most people just take for granted. The openCV function would search for a target of some sort, we test both a ring and a color. Once it would find the target it would try to center the target in its field of view, or at least very close to the center but get's slightly adjusted when we calibrate for the cannon trajectory path. If the target is to the left or right of that calibrated center then the C++ function sends the bits through a serial connection to the Arduino which then interprets the data as which direction it wants to move the lower stepper. The same process is followed for adjusted up or down with the upper stepper. One the target is in the correct location for x_amount of time then the arduino flips the relay actuator which releases the pre-pressurized PVC cylinder to fire the cannon with the nerf darts.
Unfortunately a day after we started fine tuning the turret we found out that the ring challenge was no longer a part of the Roboboat competition for the next year, so sadly we had to start working on new challenges for the team.
**Update** After a few weeks of seeing the turret just sitting around we decided to clean it up the wiring a bit so that we could do some more tests (really just playing at this point).Here is an album..
Here is a video of the turret locking onto a tennis ball and following it around for a few seconds:
And another video of Aaron trying to hold back the turret while aiming at the electrical engineer mentioned earlier, Haole Guo. Unfortunately the camera has a hard time picking up the first few nerf darts because of their speed: