How to make Robot Dog (40+ New Robot Dog Hacks 2019)

Robot Dog- How to make Robot Dog 2018

How to build Robot Dog in 2019

In this blog we build the robot dog from scratch, by using  Arduino UNO. This project, Robot Dog, is split into three parts to balance the length of each section.

Robot Dog- How to make Robot Dog

 

 

 

Prerequisites

To minimize the cost of robot dog, while also trying to teach you that sometimes household items can be used in creative ways as materials for a project, we will be using ice cream sticks to create the chassis.

The rest of the components needed for this project are as follows:

  • 1x Arduino MEGA 2560
  • 1x USB cable A to B (also known as the printer cable)
  • 12 x 9g Micro servos (2+ extra servos recommended)
  • 1x Breadboard
  •  40x Male-to-male connecting wires
  • 20x Male-to-female connecting wires
  • 20x Ice cream/popsicle sticks
  • 1x Wood glue
  • 1x Ruler/measuring tape
  • 1x Regular-type screwdriver
  • 1x Multimeter
  • 1x 7.4V (2 Cell) 2200 mAh (or above) LiPo battery
  • 1x 3A UBEC (Universal Battery Elimination Circuit)
  • 1x XT60 male
  • 1x 7.4V 500 mAh LiPo battery
  • 1x Female JST connector
  • 1x LiPo battery charger
  • 1x Pack of rubber bands
  • 1x Pack/roll of double-sided tape
  • 3x Insulating tape (different colors)
  • 1x PC with a microphone
  • 1x Proto board
  • 40x Male headers
  • 1x Soldering kit
  • 1x Thumb pin or needle
  • 1x Pack of paper clips
  • 1x Pliers
  • 1x Wire cutter
  • 1x Cutting blade

You will also need the following software:

• Putty (terminal)

• BitVoicer (speech recognition)

Since the shape and size of ice cream sticks will be different in different parts of the world, there would be the need of strengthening the sticks, by sticking two or more of them together. Hence, it is suggested that you buy more sticks.

 

To give you an edge for planning purposes, here is the ice cream stick used in this project, along with its dimensions:

robot_dog

 

 

Introducing Arduino MEGA 2560

In this section, we will briefly go through the Arduino MEGA 2560 board. We will understand how it is different from the Arduino UNO, and also see why we chose this board over the Arduino UNO.

 

As mentioned before, Arduino MEGA 2560 is like a big brother of Arduino UNO. It is almost twice as long and way more powerful; Arduino MEGA 2560 is the successor of Arduino MEGA.

 

Unlike Arduino UNO, MEGA 2560 has 54 digital input and output pins.Before we get started with using the board, it is a good idea to use one side of the double-sided tape to cover the base of the board.

 

This is to ensure that, while in use, the Arduino does not get short-circuited if the base makes contact with a conductive material. Stick a double sided tape to the bottom of the Arduino like this:

 

On the right side of the MEGA (short for Arduino MEGA 2560), you will notice some missing labels.In the pin-pair shown in the preceding image, pins 22 and 23 are 5V pins, just like the one in the Arduino UNO.

 

Testing MEGA

We will quickly test MEGA to ensure that it works as expected, and to also give you a feel of the board. As always, plug MEGA to your computer by using the corresponding USB cable. Your computer will automatically search for the drivers and install them. If you see that the on-board LEDs are turned on, you know the board's connection is fine.

 

Launch Arduino IDE and, as you did in the very first blog, open the Blink example. It can be found in File → Examples → 01. Basics → Blink. Before uploading the program, you need to select Arduino MEGA as the board to be uploaded to.

 

To do this, go to Tools → Board → Arduino MEGA 2560.

Don't forget to choose the right serial port too. Only after that, you can upload the program. You should notice the on-board LED blinking. Once you have verified that Arduino MEGA works as expected, you are ready to move on.

We will go to the next part where we will learn about servos.

 

Understanding servos

survo

Just as we had done for the relays in the previous blog, this section will tell you what a servo is and how it is used. We will also test the servo by using a Blink like example. 

 

A servo (or servo motor) can be thought of as a motor, but with the ability to be controlled by its angular position. The servos we are using are 180 degrees micro servos, as shown in the following image:

arduino_survo

Servos come in different sizes and capacities. We could use the standard-sized servos that would give us more torque, but it would require more power. For this purpose, a micro servo will do the job.

 

In the preceding image, you may have noticed that there were three wires. The wires' colors correspond to the following:

  • Black/brown: GND
  • Red: 5V
  • Yellow/orange: Signal

A signal is basically how we control how much a servo turns (between 0 and 180 degrees). Let us now test one.

 

Testing a servo

test

Pick up a servo. It should come with different types of servo arms (the typically white-colored pieces that can be attached to a servo and then screwed together). For now, choose any arm and fix it onto the servo.

 

For this part, you need not screw it. However, if you think that the attachment is too loose, you can gently screw them together. The servo will look like this:

 

Try to physically, but gently, turn the arms. You will notice that you can freely turn the arm until you reach a certain point. This is a barrier that does not allow the servo to turn more than the preset 180 degrees.

 

If you turn it in the other direction, you will notice another barrier. You might also notice that the two barriers are not located exactly 180 degrees apart.

 

Do not worry about this. If you couldn't budge the arm when you first tried it on, you know that there is something wrong with your servo. Perhaps the gears inside are broken. You will either have to replace the gears, or simply use a new one. It is a good idea to test all the servos that you have purchased before proceeding.

 

In the following image, you will notice that, at the very centre, there is a white protrusion from the base of the top big gear. This protrusion is marked here:

Try moving the arms of your servo to achieve this position. This is the central position of the servo (90 degrees).

 

Programming a servo

programming

Programming a servo is almost as easy as programming an LED. Disconnect the MEGA USB cable. Go ahead and create the following circuit:

You will have to use the male-to-male connecting wires to connect the servo to MEGA.

The connections from Arduino to the servo are as follows:

  • GND → GND (black/brown)
  • 5V → VIN (power—red)
  • D09 → Signal (yellow/orange)

 

Plug MEGA back in. You may hear some sounds from the servoIt may even change its position. This happens, do not worry about it. Now, open the servo sweep program, which can be found at File → Examples → Servo → Sweep. Then, upload the program.

 

You will see that the servo rotates from 0 to 180 degrees and comes back to 0. It keeps repeating this action. In this program, look at the following segment inside the void loop:

for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees

{ // in steps of 1 degree

myservo.write(pos); // tell servo to go to position

in variable 'pos'

delay(15); // waits 15ms for the servo to

reach the position

}

 

Notice the line that mentions delay(15). This is a very important line of code. This delay controls the speed at which the servo turns. For now, it is a good idea to keep the minimum delay at 15. You can try adding another servo, and change the program accordingly to get the similar result. If you need some help, read the following section.

 

Using multiple servos

survo_motor

Let us now try to control multiple servos. This is our ultimate task to make the robot walk, isn't it? Since the Arduino MEGA has only three 5V pins, we will make use of a breadboard to make the connections. Create the following circuit:

 

The diagram depicts only four servos. Use the same pattern and connect all the 12 servos. As I said before, the number of wires running around is dizzying. Be careful while using the male-to-male connecting wires. Make sure that the ground, voltage, and signal wires go only to their respective destinations.

 

The connections are basically as follows (Arduino → Servos):

  • GND → GND
  • 5V → VIN
  • D22 → Signal Servo #01
  • D23 → Signal Servo #02
  • D33 → Signal Servo #12

Now, open the multi_sweep.ino file that should have come with this blog. Plug in your MEGA and upload the code. What do you see? If the Arduino MEGA didn't die, then you are one of the lucky ones. In most cases, you will notice that the Arduino MEGA simply turns off, turns itself back on, tries to run the program, fails to do so, and turns off again.

 

Do you know why this happens? The answer is, because the MEGA simply cannot handle the load of all those 12 servos running at the same time. At most, you can get away with running four servos at a time.

 

The total current required by all the servos when they are in action is simply not being supplied by the computer's USB port. You didn't just kill my MEGA, did you? No, don't worry.

 

The Arduino MEGAs are made to withstand much more than the insufficient current. How are we going to deal with this then? How can I control 12 servos, when I can't even power them?

 

Understanding power requirements

power

The basic necessity for any electro-mechanical device is a power source. Selecting the right power source for a particular device is an important trick of trade that every Arduino tinkerer needs to know. This is exactly what will be taught in this section.

 

Limitations of Arduino MEGA 2560

If you look at the specifications of Arduino MEGA 2560 on the Arduino website, you will see the following:

The important thing to note is the operating voltage that says 5V. This means that no matter how large of an input voltage you put in, the MEGA will always convert it to 5V.

 

In reality, it will be slightly less than 5V due to miscellaneous resistances. Another thing to note is the DC current per I/O pin that says 40 mA. An average micro servo has a voltage rating of 4.8 - 6V, and under heavy load, its current consumption can reach up to 1A that is 1000mA. So, it is surprising that MEGA could even power one servo sufficiently.

 

Choosing the right power source

Since we are making a robot dog and not something that is stationary, we are going to rule out using a wall power supply such as the one we used for the home automation project.

 

Also, since a computer cannot provide sufficient power to the Arduino, this is also crossed out of the list. This leaves us with batteries. However, there are so many batteries to choose from.

 

Okay, so we are going to use batteries. Yes. What kind? Since we are going to build a robot and we want to increase reusability, we will cross out nonrechargeable batteries. This leaves us with two popular choices:

• Rechargeable AA battery packs

• LiPo batteries (Lithium polymer)

 

As mentioned before, a micro servo requires 4.8 - 6V to work. Each servo also has a peak current draw of 1A, which makes it 12A in total. In reality, not all servos will be moving at the same time, so the 12A is just a maximum figure we are using for calculation purposes.

 

Each rechargeable AA battery has 1.2V. So, if you connect five of them in series, you would get a total of 6V that would suffice. Now, you also need to make sure that the current provided by the batteries is high enough for the servos to work.

 

Rechargeable AA batteries rated ~2000+ mAh batteries are readily available in the market and can also be used. The reason why we are using LiPo over AA batteries is because the former lasts longer and their performance to weight ratio is much greater.

 

However, if your future project doesn't have to take weight into account, you are free to use rechargeable AA batteries.

 

Now, let's talk about LiPo batteries. As mentioned in the prerequisites, we will be using a 7.4V (2 Cell) 2200 mAh LiPo battery. If we look at the specifications for this battery, we will see that the constant discharge rate is 20C. '20C' means that the battery can give off 20 times the current of its rated capacity.

 

This means that the battery will discharge 20 * 2200 / 1000 = 44 Amps at a constant rate. This is safely above the 12A required by the servos. The more the mAh, the longer the battery will be able to power the Arduino. A LiPo battery with an ever high mAh could be chosen, but that would increase the weight of the battery.

 

Since the battery is going to be carried by the robot, increasing the battery's weight increases the load on the robot. Also, there is only so much load those micro servos can endure. So, we have to create a balance between performance and weight. Hence, the 7.4V (2 Cell) 2200 mAh LiPo battery was chosen.

 

If you had noticed that there were two batteries mentioned in the prerequisites, you were correct. The first and more powerful one that we just talked about is going to be used only for the servos.

 

The smaller 500mAh battery will be used only to power the Arduino separately. The reason why we are not hooking up the 2200mAh battery to both the servos and the MEGA is because of the noise that is generated by the servos, which might cause unwanted disturbances in the MEGA.

 

However, didn't you say the servos are rated at 4.8-6V? You now want to hook up a 7.4V directly to it? Hold your horses. This is what we are ultimately going to do, but before that I must introduce you to our little friend, the 'UBEC'.

 

What this device basically does is, it drops the voltage (no matter how high it is) to 5 or 6V, depending on what is wanted without compromising the current. Since we are going to stick with 6V, move the jumper to choose 6V as the output. The UBEC should now look like this:

 

Solder the voltage and ground (red and black respectively) wires to the XT60 male connector. Make sure that the ground is soldered to the terminal with the chamfered side. Wrap some insulation tape around it to make sure no unwanted connections occur.

 

On the other side of the UBEC, the triple wires that look like that of a servo will basically act the same. Meaning, the black/brown wire represents ground and the red wire represents the constant 6V. The yellow/orange wire is the signal that is usually used in RC planes in receivers, but we will not make use of this wire.

 

Now, we are going to modify the previous circuit to ensure that all the servos work together without choking the MEGA. To do this, create the following circuit:

 

The main thing to notice is that only the servos are being powered by the LiPo + UBEC. The MEGA is still being powered separately. Ensure that the right polarities are connected to and from the battery and the UBEC.

 

One key thing is that the ground of the breadboard should be grounded to the Arduino MEGA. This is to establish one common reference ground.

 

Be very careful while handling the high discharge battery. Now, try running the multi_sweep program again. See the difference? The servos don't stop; they keep rotating. This means that their power requirements have been satisfied.

 

If a particular servo is not rotating, make sure that its wiring is done properly. Before going to the chassis construction part, connect the smaller 500mAh battery to the 2.1mm DC plug by using the female JST connector.

 

Now, unplug the MEGA from the computer and plug the 2.1mm plug into the MEGA's 2.1mm jack. It works! So, you have successfully used a portable power source to power the servos and the MEGA independently.

 

Building the chassis

chasis

A robot always comprises of three fundamental fields. They are mechanical, electrical, and programming. Working out the power requirements falls into the electrical aspect.

 

Writing code to control the motion of the servos falls under the programming category. Building and ensuring the chassis can support the weight of all the components that the bot is carrying is a mechanical challenge that will be addressed in this section.

 

Before rushing into the building phase of the body of the robot, let us take a moment to understand what we are even trying to build in the first place. We are making a robot dog. So, let us look at the nature and see how a dog stands and moves.

 

It is very hard for us to replicate the dog at its entirety. This is mostly because an actual dog uses strong muscles in its legs to walk (jump), and we are using servos. Now, let us look at the following bone anatomy of a dog to get a deeper look at the skeletal structure that allows the dog to walk the way it does:

 

Why are we doing this? Didn't I say that I will teach you as much as possible? This part of the project is called getting inspiration from prior art. This technique is used almost everywhere while designing a new product or simply creating a new design.

 

It is used in research papers and even patents. Sometimes it helps to use what has already been done before, either natural or artificial, to aid in creating a new design.

 

Let us focus on the legs. Notice how the joints are connected. To make things easier, we will simplify this anatomy to fit our needs.

 

We will modify the legs to just have a joint at the hip and the knee. This ensures that we won't have to use too many servos. Also, we are going to make the body (not including the legs) flat. Since we are using straight, flat ice cream sticks as the bones, we have to ensure that they are proportionate. Here is a basic side view of what we will be making:

 

This stick figure shows the side view of our robot. The bones will be made of popsicle sticks (ice-cream sticks), and the joints are simply servos.

 

The base will also be made of the same sticks, but it will be rectangular in shape, with its corners attached to servos; the central part will be made to support the other components such as the Arduino, batteries, and so on.

 

The hip joint (closer to the base) will comprise of two servos attached to each other so that the leg can be rotated in two axes (axis): the y-axis and the z-axis. The knee joint (conjunction of the thigh bone and the calf bone) is going to have a single servo that allows the calf bone to be rotated only in the z-axis.

 

Make a note of all the names of the joints and the bones in the preceding diagram. We will be using the same names during the construction and programming process, to label different joints/bones.

 

Now that we have a basic understanding of what we are going to build, we can proceed with its actual construction that will be covered in the next blog. You are free to change some details of the structure while we build it. However, you should be wary that this change may result in intricate changes you have to do for the code as well.

 

We have already finished the prior art part of this section. That subsection has inspired us to design our robot in a similar fashion of a dog. We will use this knowledge to build the body of the robot. This section may bring about nostalgic memories of art and craft projects that you did when you were little.

 

Sticks and servos

  • Start by clearing out some space on your workspace. Then, pick out two working servos and put on their arms.
  • Now, cut out a piece of double-sided tape such that it covers the base of the servo as shown:
  • Now, stick this servo onto the other servo at a 90 degree angle like this:
  • Use two rubber bands and stretch them around the servos, as shown in the following image, to strengthen their bond:
  • This is going to be our hip joint that was mentioned earlier.
  • Now, pick the straightest-looking ice cream stick, mark a line that is 7 cm from one end, and cut it:

 

Now, laying the two-sided arm of the servo at the edge of the cut stick, poke two thumb pins (or any other pin) such that one of them is at the center and another one is through the tiny hole along the arm of the servo, like this:

 

Now, remove the pins and the servo armUse the pins to make holes through the thickness of the stick where they were previously poked.

 

It is suggested not to hammer the pin into the stick because this may result in creating a crack along the length of the stick from the hole, which decreases the strength of the stick. Use a smooth rotational motion to push the pin through the stick.

 

To attach the servo arm to the stick, we will use a screw that goes along the axis of the servo, and also a paper clip. Most paper clips, such as the one shown in the following image are metallic with a plastic coating:

 

We only want the metallic 'wire' that lies inside the coating. To get it, unbend the paper clip to make a straight line. If it is hard to accomplish this with your fingers, you should use a plier to do this job:

  • Now, holding a plier in one hand and a wire cutter in another, remove the coating of the paper clip:
  • Fold this clip into half and cut it into two pieces at the fold:

 

Place the arm of the servo at the position corresponding to the holes that we made earlier. Push one of the halves paper clips through the hole on the arm (not the central one). Fold the clip in such a way that it tightly locks the arms in place. Use pliers to do this; be careful of the sharp edges:

  • Bend the straightened clip to fasten the servo arm to the stick:
  • Now, center the lower servo. Attach the servo to its servo arm counterpart, such that the stick is perpendicularly downwards:

 

Once you are satisfied with the positioning of the stick, tightly screw the stick to the servo using a screw that came with the servo. These are the approximate angles you could achieve with this arrangement:

 

Now, take another servo and apply a double-sided tape to cover its base. Stick this servo to the stick above, in such a way that the edge of the servo superimposes on the edge of the stick. Now, tightly bind this servo with rubber bands as well:

 

This servo serves as the knee joint. Now, take another ice cream stick, measure 6.5 cm from one end, and cut it at that mark. As we did before, take a servo arm and place it at the edge of the stick. This time, place it at the blunt edge. Use two pins to mark the locations of the necessary holes:

 

  • Make the holes using the pins, and attach the servo arm to it. Hold it in place by using the other half of the unsheathed paperclip. 
  • When you are okay with the angular movement of the stick, screw it tightly.

 

  • You have now created one of the four legs. There are three more to go. You can create another leg in exactly the same way as you did just now.

 

  • Next, you need to create the other pair of legs. The only difference is about the way the servos at the hip are joined together:
  • They are mirror images of each other. Now, create two legs with that joint.

When you are ready with all the four legs, we will be able to move on:

 

Now, the base is ready. All that is left to do is attach each leg to the corners of the base. To do this, mark points 2 cm away from each end. As we did before, place a servo arm and hold it in place using two pins, create holes in these points with the pins, and send an unsheathed paper clip through the noncentral axis hole and bind the arm in place. 

 

In your case, the arms will look identical. Do not worry about how they look. In this project, I chose different arm shapes to differentiate between the front and back servos.

 

You will soon realize that the number of wires running around will get real confusing, real quick. Now, all we have to do is attach the legs. For our purposes, we are going to make the calf bone (stick) outward. This should give the robot enough balance to stand.

 

Completing the circuit

Now that we completed building the chassis (most of it at least), we can move on to the electrical part of the project. This involves connecting all the servos to the Arduino MEGA; this is exactly what this part entails.

 

"However, didn't we already do this in the previous section?" Yes, but to be more effective, we are going to firstly label the servos and create a circuit that drastically decreases the number of wires that we need.

 

Labeling the servos

dog_chasis

Just before connecting all the servos together to the MEGA, let us make the life of our future selves easier. Let us label each servo so that later we can easily identify what servo wires connect to what servo. 

 

A symmetric labeling will follow on the right-hand side. We will use the following chart to label each servo. The number of (bands refer to the thin strips of the insulation tape that is used as a type of identification):

 

Servo location Color Number of bands

  • Upper thigh Black 1
  • Lower thigh Black 2
  • Knee Black 3
  • Front Red 1
  • Back Red 2
  • Left Yellow 1
  • Right Yellow 2

It might have been a bit frustrating to do this, but once you are done, it will be very easy to identify and replace a faulty servo later. It also aids programming and such.

 

We simply created a more efficient way to connect all the servos through the length of the tiny circuit and connected the battery directly to this board.

 

To test the soldering, you can either use a multimeter set to measure resistances, or use the MEGA. The former is self-explanatory. For the latter, remove all the connections that go to the MEGA and create the following circuit:

 

Make sure that the two unattached wires that come out of the MEGA have female terminals. Open Arduino and launch the Button example that can be found via File → Examples → 02.Digital → Button.

 

Then, upload the program. The LED on pin 13 will stay ON as long as no connection is detected (the circuit is open). Now, use these two wires to go through the tiny circuit to ensure that the soldering is done properly and the connections are as required. Who needs a multimeter, right?

 

Now that we have built the circuit, we just have to complete the connections.

 

Putting it all together

If you haven't yet appreciated the advantage of the tiny circuit, you will now do so. Connect the edge with the 12 pins of the tiny circuit, with 12 male-to-female connecting wires. Just before going to the connections, let's take a look at a few abbreviations that will help us:

  • UH: Upper Hip
  • LH: Lower Hip
  •  K: Knee
  • F: Front
  • B: Back
  • L: Left
  •  R: Right

 

Now, here is how the rest of the connections will go about with the configuration being components → tiny circuit → Arduino:

Components Tiny circuit Arduino

  • F R UH #1 D22
  • F R LH #2 D23
  • F R K #3 D24
  • F L UH #4 D25
  • F L LH #5 D26
  • F L K #6 D27
  • B R UH #7 D28
  • B R LH #8 D29
  • B R K #9 D30
  • B L UH #10 D31
  • B L LH #11 D32
  • B L K #12 D33
  • N/A #13(GND) GND
  • UBEC (5V & GND) #0 (5V & GND) N/A

 

Programming the robot

Programming the robot is the hardest task in this blog. It is not only about simply writing code and hoping for the best. Technically, you can use that technique and still get away with it, but it would consume a huge amount of time and energy.

 

We will go through the prior art again, see how a dog (and a robot dog) walks, and try to mimic some of that motion. We will also look at the mechanical design of our robot and see how it can be upgraded for better performance.

 

Weight distribution

Funnily enough, it makes sense to put this in the programming section. This is because weight distribution and the creation of the walking motion go hand in hand. Before programming the bot, we will have to power it.

 

Since we have made our circuit in the previous blog, we just have to put it in place on the robot, such that the weight of the battery and the Arduino MEGA is evenly distributed.

 

First, let's take a look at the battery (the larger one):

This is the heaviest object that the robot will be lifting. It will significantly increase the difficulty of programming if it is not centered correctly.

 

Putting it over the base of the robot seems like a logical solution, but the issue with the battery is that it occupies so much valuable space that can be used by the circuits, as they need to be more accessible than the battery. This is why we are going to mount it to the bottom of the robot.

 

While placing the battery, sort out the servo wires and place them at the corners around the battery. You can mount it using a layer of double-sided tape and then tape to bind it from a place. Ensure that the battery is exactly at the center of the base. A well-bounded one will look like this:

 

Make a note of how the servo wires are segregated into four parts around the battery. This is to decrease the distance between the servos and the MEGA in order to avoid unnecessary servo-cable extensions. If you think you really need them, especially for the knee servos, feel free to use them.

 

Arduino MEGA can be mounted directly opposite to it on the top, like this:

The MEGA can be stuck using a double-sided tape that we had used earlier to cover its base. Again, make sure that the segregated servo wires come out through the corners of the MEGA. For testing purposes, we will leave the rest of the connections as it is for now.

 

Test one

test_robot

 

"Test one?" As mentioned before, you will be taught how to make a robot, including the testing and reiteration phases. We are going to run our first test. It is a simple test that checks the stability of the robot and its ability to stand upright. You can connect the USB to the MEGA. Do not connect the battery yet.

 

Open the robot_dog_basic.ino file in Arduino, upload the program, and carefully connect the batteries to the UBEC. Your robot should spring into life and stand in an awkward stance, or not stand at all.

 

All the bones (sticks) point straight down. If you didn't achieve this, don't be saddened. Let us look at the code and fix it.The marked part is very important. The numbers that represent the starting position of the servos used in this blog and the number you have to use will be different.

 

Try changing one of the numbers, say F_R_UH_center (Front Right Upper Hip) right now, and uploading the code. Notice what happens? Tweak the numbers until your robot looks like the required stance shown in the preceding image of the robot.

 

If you haven't got it standing yet, keep trying until you get it. You can proceed once you are done.

Let's take a look at the robot now. The whole thing looks balanced, but it seems as though something is not perfectly right. It looks like the back legs are taking the majority of the load. This is because we had attached the back hip servos in order to resemble very much like a dog.

 

A dog has more muscles to help balance. However, this slight offset we have here will give us a lot of trouble in the future. Why didn't you tell me this while we were putting the thing on? It's simple: nobody knows how to create the perfect project plan. It requires choosing a design and hoping for the best, and reiterating the design on the way.

 

Unhook the battery and the USB. Unhook all the back servos going to the tiny circuit. Unscrew the back hip servos only. Exchange the left and right legs. Screw the exchanged hips back.

 

Relabel the servos (remove one yellow band from the then right servos and put them onto the current right servos). Connect them accordingly to the tiny circuit following this components → tiny circuit → Arduino:

  • B R UH → #7 → D28
  • B R LH → #8 → D29
  • B R K → #9 → D30
  • B L UH → #10 → D31
  • B L LH → #11 → D32
  • B L K → #12 → D33

 

Make sure the connections are correct and tight, connect the USB and the battery and check the position the dog now stands in. You may have to change the 'servo center' values to get the desired position. 

 

Save this file or at least the center values, as we will be using it from now on. The dog is much more stable now with the weight equally distributed among the four legs. We can now move to the next step: teaching the robot how to walk.

 

Try using the same technique to create a sitting position. Save this position and use these numbers when we come across the sitting position again.

 

The walking gait

Programming the robot's walk is similar to teaching a baby to walk, except that the robot does not have consciousness. A walking gait is basically a sequence of motions that results in the walking action.

 

There are two common gaits: the 'creep/crawl' gait and the 'trot' gait. The creep gait is what you see a cat doing when it is stalking its prey.

 

A video (https://www.youtube.com/watch?v=wQsmsr0oR6c) would do this more justice, but even from the preceding image or your experience, you can observe how the cat keeps its body constantly horizontal. This is a highly energy-efficient walking gait, but it is very complex to engineer.

 

The trot gait is when the two diagonal legs move together at a time to create a walking motion, as shown in the following image:

 

This is not as highly energy-efficient as the creep gait, but is far simpler than the creep gait. Also, this has more static stability, while the creep gait has more dynamic stability. Since you are programming a quadruped robot for the first time, let's take it easy. We will choose the trot gait and slightly modify the motions to make it suitable for our robot.

 

Test two

We are going to program the robot, using the trot gait. Open the robot_dog_trot_ gait.ino file in Arduino. Before uploading it, keep the robot in a space where it has no obstacles. A long USB cable benefits here.

 

Change the servo center values to what you had saved in the previous subsection. Plug in the battery and upload the program. Did it move forward or did it fall? Even if you executed a perfect walk, you can glance through the next bit. This may aid you later.

 

If your robot fell, why do you think this happened? We were sure of the balance. What is going wrong in that case? The ends of the calf bones (sticks) are too thin to cover the area that would further improve stability and weight distribution along the legs.

 

A good way to solve this is using plastic bottle caps. As mentioned earlier, these household materials are easily available.

 

Again, unplug the USB and the battery. It is not necessary to remove the knee screws to remove the calf stick, but if this is more convenient, go for it. We will need eight bottle caps.

 

If you think four will suffice, then you can choose 4 and run the code again. Mark the center of the two bottles with the thumb pin you used earlier, and push the pin through to make a tiny hole.

 

Tape the bottom part of the calf stick a couple of times to create a washer-like material. Now make a small hole, 1 cm above the bottom of the calf stick.

 

Now, with one cap on both the sides of the calf stick, drive a screw through the thickness of all the three layers. It is recommended to tape the exterior of the bottle caps to improve traction. It will look something like this:

 

Do this for all four limbs.

Once done, connect the battery and then the USB cable. You can alternatively use the smaller LiPo battery to power the Arduino at this stage via the 2.1 mm power port on the Arduino MEGA. This would be more convenient because of the length constraint of the USB cable.

 

It walks, doesn't it? It doesn't fall either, right? It is cool, right? If it does fall, try tweaking these parameters:

What this program does in sequence and repetition is the following:

  • Raise the front-right leg and advance it
  • Raise the back-left leg and advance it
  • Center the above servos, raise and advance the front-left leg, pushing the robot forward
  •  Raise the bottom-right leg and advance it
  • Center other servos pushing the robot forward
  • There you have it: the 'trot gait'.
  • This was the major part of programming the robot.

 

Developing personality

The personality is what makes the robot more alive. Adding personality to it makes it more fun and likable. This section focuses on some ideas that will help you create your own unique personality for your robot.

 

Circuit upgrade

The tiny circuit that we made can be split into two; one along each side of the Arduino connected to a common GND and power. Additionally, more header pins can be added to accommodate more servos (the tail and head) in order to organize the wires better. First, for this, cut out a long circuit board with a row size of about 6 pins.

 

Body upgrade

To be perfectly honest, the robot doesn't resemble a dog at all. Sure, it walks on four feet, but it doesn't resemble a robot dog either. This would require an outer shell with a head and a tail. 

 

Before installing a tail, it's a good idea to create an additional base layer or a case above all the wire commotion. This can either be made of more ice cream sticks, or you can just modify a cardboard box that you happen to have lying around to fit the robot, like this:

 

This new base can accommodate the tail. The tail can be made using another ice cream stick. It needs to be attached to a servo stuck underneath the base at the back.The servo can be programmed to create a wagging effect. You can also attach two servos that would allow you to control the shape of the tail. 

 

Sensors

The reason why adding sensors, such as the SRF04 (or SRF04) sensor that you used earlier to measure the distance, is such a great idea is because it enables the robot to get a feel of the environment—only with sensors can it respond to stimuli.

 

 To attach the sensor, make a slit on the top-front part of the base to accommodate the HC SRF04. Place the sensor at the front

 

Attach this in place. When the time comes, connect the sensor using the following circuit (SRF04 → Arduino):

  • GND → GND
  • Trig → D12
  • Echo → D11
  • VCC → 5V

Once you have attached the switch to the battery, attach the battery on the underside of the case. Make sure that you stick it at the exact center of the case: Make a small hole on the side where the wires of the battery are, and attach the switch to it:

 

Once you are satisfied with the components inside the case, connect all the wires including those for the sensor. Connect the tail to D34. Then, attach the case to the body of the robot.

 

Coding the personality

Just like the external design of the robot, you can program your robot's unique personality too. Since we have attached the sensor as the head of the robot, we can make use of its capabilities. To give you an example, let us make a 'lazy but loving' robot. Let us briefly discuss the algorithms involved:

  • Dog just sits around
  • Keeps sitting if not disturbed
  • If disturbed (detects a hand in front of its sensors), it stands up and wags its tail
  • If the hand slowly moves back, the robot follows the hand

 

Ultimately, if the hand comes close enough, the robot will lift its leg to shake its hand with you Load the arduino_robot_dog_personality.ino file, and go ahead and play with it. It is important to note that this program uses both a tail and the ultrasound sensor. If you do not want to use these components, tweak the code accordingly.

 

Implementing speech control

We have already learned about Bluetooth and speech control in the previous blogs. In this blog, we are going to merge them. Make sure you are connecting the Bluetooth module to the 3.3V of the MEGA, and not the 5V. Leave the rest of the servo wiring as it is.

 

Programming the Arduino

Now, open the robot_dog_speech.ino file. Just like before, change the servo center parameters to match your robot. Upload the program and connect the computer to the Bluetooth

 

Setting up BitVoicer

Open up BitVoicer and use the commands as shown in the following screenshot:

In summary, the commands are as follows (integer type):

  • Stand up – 1
  • Sit down – 2
  • Shake hands – 3

 

Note that the COM ports for you will be different. You can look it up in the device manager. Once everything is set, run the BitVoicer schema. Now, you can literally talk to your robot. It won't talk back, but you can make it sit, walk around, shake your hand, or whatever else you want to program. You are free to add additional functionalities via speech.

 

Unfortunately, you will still need the computer to communicate with the robot. Making the project standalone will require an additional microcontroller, which is beyond the scope of this blog. For now, you can, however, use a wireless headset to communicate with the robot wirelessly.

Recommend