Difference between revisions of "Raspberry PI Spiderbot"

From BITPlan Wiki
Jump to navigation Jump to search
 
(39 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{OsProject
 +
|id=PI-Q-Robot
 +
|owner=BITPlan
 +
|title=Raspberry PI controlled Quadruped Robot with 3D Simulator
 +
|url=https://github.com/BITPlan/PI-Q-Robot
 +
|version=0.0.1
 +
|date=2019-08-07
 +
}}
 +
{{:Self_Driving_RC_Car/Links}}
 +
 
Inspired by the Arduino Project below we'd like to create a Raspberry PI version as in https://github.com/yasaspeiris/aragog
 
Inspired by the Arduino Project below we'd like to create a Raspberry PI version as in https://github.com/yasaspeiris/aragog
 
= Video =
 
= Video =
 
<youtube>fiQbOWvqVco</youtube>
 
<youtube>fiQbOWvqVco</youtube>
 +
= Simulator =
 +
* http://pi-q-robot.bitplan.com/
 +
* {{Link|target=PI-Q-Robot|title=Simulator documentation}}
 +
== Calibration ==
 +
=== Restful interface ===
 +
<pre>
 +
http://<baseurl>/servo/<servoid>/<angle> will set the angle of a single servo
 +
</pre>
 +
=== Servo numbering scheme  ===
 +
This is the default numbering schema as configured in the software. If your servos are mounted or cabled differently you might want o adjust the code a accordingly
 +
{| class="wikitable"
 +
|-
 +
! ServoId !! Leg !! Extrimity !!  Inverted
 +
|-
 +
| 0 || 1 || Coxa ||
 +
|-
 +
| 1 || 1 || Femur || x
 +
|-
 +
| 2 || 1 || Tibia || x
 +
|-
 +
| 3 || 2 || Coxa ||
 +
|-
 +
| 4 || 2 || Femur || x
 +
|-
 +
| 5 || 2 || Tibia || x
 +
|-
 +
| 6 || 3 || Coxa ||
 +
|-
 +
| 7 || 3 || Femur ||
 +
|-
 +
| 8 || 3 || Tibia ||
 +
|-
 +
| 9 || 4 || Coxa ||
 +
|-
 +
| 10 || 4 || Femur ||
 +
|-
 +
| 11 || 4 || Tibia ||
 +
|-
 +
|}
 +
 +
== Calibration Range ==
 +
{| class="wikitable"
 +
|-
 +
! Extremity !! Servo Angle || Position !! Direction !!  Range
 +
|-
 +
| Coxa || 90 || 45°  || left to right || 0°-180°
 +
|-
 +
| Femur || 90 || Flat  || up to down || 0°-180°
 +
|-
 +
| Tibia || 90 || Flat  || down to up || 0°-180°
 +
|-
 +
|}
 +
 +
=== Relevant source code ===
 +
<source lang='python'>
 +
class Spider:
 +
    """ I am a quadruped spider with four legs consisting of coxa, femur and tibia each"""
 +
    def __init__(self):
 +
        self.fl = Leg(0, 0,  1,  2)
 +
        self.fr = Leg(1, 3,  4,  5)
 +
        self.rl = Leg(2, 6,  7,  8)
 +
        self.rr = Leg(3, 9, 10, 11)
 +
 +
...
 +
class Leg:
 +
    """ I am a single leg of the spider consisting of coxa, femur and tibia"""
 +
    def __init__(self, legId,coxaId, femurId, tibiaId):
 +
        self.legId=legId
 +
        self.coxa = Extremity('coxa', coxaId)
 +
        self.femur = Extremity('femur', femurId,legId<2)
 +
        self.tibia = Extremity('tibia', tibiaId,legId<2)
 +
 +
...
 +
class Servo:
 +
    """ I am a single Servo motor """
 +
    def __init__(self, id,inverted=False):
 +
        self.id = id
 +
        self.inverted=inverted
 +
 +
    def setAngle(self, angle):
 +
        self.angle = angle
 +
        trueAngle=180-angle if self.inverted else angle
 +
        if kit is not None:
 +
            kit.servo[self.id].angle = trueAngle
 +
        return trueAngle
 +
 +
 +
</source>
 +
 
= Links =
 
= Links =
 
* [https://www.thingiverse.com/thing:2204279 Spider robot(quad robot, quadruped)-MG90  regishu 2017]
 
* [https://www.thingiverse.com/thing:2204279 Spider robot(quad robot, quadruped)-MG90  regishu 2017]
 +
* https://github.com/regishsu/SpiderRobot
 
* https://www.hackster.io/yasaspeiris/raspberry-pi-powered-quadruped-bbb68b
 
* https://www.hackster.io/yasaspeiris/raspberry-pi-powered-quadruped-bbb68b
 
* https://github.com/yasaspeiris/aragog
 
* https://github.com/yasaspeiris/aragog
 +
* https://engineering.tamu.edu/media/4247823/ds-servo-mg90s.pdf
 +
== Other ==
 +
* https://github.com/topics/quadruped
 +
* https://github.com/anoochit/arduino-quadruped-robot
  
 
= Parts =
 
= Parts =
Line 22: Line 126:
 
| 5 || [[File:31pzC7A3D3L.jpg|200px]] || Micro USB Connector || [https://www.amazon.de/Delock-Stecker-Offene-Kabelenden-schwarz/dp/B01A9GLG6Q Delock USB 2.0 Micro USB] || || 6 €
 
| 5 || [[File:31pzC7A3D3L.jpg|200px]] || Micro USB Connector || [https://www.amazon.de/Delock-Stecker-Offene-Kabelenden-schwarz/dp/B01A9GLG6Q Delock USB 2.0 Micro USB] || || 6 €
 
|-
 
|-
| 6 || || 3D Printed Parts: Coxa, Tibia, Femur, Hinge || [https://www.thingiverse.com/thing:2204279 parts from regishu's design] || ||  
+
| 6 || [[File:SpiderBot-Parts-IMG_0033.JPG|200px]] || 3D Printed Parts: Coxa, Tibia, Femur, Hinge || [https://www.thingiverse.com/thing:2204279 parts from regishu's design] || ||  
 
|-
 
|-
| 7 || || Adafruit PCA9685 16 channel PWM controller || {{Link|target=PCA9685}} || ||  
+
| 7 || [[File:61B2dK96ysL. SL1000 .jpg|200px|link=https://www.amazon.de/PCA9685-Servomotor-Treiber-Arduino-Roboter/dp/B06XSFFXQY]] || Adafruit PCA9685 16 channel PWM controller || {{Link|target=PCA9685}} || || 6.5 €
 
|-
 
|-
| 8 || [[File:61yfILxEkgL._SX679_.jpg|200px]]  || set of small screws || [https://www.amazon.de/gp/product/B07LFDDXZ2 set of small screws] || ||  
+
| 8 || [[File:61yfILxEkgL._SX679_.jpg|200px]]  || set of small screws || [https://www.amazon.de/gp/product/B07LFDDXZ2 set of small screws] || || 8.5 € ||  
 
|-
 
|-
| 9 || [[File:71a1K3RQuqL. SX679 .jpg|200px]] || 12 x MG90S || [https://www.amazon.de/gp/product/B07FQMTLD4 12 x MG90s] || ||  
+
| 9 || [[File:71a1K3RQuqL. SX679 .jpg|200px]] || 12 x MG90S || [https://www.amazon.de/gp/product/B07FQMTLD4 12 x MG90s] || || 42 €
 
|-
 
|-
| || || || ||Total ||  €   
+
| || || || ||Total ||  ~ 135 €   
 
|-
 
|-
 
| a
 
| a
Line 46: Line 150:
 
| 10 €
 
| 10 €
 
|}
 
|}
[[File:SpiderBotParts-IMG_0028.jpeg|400px]]
+
= Printing =
 +
You might want to make sure that you print your parts with sufficient infill - I used 75%.
 +
 
 +
[[File:SpiderBotParts-IMG_0028.jpeg|960px]]
 +
== Example for broken part ==
 +
This part was printed with {{Link|target=Cura}}'s default infill and broke off:
 +
 
 +
[[File:Broken-IMG_0034.JPG|400px]]
  
 
= Assembly =
 
= Assembly =
Line 118: Line 229:
 
   setAngle(servos,fromangle)
 
   setAngle(servos,fromangle)
 
</source>
 
</source>
 +
 +
= Evolution of Base =
 +
Since we'd like to use a Raspberry PI we couldn't use the orignal Base by regishu. Trying the one from https://github.com/yasaspeiris/aragog also did not work since our raspberry PI case had a different size. So incrementally a new design was created:
 +
 +
[[File:Evolution_of_Base_IMG_0030.JPG|800px]]
 +
 +
The problems mentioned further below led to this design:
 +
 +
[[File:Modified_Base-IMG_0036.JPG|400px]]
 +
 +
= Legtest 2=
 +
The three parts of a leg have been connected to the ports 10,11 and 12 and then the test was started with:
 +
<source lang='bash'>sudo python3 testadafruit.py 10 11 12 60-120</source>
 +
<HTML5video width="960" height="600" controls autoplay="false" loop="false">legtest2019-07-25</HTML5video>
 +
 +
= Wiring =
 +
Breadboard - style wiring before designing a proper holder:
 +
 +
[[File:Wiring-IMG_0035.JPG|960px]]
 +
 +
In this state of affairs:
 +
# the power input of the raspberry is blocked by a servo - needs to be moved by at least 13 mm
 +
# the corner hinges are to close to the corners of the servo holders
 +
# the pivots to be used for the next level are blocking e.g. the usb connectors
  
 
= What Links Here =
 
= What Links Here =
 
{{WhatLinksHere}}
 
{{WhatLinksHere}}
 
[[Category:Raspberry]]
 
[[Category:Raspberry]]

Latest revision as of 20:03, 19 January 2020

OsProject
id  PI-Q-Robot
state  
owner  BITPlan
title  Raspberry PI controlled Quadruped Robot with 3D Simulator
url  https://github.com/BITPlan/PI-Q-Robot
version  0.0.1
description  
date  2019-08-07
since  
until  

Click here to comment see Self Driving RC Car

Inspired by the Arduino Project below we'd like to create a Raspberry PI version as in https://github.com/yasaspeiris/aragog

Video

Simulator

Calibration

Restful interface

http://<baseurl>/servo/<servoid>/<angle> will set the angle of a single servo

Servo numbering scheme

This is the default numbering schema as configured in the software. If your servos are mounted or cabled differently you might want o adjust the code a accordingly

ServoId Leg Extrimity Inverted
0 1 Coxa
1 1 Femur x
2 1 Tibia x
3 2 Coxa
4 2 Femur x
5 2 Tibia x
6 3 Coxa
7 3 Femur
8 3 Tibia
9 4 Coxa
10 4 Femur
11 4 Tibia

Calibration Range

Extremity Servo Angle Position Direction Range
Coxa 90 45° left to right 0°-180°
Femur 90 Flat up to down 0°-180°
Tibia 90 Flat down to up 0°-180°

Relevant source code

class Spider:
    """ I am a quadruped spider with four legs consisting of coxa, femur and tibia each"""
    def __init__(self):
        self.fl = Leg(0, 0,  1,  2)
        self.fr = Leg(1, 3,  4,  5)
        self.rl = Leg(2, 6,  7,  8)
        self.rr = Leg(3, 9, 10, 11)

...
class Leg:
    """ I am a single leg of the spider consisting of coxa, femur and tibia"""
    def __init__(self, legId,coxaId, femurId, tibiaId):
        self.legId=legId
        self.coxa = Extremity('coxa', coxaId)
        self.femur = Extremity('femur', femurId,legId<2)
        self.tibia = Extremity('tibia', tibiaId,legId<2)

...
class Servo:
    """ I am a single Servo motor """
    def __init__(self, id,inverted=False):
        self.id = id
        self.inverted=inverted

    def setAngle(self, angle):
        self.angle = angle
        trueAngle=180-angle if self.inverted else angle
        if kit is not None:
            kit.servo[self.id].angle = trueAngle
        return trueAngle

Links

Other

Parts

# picture part example sources documents ~ price
1 713LX1Z383L. SL1500 .jpg Raspberry PI 3 B+ Raspberry PI 3 B+ en 35 €
2 81UBu4aoQHL. SL1500 .jpg microSD Card SanDisk 16 GB 7 €
3 61Z5yEYfnAL. SL1426 .jpg Raspberry PI Camera 1080 p Camera Module 23 €
4 41smcErJNjL.jpg DC/DC Converter 12 V-> 5V 12 V->5 V Converter Module 7 €
5 31pzC7A3D3L.jpg Micro USB Connector Delock USB 2.0 Micro USB 6 €
6 SpiderBot-Parts-IMG 0033.JPG 3D Printed Parts: Coxa, Tibia, Femur, Hinge parts from regishu's design
7 61B2dK96ysL. SL1000 .jpg Adafruit PCA9685 16 channel PWM controller PCA9685 6.5 €
8 61yfILxEkgL. SX679 .jpg set of small screws set of small screws 8.5 €
9 71a1K3RQuqL. SX679 .jpg 12 x MG90S 12 x MG90s 42 €
Total ~ 135 €
a 71AYEqpWHcL. SL1500 .jpg Breadbord Kit MB102 Breadbord Kit 7 €
b 714Ep9LpwoL. SL1200 .jpg Ulrasound Sensor 5 x HC-SR04 + Cables 10 €

Printing

You might want to make sure that you print your parts with sufficient infill - I used 75%.

SpiderBotParts-IMG 0028.jpeg

Example for broken part

This part was printed with Cura's default infill and broke off:

Broken-IMG 0034.JPG

Assembly

  • Legs and hinges are connected with 1.4x5mm screws
  • Legs and servos are connected with 1.7x6mm screws

Leg IMG 0029.JPG LegConnection-IMG 0030.JPG

We use the raspberry base from https://github.com/yasaspeiris/aragog/blob/master/3d%20printed%20parts/base.STL

Plate-IMG 0033.JPG

Leg Test

sudo python3 testadafruit.py 0 1 2 3  0

Legs0-IMG 0030.JPG

sudo python3 testadafruit.py 0 1 2 3  90

Legs90-IMG 0031.JPG

sudo python3 testadafruit.py 0 1 2 3  180

Legs180-IMG 0032.JPG

testadafruit.py

# Test Adafruit 
# WF 2019-07-09
import sys
import time
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)

# 
# set the given angle for the given servos
#
def setAngle(servos,angle):
  print (angle)
  for id in servos:
    kit.servo[id].angle=angle
  time.sleep(0.3)

# Test Servo Software
servos=[]
args=len(sys.argv)
fromangle=0
toangle=180
step=1
if args>1:
  for port in range(1,args-1,1):
    servos.append(int(sys.argv[port]))
  anglestr=sys.argv[args-1]
  if "-" in anglestr:
    parts=anglestr.split("-") 
    fromangle=int(parts[0])
    toangle=int(parts[1])
  else:
    fromangle=int(anglestr)
    toangle=fromangle
else:
  servos.append(0)
  servos.append(1)
  servos.append(2)

if fromangle!=toangle:
  try:
    while True:
      for setangle in range(fromangle,toangle+step,step):
        setAngle(servos,setangle)
  except KeyboardInterrupt:
    print("Keyboard interrupt")
else:
  setAngle(servos,fromangle)

Evolution of Base

Since we'd like to use a Raspberry PI we couldn't use the orignal Base by regishu. Trying the one from https://github.com/yasaspeiris/aragog also did not work since our raspberry PI case had a different size. So incrementally a new design was created:

Evolution of Base IMG 0030.JPG

The problems mentioned further below led to this design:

Modified Base-IMG 0036.JPG

Legtest 2

The three parts of a leg have been connected to the ports 10,11 and 12 and then the test was started with:

sudo python3 testadafruit.py 10 11 12 60-120

Wiring

Breadboard - style wiring before designing a proper holder:

Wiring-IMG 0035.JPG

In this state of affairs:

  1. the power input of the raspberry is blocked by a servo - needs to be moved by at least 13 mm
  2. the corner hinges are to close to the corners of the servo holders
  3. the pivots to be used for the next level are blocking e.g. the usb connectors

What Links Here