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:
Board | Servo | Board | Servo | |||||||
Left | Front | Shoulder | Pwm1 | 8 | Right | Front | Shoulder | Pwm1 | 7 | |
Left | Front | Elbow | Pwm1 | 10 | Right | Front | Elbow | Pwm1 | 5 | |
Left | Front | Ankle | Pwm1 | 13 | Right | Front | Ankle | Pwm1 | 2 | |
Left | Middle | Shoulder | Pwm1 | 9 | Right | Middle | Shoulder | 13 | 6 | |
Left | Middle | Elbow | Pwm1 | 14 | Right | Middle | Elbow | 14 | 1 | |
Left | Middle | Ankle | Pwm1 | 15 | Right | Middle | Ankle | 15 | 0 | |
Left | Back | Shoulder | Pwm2 | 8 | Right | Back | Shoulder | Pwm2 | 7 | |
Left | Back | Elbow | Pwm2 | 9 | Right | Back | Elbow | Pwm2 | 6 | |
Left | Back | Ankle | Pwm2 | 10 | Right | Back | Ankle | Pwm2 | 5 |
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:
Name | Board | Servo | servo_min | servo_max |
LeftFrontShoulder | Pwm1 | 8 | 500 | 500 |
LeftFrontElbow | Pwm1 | 10 | ||
LeftFrontAnkle | Pwm1 | 13 | ||
LeftMiddleShoulder | Pwm1 | 9 | ||
LeftMiddleElbow | Pwm1 | 14 | ||
LeftMiddleAnkle | Pwm1 | 15 | ||
LeftBackShoulder | Pwm2 | 8 | ||
LeftBackElbow | Pwm2 | 9 | ||
LeftBackAnkle | Pwm2 | 10 | ||
RightFrontShoulder | Pwm1 | 7 | ||
RightFrontElbow | Pwm1 | 5 | ||
RightFrontAnkle | Pwm1 | 2 | ||
RightMiddleShoulder | 13 | 6 | ||
RightMiddleElbow | 14 | 1 | ||
RightMiddleAnkle | 15 | 0 | ||
RightBackShoulder | Pwm2 | 7 | ||
RightBackElbow | Pwm2 | 6 | ||
RightBackAnkle | Pwm2 | 5 |
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.