Categories
projects robots

Project Hexapod Part 3: No plan survives contact with the enemy

Design change 1:

Originally, I was going to control the hexapod from an Arduino pro mini.  Partly because that’s how I originally started the project.  But also, because I’d heard ropey things about raspberry pi’s and Python controlling servo’s in real time.  I was however planning to use a raspberry pi zero-w as a master.  The control system would connect to the Bluetooth adapter in the PI, some of the more complex calculations could be done on the PI, and then the PI would send messages to the Arduino which was in charge of moving the legs.

When I’ve seen people on YouTube do this (Tom Stanton, James Bruton), they often take this approach.  But that’s partly because they seem to have a remote-controlled background and are using devices like RC car controllers or drone controllers (and the associated electronics on the robot end).  I don’t have those devices and don’t have that experience. 

After playing with the Arduino code a bit, I’m starting to think that idea is a pain in the ass.  There’s the physical weight of the Arduino, but also the additional power draw it will take.  The calibration of the servo’s and the interfacing between the pi and the Arduino seems like extra work.  And configuring the servo’s end stops on the Arduino seems like a massive kludge. 

Most of my coding experience is with mobile apps.  My thought process was to write a smart phone app to connect to the device over Bluetooth.  Therefore, I’m not going to be going down the physical handheld controller route.

In addition, I have more experience with UNIX based systems.  So once the remote is walking, I’m more interested in doing client / server / web stuff where the robot is interacting with both it’s environment but also the web.  Whilst I have very little experience in Python, I have more experience in that kind of UNIX based scripting language than the C based Arduino language.  I’m not a natural developer so I need to minimise the number of language’s I’m learning.  I expect I’ll have more usage out of Python from a professional and personal projects perspective

For all of that, I’m now planning on ditching the Arduino and seeing just how difficult it is to get the pi zero-w to control the servo’s using the PCA985 PWM controllers over I2C.

Categories
projects robots Uncategorized

Project Hexapod Part 2: More walking design thinking

Each leg on this robot has 3 motors; a shoulder, an elbow, and an ankle

To make things easier I labelled them up like this:

There are 18 separate motors to control:

BoardServoBoardServo
LeftFrontShoulderPwm18RightFrontShoulderPwm17
LeftFrontElbowPwm110RightFrontElbowPwm15
LeftFrontAnklePwm113RightFrontAnklePwm12
  
LeftMiddleShoulderPwm19RightMiddleShoulder136
LeftMiddleElbowPwm114RightMiddleElbow141
LeftMiddleAnklePwm115RightMiddleAnkle150
  
LeftBackShoulderPwm28RightBackShoulderPwm27
LeftBackElbowPwm29RightBackElbowPwm26
LeftBackAnklePwm210RightBackAnklePwm25

Design Thoughts

First thought was to create a function that controls each limb.  At the least every limb should move in the same way.  However, whilst limbs move together from the gait perspective (Figure 2) I don’t think we can do that from an Arduino perspective.  I don’t think I can create a function that says move limbs L1, R2, L3 at the same time.  I think I’ll need a function that does that.  But then separately what it’s doing is moving “Left Front Shoulder, Right Middle Shoulder, Left       Back Shoulder” together, then “Left Front Elbow, Right Middle Elbow, Left Back Elbow”, etc.  until that function is complete.

I think I’ll have a multidimensional array with degrees in it for each joint.  What I might do though is write a routine which sets each joint to 0.  Then unscrew and reattach the joints so I know where zero is on each motor.  Either way, I probably need a few lists to define:

the start and end position of each joint for a forward motion

the start and end position of each joint for a circular motion

the start and end position of each joint for being sat still.

That currently looks like this:

NameBoardServoservo_minservo_max
LeftFrontShoulderPwm18500500
LeftFrontElbowPwm110  
LeftFrontAnklePwm113  
LeftMiddleShoulderPwm19  
LeftMiddleElbowPwm114  
LeftMiddleAnklePwm115  
LeftBackShoulderPwm28  
LeftBackElbowPwm29  
LeftBackAnklePwm210  
RightFrontShoulderPwm17  
RightFrontElbowPwm15  
RightFrontAnklePwm12  
RightMiddleShoulder136  
RightMiddleElbow141  
RightMiddleAnkle150  
RightBackShoulderPwm27  
RightBackElbowPwm26  
RightBackAnklePwm25  

Maybe a piece of code that takes serial input and resets the device to zero’s.

Control System:

Due to its built in Bluetooth, I’m thinking about having a raspberry pi zero-w connected to an Arduino nano over USB Serial:

https://maker.pro/raspberry-pi/tutorial/how-to-connect-and-interface-raspberry-pi-with-arduino

ser=serial.Serial(“dev/ttyACM0”,9600)

Then I can both ssh into the robot to tell it what to do.  And I can also write a phone app to act like a remote control, connecting over Bluetooth.  The v5 of the robot car did that.

Categories
robots

Project Hexapod Part 1: Walking Design

The design of the hexapod looks like this.  Each “limb” comprises of a shoulder, elbow and a foot.  The shoulder moves in a horizontal plane, left and right.  The elbow and feet move in vertical plans, up and down.

To control the hexapod, I need to consider stability. My current plan is to move three legs at a time. Something like this

This is an example gait I’ve found online.  It resembles how an ant walks.  So either side always has at least one foot on the ground and the robot should be balanced.  And this should be quicker (and easier) than moving each foot at a time. 

#Problem – how do I make walking asynchronous?  If I have a single function to move a limb, how do I move two limbs at once?

This is an example gait I’ve found online.  It resembles how an ant walks.  So either side always has at least one foot on the ground and the robot should be balanced.  And this should be quicker (and easier) than moving each foot at a time. 

#Problem – how do I make walking asynchronous?  If I have a single function to move a limb, how do I move two limbs at once?

#Answer


/* Sweep
 by BARRAGAN <http://barraganstudio.com>
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>
 
Servo servo1;  // create servo object to control a servo
Servo servo2;  // create servo object to control a servo
                // twelve servo objects can be created on most boards
 
int pos = 90;    // variable to store the servo position
 
void setup()
{
  servo1.attach(8);  // attaches the servo on pin 9 to the servo object
  servo2.attach(7);  // attaches the servo on pin 9 to the servo object
}
 
void loop()
{
  for(pos = 90; pos >= 19; pos --){
  servo1.write(pos);
  servo2.write(180-pos);
  }
  //delay(5000);
  for(pos = 19; pos <= 90; pos ++)     // goes from 19 degrees to 90 degrees
  {                               
    servo1.write(pos);              // tell servo to go to position in variable 'pos'
    servo2.write(180-pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

Note that this is my design process as I try and plan how I’m going to make this work, and part of that is trying to understand what’s possible. So this isn’t my code, but an example of how to control the servos I found here .

Categories
projects robots

Project Hexapod: Introduction

In 2018 I was building lots of Arduino projects. One of which was a robot car which sense walls using ultrasound to sense when it was about to drive into a wall. In the video below I connect via bluetooth, then enter some commands into the Arduino serial console

https://www.youtube.com/watch?v=-6rlZxKwQQU

To build on this I decided to make a hexapod – a walking spider.

https://www.instagram.com/p/B-UYLZ4gD9uStzXugmaBnCfFzCwmCFCYKgSnoE0/

The parts are still available here, although there isn’t a codebase to use the robot – you need to make that yourself. And that’s what this new project is about.