Dodge - ESP32 Cam Based Tripod
by hannu_hell in Circuits > Robots
6355 Views, 87 Favorites, 0 Comments
Dodge - ESP32 Cam Based Tripod
DODGE is a novel design of a tripod which is powered by an ESP32 Cam module. The third leg (support leg) of the tripod is positioned in the middle which allows support when positioning the legs when moving. It can also rotate 360 degrees owing to the servo based at the bottom of the support leg. The robot has six servos in total and allows for a range of motions given the fact that the ESP32 Cam module has limited GPIO pins available when the camera on the module is in use. DODGE as the name implies moves sideways and also can move vertically up and down.
Dodge can be used indoors to monitor around your house and can be controlled with your phone or computer by connecting to its WIFI access point. Once connected you have access to control its motion along with the live camera footage from the camera mounted on its head. It uses two batteries - one to power the servos and the other to power the ESP32 module. The two batteries allow for stable operation of the robot as using the same battery for powering both the servos and the ESP32 module created some glitches in the camera feed but more on that later.
As for future plans I hope to use the camera footage from Dodge to stream to a raspberry pi for image recognition, face detection and so on and can also control its movements. The 3D model of Dodge was designed using Fusion360 and 3D printed. Since Dodge is small all the parts can be printed fast without using up much filament.
Supplies
- Emax ES08MDII Digital Servo Motor x 6 link
- Aluminum Rod (Length-200mm, Diameter-4mm) x 1 link
- SS Pins or Aluminum Pins - You can cut the aluminum rod into 10mm length pieces also if you wish (4mm Diameter x 10mm Length) x 4 link
- ESP32 Cam module with MB for type-C USB (CH340) connectivity x 1 link
- 7.4 V 800mAH 15C Lipo Battery (Length-57mm x Width-30mm x Height-15mm)
- 5V 800mAh Lipo Battery (Length-50mm x Width-31mm x Height-11mm)
- 2.5M Threaded inserts x 8
- 2.5M hex screws (Length-15mm) x 4
- 2.5M hex screws (Length-25mm) x 4
- 2.5M hex screws (Length-10mm) x 4
- 3A Adjustable Buck Convertor Module x 1 link
- Barrel Jack x 1 link
- Female Header Pins (8 sockets) x 2
- LM4UU Linear Bearing (Inner Diameter-4mm, Outer Diameter-8mm, Length-12mm) x 2 link
- Small Radial Bearings (4mm Inner Diameter, 7mm Outer Diameter) x 4 link
- Electrolytic Capacitor (10V, 1000uF) x 1
- Electrolytic Capacitor (10V, 470uF) x 1
- Generic Perf Board (50mm x 50mm) x 1
- 2mm normal screws x 4
- 28 AWG Wires for extending servo wires(Black, Red, Yellow) x 1
- Spiral Wire Wrap (Diameter-4mm) x 1 link
- Slide Switch x 1 link
- Super Glue x 1
- Old Mouse Pad or Heat Shrink for creating friction between feet and ground
- Hand Saw or Dremel x 1
- 3D Printer x 1
- 3D printing filament x 1
3D Model
The legs of the robot after printing were assembled using the hex screws and the servo horns provided with the servos. Some of the parts of the body were super glued in place but I have provided aligning features in the design so that you can glue the rack and pinion assembly and mount the pinion without difficulties allowing for optimal meshing between the rack and pinion. Printing smaller parts reduced complexity in printing and also allows easy assembling of the parts. The servos that fit in place have a clearance of 0.2 mm for an easy fit.
Lower Legs
The legs are designed in two parts which are the Lower and Upper Legs. The servo horns are pressed into the cutouts on the lower legs before assembling the Upper Leg. The bottom of the Lower Legs have holes to fit in the feet. The hole located opposite to the servo horns is for pushing in the SS/Aluminum pins through the radial bearings on the Upper Legs. The Upper leg with the servo assembled can be pushed into the servo horn with a little bit of force ensuring a gap of 1 mm on the opposite side. The SS/Al pins will be flush with the outer surface of the Legs when pushed all the way in.
Upper Legs
The Upper Legs are designed with cutouts to fit in the servo horns that connect the Shoulder servo and fastened with 2mm normal screws. The small radial bearings fit opposite to servo horns that connect the Lower Legs to the Upper Legs. This ensures that the legs don't move out of place and provide stability in rotation when moving. Once the bearings are press fitted the servo can be mounted in the bottom part of the Upper Legs and screwed in place with the mounting screws provided with the servos. Make sure to note the rotation angle of the servos before assembling the Lower Legs. The 90 degrees position of the servo on the Upper Leg should make the Lower Leg parallel with the Upper Leg. The cutout hole allows easy screwing of the screws and ensures correct positioning when assembling.
Feet
The feet are designed with cutouts to fit 20mm Length Al rods for added strength. The 200mm Length, 4mm Diameter Aluminum rod can be cut into two 20 mm pieces and the rest of the rod will be later used for the rack and pinion assembly so make sure to leave it aside for now. After fitting in the Al rods into the feet it can be pushed in through the holes located at the bottom of the Lower Legs with some super glue to keep it in place. Heat shrink can be used to glue to the bottom of the feet to create traction when moving. I used an old mouse pad cut to the shape of the bottom of the feet and glued it in place. This created the necessary friction but you can use any thing that is available.
Shoulders
The Shoulders connect the legs to the Top Plate where the head and the battery packs are placed. The threaded inserts are pushed in place with the help of a solder iron to the holes on the top of the shoulders. Note that there are 3 holes but only two need to be inserted with the inserts. Once again insert the radial bearings in the cutout slots and then fit in the servos and screw them in place. Make sure the servo angles allow for complete rotation of the legs before screwing them in. When the servo is in 90 degrees position the Upper Leg should be 10 degrees below in the stretched arm position which will allow it to move all the way down and not as much upwards. The legs can then be assembled to shoulders.
Support Leg
The Support Leg consists of the Rack and Pinion assembly and the pinion is driven by a servo. Another servo is placed on the support foot for Dodge to turn 360 degrees. Since the servo used has a range from 0 to 180 degrees, Dodge is able to raise the support foot and turn the foot 180 degrees and then lower its foot to the ground to give it the ability to rotate the other half. This is a nifty way to achieve 360 degrees turn given the limitation of a single 180 degree ranged servo.
One end of the Rack is fitted onto the slot in the Collar with some super glue. The lower end of the Collar has a gear profile cutout to slot in the Coupler Gear which is then screwed to a round servo horn which comes with the servo. The servo is then placed in the support foot and screwed in place. The support foot also needs friction with the ground so the old mouse pad came handy as it was cut to shape and glued to the bottom of the feet.
The Bearing Holder has two holes on either side to fit in the linear bearings and then its glued in place to the cut slot behind the Rack. There are aligning marks on the Rack and the Bearing Holder allow for precise assembly and should be aligned before gluing in place. The Bearing Frame needs to be glued to the bottom of the Top Plate. The aligning holes on the bottom of the Top Plate and the holes on the Bearing Frame allow for easy assembly. Once the Bearing Frame is glued in place, the aluminum rod needs to be cut into two pieces of length 60mm. These rods go through the linear bearings allowing sliding motion and restricting motion in other directions. The servo that drives the pinion can be screwed in place on the bottom of the Top Plate. The round servo horn that comes with the servo is fitted into the slot behind the pinion and then two 2.5M hex screws(10mm Length) is used to keep it in place. The pinion can now be pushed into the servo head and screwed in. Once again make sure to position the servo to the 90 degree position (mid position) and screw the pinion with the Rack positioned in the middle although the servo will not have to move its full range to allow lowering and lifting of the support leg. You can always adjust this after assembling as well.
Head and Battery Packs
The Head consists of two parts - Front and Back and the Perf board which houses the ESP32 Cam module is sandwiched between the Front and Back of the Head. Four holes are drilled on the Perf board after aligning the Head. Four threaded inserts go into the holes on the Back part of the head and four M2.5 (25mm Length) hex screws are used to fasten the Front Head, Perf board and the back part of the head.
The Battery Packs are glued on either side with the heavier secondary battery pack positioned on the left and the lighter primary battery pack placed on the right. The lighter pack is placed on the right as more weight is shifted to the right due to the additional placement of the servo which drives the pinion. Once the electronics are sorted out, the wires from the servos can be routed in through the holes in the back of the head.
The Buck Converter is placed inside the Buck Converter housing and then glued behind in between the Primary and Secondary Battery Packs. Make sure to adjust the output voltage to 5V when 7.4V is supplied as input before sealing it inside the housing.
Wiring
The Perf board was cut to a dimension of 35 x 50 mm and then the female header pins soldered to the board. Two rails were created by using solder to serve as GND and VCC (Power for servos). The sliding switch should be soldered on the Perf Board after checking the cutout slot on the front of the Head. This will allow access to the switch when the head is closed up. The connections were made to the respective pins and wires were routed out from the holes. By doing this I will be able to solder the wires to the servos later on knowing well how much length of wire to allow for the legs to move freely.
Servo connections are as follows:
- Support Feet Base Servo - IO 4
- Right Leg Top Servo - IO 12
- Left Leg Top Servo - IO 13
- Right Leg Bottom Servo - IO 14
- Left Leg Bottom Servo - IO 15
- Pinion Servo - IO 2
Both the ESP32 Cam and Servos are supplied power via capacitors to smooth out any voltage spikes and avoid jitter in servo movements and glitches in camera footage. The servos are connected to power via a 1000uF capacitor and the ESP32 Cam is powered via a 470uF Capacitor. Initially I tried powering both the servos and the ESP32 with the 7.4 V battery and there were power outages in the ESP32 module and sometimes caused glitching in the camera feed. I presume its because of voltage spikes and irregularities in the power lines. After isolating the power things worked as expected. Also adding the capacitors did show a noticeable difference.
Kinematic Analysis
In order to speed up the development process a kinematic analysis of the motion is always useful. Since we are concerned with determining the angles the servos have to move to position the tip of the Lower Leg it is useful to use an inverse kinematic model. In this case our main objective is to determine the angles theta 1 and theta 2 which are the servo angles for the Upper Leg and Lower Leg respectively and not so much concerned of the angle the tip of the Lower Leg makes with respect to the vertical axis (Y) as the round design of the feet tip would anyway provide sufficient contact with the ground irrespective of the angle.
Below is a block of python code that was used to determine the angles upon deriving the equations. In my case after adding the friction pads to the feet the link lengths L1 and L2 are determined to be 42mm and 72.5mm respectively. The known variables are L1, L2, x and y and what needs to be calculated are the angles theta1 and theta2.
import math
x = 30
y = 80
L1 = 42
L2 = 73.5
z = math.sqrt((x**2)+(y**2)) # -> Eq 1
theta2 = math.degrees(math.acos(((x**2) + (y**2) - (L2**2) - (L1**2))/(2*L1*l2))) # -> Eq 2
Psi = math.degrees(math.acos(((L1**2) + (z**2) - (L2**2))/(2*L1*z))) # -> Eq 3
alpha = math.degrees(math.atan(x/y)) # -> Eq 4
theta1 = Psi + alpha
Phi = theta1 - theta2 # -> Eq 5
print(f'Theta 1 = {theta1}')
print(f'Theta 2 = {theta2}')
print(f'Phi = {Phi}')
STL and Code
Some important points to note is when uploading code to the ESP32 Cam module you need the ESP32 Cam-MB which has the boot loader to upload code. You need to press the IO 0 button on the ESP32 Cam-MB and then the RST button on the ESP32 module to put the board to accept code uploads. Apart from that you will also need to download ESP32Servo library by Kevin Harrington/John K. Bennett from the Library manager in Arduino IDE.
In the code file update to your desired password to connect to Dodge and once the code has been uploaded you can see it visible as Dodge-Tripod on the WIFI network. After you upload the code make sure to reset the ESP32 Cam module by pressing the RST button on the back. Connect to Dodge-Tripod and then open up a browser and in the url enter 192.168.4.1 on your phone/computer to connect to the Dodge Control App. Make sure to power up the Primary and Secondary Batteries and then your good to go.
Downloads
Conclusion
After having done the build its worth noting that there is a bit of a wobble in the support leg when the whole weight of the robot is on it as I've used a plastic servo horn on the servo placed on the support foot. It could perhaps be remedied by using an aluminum horn which would prevent it from deforming or warping.
Dodge is a small robot that can be used indoors and with its capability to capture video allows me to monitor around the house. It could be used as a desk robot as well. As mentioned earlier my next goal is to stream its video data to a Raspberry Pi for face detection and image recognition . Apart from that it can be programmed to do many other moves in addition to what's already done and I hope to try it and will make sure to update this instructable if I get to do so.