Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: [posted] Quadruped walking robot

  1. #1
    Junior Member
    Join Date
    Feb 2020
    Posts
    17

    [posted] Quadruped walking robot

    I wanted to learn modern machine learning by building a small walking robot and have it controlled by a neural network. I will get to that, eventually. That's the primary reason I chose the Teensy 4 over other platforms, it has the computing power to run some decently sized neural networks in real time.

    So far it has been a project about servos, mechanics, robotics, kinematics, electronics, etc.

    What it has become, so far, is a neat walking robot that is quite capable of slowly walking difficult terrain https://youtu.be/a22FzKibE3c. It is somewhat capable of trotting at a higher speed too but the software needs some love. https://youtu.be/MDsygNth5o0

    Click image for larger version. 

Name:	Pose.jpg 
Views:	59 
Size:	152.1 KB 
ID:	19051

    The heart of the beast is a Teensy 4.0 where I have used all pins but one on the normal side pinouts. 12 PWMs are controlling the servos, 4 ADCs read the foot sensors, 2 I2C pins talk to the MPU6050 gyro/accelerometer modules and 5 pins do SPI to the NRF24 radio.
    The robot is powered by a 4 cell LiPo pack, which is total overkill, a 2 cell would be work perfectly fine. I have one switching voltage regulator for the servos to supply the 5-6V and one regulator for the fine electronics, Teensy and others. Since I didn't know if the Teensy supplied 3.3V would be enough there is another 3.3V linear regulator as well. I could probably skip that but I know that the NRF24 radio module is very very picky when it comes to getting a stable 3.3V.

    Click image for larger version. 

Name:	Electronics.jpg 
Views:	75 
Size:	136.4 KB 
ID:	19052

    The NRF24 radio sends all sensor data it has back to and old Arduino that relays it via serial to my PC, at 100Hz. The PC sends back commands from the game controller I use to tell the bot what to do. I'm working on modding and old PS2 controller to talk directly to the bot.


    The leg mechanics is a bit strange. It's not like Boston Dynamics spot legs or most other bots you see people build. If it was a horizontal arm, and not a leg, the boston leg would be called a scara arm. My leg is a 5-bar parallel, or 5-bar scara arm, with an extension. The 5-bar is quite strong mechanically and it was easy to place the servos to fit all 3 axis per leg in a small package. The math is quite hairy though. I was considering a delta leg, but fitting the servos on a reasoanable way was not possible.

    Click image for larger version. 

Name:	Leg.jpg 
Views:	58 
Size:	230.9 KB 
ID:	19053

    It is very handy that the bot is pretty small, it's just 20cm long and weighs about 600g. It is totally harmless to both itself and it's operator. It has pinched my fingers quite a few times (those tiny 14g servos are strong) but never anything serious. I happily upload code that is never simulated, bugs out totally and sends all servos to their extreme, no harm done. It's just a funny pose. The digital servos cuts the power after a while if they can't reach their position.


    The magic to getting it walk as good as it does is all in the software. The MPU and the foot sensors are critical input to be able to walk good, but it takes software to process that data and control the servos.
    I have spent many hours coding on the kinematics, i.e. converting from x,y,z to motor positions (and back), and lots of 3D algebra, rotations, translations, etc. I am a CS major though, my home turf

    For now it can only walk slow and stable, and do some shaky trotting. I have only implemented static balancing, it has no idea about speed and inertia. I quickly tried some simple stand on 2-leg balancing but failed. I hope that the servo lag/gearbox play does not make this totally impossible. It might. Boston Dynamics Spot can easily lift two legs and with (what looks like) no effort stand two legs.
    If there existed tiny brushless motors, play-free gearboxes and reasonable motor controlles I would get them in a heartbeat. The RC servos are blunt machines.

    Back to machine learning, the starting point of the project. My idea for now is to make it walk decently with hand coding, record a lot of walking and use that data to train a neural network. Once it can imitate reasonably I can let it control the physical robot, walk around and learn by itself. I just have to figure out a reasonable arena for it to train in, and how to get it back on it's feet when it falls over. And the magic of network design, reward functions etc. It was easier back in the 90's when I last played with neural networks, kohonen and 3 layers.

  2. #2
    Junior Member
    Join Date
    Oct 2016
    Posts
    15
    Gorgeous mechanics! I love the leg hinge solution. What material are you using it? You're spot on about the difficulty of using 'dumb' motors, closed-loop is a fundamental feature for systems with so many DOFs. If you had an internal physics engine servo telemetry would let you do velocity estimation. Have you considered using something like these new baby Dynamixels?

    I'm also really curious what 'fitness' metric you have chosen for ML.

  3. #3
    Junior Member
    Join Date
    Feb 2020
    Posts
    17
    I forgot to mention that never ever connect a PWM pin from the Teensy directly to a servo. It works fine until the cables on the servos short, intermittently, sends 6V to the teensy and fries it. Believe me, I have 5 fried Teensies.
    It works with a 330ohm resistor in series. The proper solution would probably be some lever converters/isolators that prevent back-currents.

  4. #4
    Junior Member
    Join Date
    Feb 2020
    Posts
    17
    The leg hinges are in PP, polypropylene, perfect plastic for hinges. And 3D printable, at least for simple items like this. There is still a bit of flex in non-wanted angles when the legs are at extreme sideways positions, but the hip servos tends to give up in those situations. The small flex in the hinges should save the servos from some shocks too. But, it's a very small robot.

    Dynamixels looks very cool, i'll check them out in detail.

    I have one pin left on the Teensy, and seriously consider making that a current measurement pin. For good walking energy use is very important. Other than that and the obvious ones for fitness, such as distance traveled in wanted direction, I am not sure.

    Edit: And for "closing the loop" i think that absolute precision in each motor is not critical. The loop can be closed good enough by end effector feedback, ie foot sensors in this case. The issue with RC servos are the PWM update time(100Hz ish) and the massive backlash in the gearbox, several degrees.
    Last edited by scaraman; 02-12-2020 at 08:39 PM.

  5. #5
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    As I said impressive effort. When I was testing the servos with the T4 I was concerned of the possibility of 5v getting back into the T4 so I started to use level shifters just in case especially since I was using digital servos. Serial servos are interesting, haven't had much time to play with them

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,502
    Even cooler when seeing the details and more behind it!

    Only one pin left? Have you used any of the bottom pins in case you needed more? The T_3.6 type T_4.1 PJRC is working on would have a few more pins- plus the bottom 10 pins on the edges, and easier to get USB Host for Bluetooth dongle to connect a PS/2 controller - though the NRF24 radio a bit close for the 1" growth.

    Very good leg selection and articulation - and hips too!

  7. #7
    Junior Member
    Join Date
    Feb 2020
    Posts
    17
    I have been struggling hard to make it keep some kind of dynamic balance, ie take speed into account. But I fail miserably all the time

    I think one of the problems is that the hobby servos have a massive slop in the gearboxes. At a normal stance you can wiggle the legs +-1cm sideways, all is gearbox slop.

    Now I could either redesign and gear down the hip join to reduce the slop, or make a very advanced control algorithm that takes the slop into account, or release the AI and see what it comes up with

    I would have to construct something to automatically get it back on its feet when it falls over...

  8. #8
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    156
    That is incredibly cool!

    Why not just add a passel of Teensys? Then you can bust up the coding making it easier to write and faster to respond, and you end up with more pins that you'd ever need.

    -jim lee

  9. #9
    Administrator Paul's Avatar
    Join Date
    Oct 2012
    Posts
    369
    This project was posted on the blog. Still on the main PJRC today.

    https://www.pjrc.com/quadruped-walking-robot/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •