Difference between revisions of "Raspberry PI Spiderbot"

From BITPlan Wiki
Jump to navigation Jump to search
Line 14: Line 14:
 
[[File:Leg_IMG_0029.JPG|400px]]
 
[[File:Leg_IMG_0029.JPG|400px]]
 
[[File:LegConnection-IMG_0030.JPG]]
 
[[File:LegConnection-IMG_0030.JPG]]
 +
= Leg Test =
 +
<source lang='python'>
 +
# 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)
 +
</source>
 
[[Category:Raspberry]]
 
[[Category:Raspberry]]

Revision as of 17:36, 23 July 2019

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

Video

Links

Parts

SpiderBotParts-IMG 0028.jpeg

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

Leg Test

# 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)