DIY hobby servos quadruped robot

Cheap 3D printed 4 legged robot, that almost looks like boston dynamics spot but moves like her newborn sister.

Similar projects worth following
I built this robot in order to introduce my self to control theory, studying its maths and practicing pragramming, so the idea of this project is to implement, somehow, a Model Predictive Control to make the walk stable.
Runs with hobby servos, and has Raspberry Pi 4 as brain, plus an Arduino Mega for reading/writing of signals and MPU6050 IMU.

  • General Summary

I made all the code, written on python, for now implements a walking loop inside a kinematic model, so you can command a pose on the body, as well as feet position and also velocity and directinal commands for the walking loop. Controlled by a ps3 controller via bluetooth.

Arduino is used for speed up the reading and writing of signals, so in the future i can add other sensor, as well as position feedback... This communication is made via bidirectional Serial Commands, so servo pulses are sent to the arduino and angles on IMU are recived on the Raspberry Pi.

As soon as you see the project, you will notice i'm not using Raspberry Pi, thats becouse as i don't have batteries for now (This will be finished in the following updates), its more comfortable for me to work on the PC, but on Raspberry Pi it would work the same.

For the first update of the project i show you a video in which i compare the real robot model with the simulation model:

I'm using PyBullet physics engine, it is simple to use and seems to have a good performance as well as very precise results.

  • Building premises.

I'm going to enumerate some important concepts i have taken into account for the robot design.

This robots depends hardly on its mass distribution and dynamics of the moving parts (legs). Thats why i decided to go for this servo configuration, having the coxa servo on the body, the femur servo on the coxa and tibia servo on the the femur, so there is only 2 servos moving with the legs.

This way, the less leg weight the less unexpected inertia, causing a better dynamic behavior.

Also the robot weight should be as less as posible becouse hobby servos can be overcharged easily.

About the mass distribution, this would define the Center of Mass which should be the closest to the Geometric Center, for this the building must be as simetric as posible, this way CoM is easier to locate and the control would be more predictable.

  • Robot Update (May 2020)

Most of the time the robot is disassembled and i will need to wait until i can print the new version (Final exams comming) which would be much lighter. Until that i'm starting to configure raspberry. (Powered by the batteries)
For now the code runs very well on raspberry but it is a bit slower than pc reading the data coming from arduino. Also raspberry is not powerfull enough to run pybullet on GUI mode, but on DIRECT mode it takes the raspberry at 40% of its capacity.
About the electronics, i'm going very carefully on it as i don't want to burn anything. So basically, the problem here is that, when i switch off the motors there is still voltage (~1,5 V) going trought that line. I think this is becouse the switch is cutting servo ground in stead of V+, so there is still some voltage drop between V+ from servo and common ground on arduino. Let me know your thoughts about that.

Also i'm working on a lighter version of the robot as the servos are a bit overloaded, i realized the parts are printed with 5-6 perimeters and up to 4 solid layers, weighing about 100 g for a femur. However, 2 perimeters and 2-3 solid layers the same piece weighs 40 g.

For next version i will make the body higher, becouse there is no much room inside. The batterie box is made for 6x 18650 litio batteries with the typical frame sold out there.

These renders aren't final version, there are lot of thing to polish in orther to make the design buildable.

  • 12 × Servo DS3218 PRO version 20 kg/cm torque and 0.1 s/60º
  • 1 × MPU6050 IMU accelerometer + gyrocope
  • 1 × Arduino Mega
  • 1 × Raspberry Pi 4
  • 20 × 8x3x4 mm bearings (autter x inner x width)

  • Step Trajectory and Gait Planner

    miguel_ayuso3 days ago 0 comments

    As in the you can change the foot position, you can make a time varying system by changing the feet position describing a bezier curve.

    So building a parametric bezier curve (7 points in my case) you can follow a closed step loop, i designed this trayectory by drawing it on this bezier curve generator:

    This can by written by an equation dependant of the 7 point and a parameter going from 0 to 1 in order to describe the trajectory. In the the file is known as phi and the start-end point is (0,0).

    This parameter is important becouse it tells you where the foot is located, these coordinates are defined in the foot frame, so this would by the foot trajectory.
    Then making 4 loops going from 0 to 1, for every leg and define an offset for every foot you can do different gaits as shown in the video.

    In the video i explain how you can generate different gaits just by changing the offset between the feet loop:

    You can play with the simulation at the file just python3 with pybullet and numpy needed to run the simulation.

  • Lets talk about the kinematic model.

    miguel_ayuso05/14/2020 at 12:10 0 comments

    In this log i'm going to explain how the kinematic model works.

    First thing to take into account is the robot geometry and its DOFs, to ilustrate this, in the next image you see where are they and how they transform. This model is very looking forward, in real robotics first is to make a robust state stimator so you can have smooth meassurements of robots states.

    NOTE: All vector are defined inside the robot frame, no world frame is used for now.

    So, we have 4 frames on each leg and one which is commun for all, which is the geometric center of the robot (very close to the CoM).

    For our setup, there are 2 important frames on the leg, which are the frame0 (coxa frame or first frame on the leg) and frame4 (foot frame or last frame on the leg).

    So now, we are going to calculate Inverse Kinematics between those frames. If you want more information on how to calculate IK you can read this article:

    As u can see the setup is a bit diferent, but it only change the simetry of the legs, so the analytic function is the same.

    Inverse Kinematics are solved on the file, which is basically two functions, one for right legs and the other for the left legs. These functions works as shown:

    Now, we can locate foot in the 3D space, inside the frame0.

    Next step is to move the body frame in relation with the feet. Which is essentialy the kinematic model i built, file in the code.

    For this, we need to define 3 vectors, the first is a 'constant' vector, which is the vector from the center to the frame0 or coxa frame, this vector is going to be rotated and translated with the desired body position.

    The next vector is the vector from the center or body frame to the frame4 or foot frame, this vector is where we want the foot to stay.

    With this two vector we can calculate the IK vector needed to calculate the inverse kinematics just by subtracting body to frame4 and body to frame0.

    Now, we want the body to rotate on its 3 dofs and its 3 logitudinal movements, for this, we just multiply the body to frame0 vector by the rototranslation matrix. You can see how this woks on the file, where the fuctions for the rototranslations are defined.

    As the the principal frame is transformed, all other child frames are also transformed,  so in order to keep feet still, we need to undo the fransformation for the frame0 to frame4 vector (IK vector) before IK are solved.

    Here there is a video showing the model in action:

    As you see in the video, you can define a initial position for the feet and vary the 6 dof on the body frame, that it may be, for example, the states of a control model.

View all 2 project logs

Enjoy this project?



albertson.chris wrote 05/15/2020 at 00:40 point

Will you post th CAD files?   Already I'd like to try building just one leg for testing and I can think of a few changes.

One other question:  It looks like the prototype in the video was missing the Pi and batteries.  How much weight could be added?   Certainly the Pi4, batteries and see DC/DC regulator will need to be addd but also some sensors.

  Are you sure? yes | no

miguel_ayuso wrote 05/15/2020 at 10:07 point

Yes! i'm finishing them, i think in the next 3 month i will print all the parts left, correct them if there are mistakes and then share them.

Yes, batteries, raspi and its cables are taken into account in the design, they add about 500-700 g, but also i'm removing weight in the design. Another diference between prototype and wireless version is that cable is going at 5V and batteries at 7.4V.

So i think, there will be no problem with this extra weight

  Are you sure? yes | no

Mustafa wrote 05/14/2020 at 18:11 point

If you prepare a basic udemy course we can buy it

  Are you sure? yes | no

Mustafa wrote 05/14/2020 at 16:50 point

Miguel I am following your project, thanks for those precious informations.. Please continue..

  Are you sure? yes | no

miguel_ayuso wrote 05/15/2020 at 10:08 point

Thanks a lot man! Of course i'll be documenting all the project.

  Are you sure? yes | no

Comedicles wrote 05/14/2020 at 06:17 point

Does it have accelerometers and inertial orientation? Put the poor thing out of its misery and place it on a  rubber surface so that leg motion can correspond to movement through space. I can tell it is miserable!

  Are you sure? yes | no

Steve wrote 05/13/2020 at 17:23 point

I loaded the STLs into Ideamaker(3D-printer slicer) and it shows up super-tiny, like it's in inches not millimeters. What are the dimensions supposed to be  if we wanted to print this out ?

  Are you sure? yes | no

miguel_ayuso wrote 05/13/2020 at 22:40 point

Those files are not printable, are only for show them on the simulation, thats why u see them very small as they are meassured on meters. If you look closer to them, there is no way to build or mount them with the hardware

  Are you sure? yes | no

Steve wrote 05/14/2020 at 00:10 point

Is there a way to print it out if we wanted to work on one ourselves or is that not ready yet ?

  Are you sure? yes | no

Steve wrote 05/14/2020 at 00:14 point

Anyway, this is still very cool and I'm looking forward to reading about it more as it progresses along.

  Are you sure? yes | no

Alior101 wrote 05/13/2020 at 16:34 point

Cool! Is this the 180 or 270 pro version of  DS3218?

  Are you sure? yes | no

miguel_ayuso wrote 05/13/2020 at 17:17 point

180 PRO version, as for example, the tibia movement is limited to 110 dregrees.

  Are you sure? yes | no

Alex Tacescu wrote 05/13/2020 at 15:58 point

Super cool project! Are you calculating forward/inverse kinematics on the Arduino? Or is everything done in the physics engine?

  Are you sure? yes | no

miguel_ayuso wrote 05/13/2020 at 17:21 point

I'm calculating them on the python sketch in the computer/raspberry. For now i'm not using data from the simulation, only i sent to the simulation the angles for every joint, the same as in the real robot.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates