Close
0%
0%

Low cost pi based quadruped "sparx"

My continuing project to build and improve a low cost quadruped robot as an introduction to walking robots.

keaKea
Similar projects worth following
Using an open source meped v2 kit, a Pi Zero, and an adafruit pca9685 servo driver to make a low cost quadrupedal robot, with aims to eventually give it a basic ai and autonomous functions.

After wishing to construct a walking robot for a long time, since I thought they were undeniably cool, if a little impractical. I decided to try and put together something relatively low cost with a significant margin for upgrade and improvement.

The base of the quadruped ("sparx") is a MePed v2 kit, consisting of laser cute plywood parts, some m3 hardware and 8 mg90s (clone) servos. This is a low cost kit coming in at on or around £30.

The brain is a standard raspberry pi zero, low cost, decently powerful and compatible with USB devices makes it very handy for attaching devices. The wifi included model would remove the need for a USB WiFi adaptor and will likely be a future upgrade.

The servo controller is an Adafruit PCA9685, relatively low cost (clones can be had for less money but may be questionably functional) and capable of driving 16 servos with the ability to daisy chain more boards for more servos. Plenty of space to add more for the future.

The battery and charge controls use what I had lying around, the batteries are pretty standard 3.7v LiPo batteries, one is 2000mAh and drives the servos, the other is 1200mAh and drives the pi. Using these batteries Sparx was capable of turning on the spot for over 2 hours before one of the batteries drained (specifically the one controlling the pi)

The code for the project is based on the open source code made available with the meped kit, but translated into python using the Adafruit library for the servos and PCA9685. These libraries made the code considerably easier to do.

CoreMovement.py

Core movement code for use with this quadruped.

plain - 20.88 kB - 09/13/2019 at 12:42

Download

  • 1 × MePed v2 kit The base kit I used, included servos, hardware and laser cut plywood body
  • 1 × ADAFRUIT PCA9685 Servo driver I used
  • 1 × Raspberry pi zero base raspi zero
  • 2 × MP2636 power boost & charge module Allows use of lipo batteries like a USB power bank
  • 2 × LIPO 3.7v battery two lipo batteries

View all 6 components

  • Failure, learning the limits of what you have.

    Kea09/20/2019 at 13:42 0 comments

    So I decided It was time to give Sparx some sort of sense, something that would allow it to move autonomously . This is what would for the first time turn Sparx from a rover, to a robot. Real autonomy.

    Digging through my box of assorted sensors I found a HC-SR04 sonar sensor, this looked perfect. Doing a bit of reading up on this specific sensor I learned that it was digital, meaning I wouldn't need an ADC (Analog to Digital Converter) to let my Pi speak to it. Plus it could range from 10cm up to 400cm! Likely far further than my little bot would need roaming inside (small British houses)

    A quick bit of work in Fusion 360 and a few hours printing gave me a bracket to bolt a servo to Sparx' "head" plus a bracket to attach the sonar sensor, as a happy bonus this let me turn the sensor from side to side AND looked very cute. 

    Then I needed to solder up a quick voltage divider, the output of the Sensor is 5v and that would harm the Pi, so a voltage divider was constructed and wired up and Sparx had vision, well, echolocation, kind of.

    A short PC session later I had a program that would enable Sparx to walk forward until it detected something less than 10cm infront of it, turn its servo "neck" to each side, scan distance and then turn in the direction of the longest distance and continue walking. I compiled it, confidently loaded it onto the Pi and watched my little bot in excitement as it walked towards my sofa.

    30 seconds later Sparx walks straight into the sofa, not the slightest hint of attempting to avoid it. I was surprised so picked it up, restarted the program and put my hand in front of it, as expected the little sensor turned left, then right, then picked a direction. I was confused so I plopped Sparx down again and set it on its way. Yet again, a collision occurred.

    A quick adjustment to my code and I printed each ranging measurement to the console as Sparx walked. I watched and looked for what could be causing the odd behaviour. Suddenly the readings went from 80cm to over 1000cm. A quick google showed me the problem, the sonar sensor cannot range accurately versus cloth/material surfaces, they absorb the sound, causing the sensor to read its maximum range regardless of how close.

    In frustration I added some sanity checks to my code, discarding any results over 600cm as clearly incorrect. I restarted the program and set Sparx on its way. With the sanity checks enabled It wouldnt walk into the sofa, instead it would get stuck in a loop, unsure what to do. So i adjusted the program again, to ensure no loop condition could happen. What was the result?

    Sparx walked around seemingly drunkenly, sometimes crashing into things, sometimes not. The whole project was a failure. Even with sanity checks the sonar sensor was simply the wrong tool for the job. Despite my best attempts I couldn't overcome the limitation of the sensor I was using in the environment I was using it in. My first major setback.

    Soon I plan to order either an IR distance sensor, or one of the ToF VL53L0X sensors, perhaps like the one Adafruit sells. These can range versus most materials that aren't IR absorbing and should allow Sparx to roam, as long as I don't need to detect things further than about 100cm.

    What I learned from this was to double check the constraints of the sensors I use, the HC-SR04 is a commonly used sensor, both because it is cheap and effective for where it is used. But I didn't check and instead learned something new. So not the worst outcome really.

  • Sparx HUNGRY

    Kea09/15/2019 at 12:31 0 comments

    So a major point of this project is to eventually turn sparx into an autonomous rover, able to wander around and do its own thing. Currently Sparx has no way to know its own battery level, It will continue to function until the batteries shut off, which is not ideal. 

    Since i am trying to give Sparx a basic AI (eventually) it makes sense to give it sensors. So first off I decided to kill two birds with one stone and give Sparx the ability to sense his battery level which will translate to the sensation of hunger.

    This was a fairly simple addition, a pair of voltage dividers (one for each battery) with some high value resistors to ensure that the current draw was low (a few mA a day) a small capacitor to smooth out any peaks and connect that to one of the pins on the MCP3008.

    The MCP3008 is an SPI ADC, offering 8 channels and is basically perfect to connect to a raspberry pi. If you follow the tutorial here: 

    https://learn.adafruit.com/mcp3008-spi-adc/python-circuitpython

    You should be able to both hook up the chip and have some basic knowledge of how to talk to it.

    I will soon be writing a python script that starts when Sparx is turned on that will check the battery level every few minutes. Measuring the voltage of the battery wont give me a charge percentage or anything like that, but we can use the voltage returned to gauge how empty the battery is, a lipo battery hovers at a little over 4v when fully charged and the charge/boost circuit I have will cut off the batteries around 3v. If i wanted to get a "percentage" of battery remaining I could try and do something with these values but LiPo voltage doesnt drop in a linear fashion across its battery life.

    Hopefully all of this will soon tie into the ability for Sparx to search for and find his own charging station. 

  • Sparx walks!

    Kea09/13/2019 at 13:08 0 comments

    Sparx is now complete enough to walk un-tethered! There is still a lot to do, while mobile Sparx is more of a rover than a robot as none of his functions are autonomous. Soon I will be adding both a sonar distance sensor and a camera to give him some basic autonomy. He will also be equipped with a method to monitor his own charge levels and hopefully in the futue the ability to find and utilise a charging station without intervention.

View all 3 project logs

  • 1
    Setting up the raspberry pi with the movement code provided.

    Simply follow this tutorial ( https://learn.adafruit.com/16-channel-pwm-servo-driver/python-circuitpython) to install the required libraries and dependencies. Then copy the code to your pi, connect via your preferred method (SSH or VNC etc) and run the code (ensuring to use python3 not python)

    The code is commented so should be relatively easy to follow. 

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

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