6 legged 3DOF Spiderbot
Carol Hazlett
Posts: 312
This has been an overwhelming project for me. I've learned a lot by even attempting it and still have a ways to go! The body is built using the Minds-i building system (mymindsicom) with a BOE for brains and two Prop Servo Controllers for the legs and Pings. I have it doing some simple movements but haven't been able to program a decent looking gait yet. It is really a prototype yet as I am thinking of switching to a Propeller board for the brains. There is an incompatibility in voltage between the Prop Servo Controllers and the Propeller BOE I have to address first. That and I am still new to Spin. Here is some code I have written for the spider, and all suggestions and advice will be gladly welcomed.
I haven't annotated this code yet. This was a little demo of the spider twisting his shoulders and moving his body up and down. You can see videos of this project as it progressed at facebook.com/Robothon or facebook.com/CarolLynnHazlett.
' {$STAMP BS2} ' {$PBASIC 2.5} ch VAR Byte pw VAR Word ra VAR Byte twist VAR Byte Sdat1 CON 14 Sdat2 CON 15 Baud CON 396 FRHip CON 10 FRKnee CON 11 FRFoot CON 5 MRHip CON 8 MRKnee CON 9 MRFoot CON 4 RRHip CON 6 RRKnee CON 7 RRFoot CON 3 FLHip CON 4 FLKnee CON 5 FLFoot CON 2 MLHip CON 2 MLKnee CON 3 MLFoot CON 1 RLHip CON 0 RLKnee CON 1 RLFoot CON 0 Main: twist = 1 GOSUB Stance GOSUB High_Stance FOR twist = 1 TO 3 GOSUB Twist_Left GOSUB Twist_Right NEXT GOSUB Stance FOR twist = 1 TO 3 GOSUB Twist_Left GOSUB Twist_Right next GOSUB Stance END Stance: '--------------Front left leg-------------------------------------------- ra = 11 pw = 780 SEROUT Sdat1, Baud+$8000,["!SC", FLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 1000 SEROUT Sdat1, Baud+$8000,["!SC", FLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 550 SEROUT Sdat2, Baud+$8000,["!SC", FLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '--------------Middle left leg------------------------------------------- ra = 11 pw = 720 SEROUT Sdat1, Baud+$8000,["!SC", MLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 1000 SEROUT Sdat1, Baud+$8000,["!SC", MLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 550 SEROUT Sdat2, Baud+$8000,["!SC", MLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '--------------Rear left leg--------------------------------------------- ra = 11 pw = 750 SEROUT Sdat1, Baud+$8000,["!SC", RLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 1000 SEROUT Sdat1, Baud+$8000,["!SC", RLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 600 SEROUT Sdat2, Baud+$8000,["!SC", RLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '---------------Front right leg------------------------------------------ ra = 11 pw = 720 SEROUT Sdat1, Baud+$8000,["!SC", FRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 500 SEROUT Sdat1, Baud+$8000,["!SC", FRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 850 SEROUT Sdat2, Baud+$8000,["!SC", FRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '----------------Middle right leg--------------------------------------- ra =11 pw = 750 SEROUT Sdat1, Baud+$8000,["!SC", MRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 500 SEROUT Sdat1, Baud+$8000,["!SC", MRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 930 SEROUT Sdat2, Baud+$8000,["!SC", MRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '----------------Rear right leg------------------------------------------ ra = 11 pw = 750 SEROUT Sdat1, Baud+$8000,["!SC", RRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 500 SEROUT Sdat1, Baud+$8000,["!SC", RRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 930 SEROUT Sdat2, Baud+$8000,["!SC", RRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 RETURN Twist_Right: ra = 10 pw = 900 SEROUT Sdat1, Baud+$8000,["!SC", FLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 850 SEROUT Sdat1, Baud+$8000,["!SC", MLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 850 SEROUT Sdat1, Baud+$8000,["!SC", RLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 800 SEROUT Sdat1, Baud+$8000,["!SC", FRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 850 SEROUT Sdat1, Baud+$8000,["!SC", MRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 850 SEROUT Sdat1, Baud+$8000,["!SC", RRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 RETURN Twist_Left: ra = 10 pw = 650 SEROUT Sdat1, Baud+$8000,["!SC", FLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 600 SEROUT Sdat1, Baud+$8000,["!SC", MLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 600 SEROUT Sdat1, Baud+$8000,["!SC", RLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 550 SEROUT Sdat1, Baud+$8000,["!SC", FRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 600 SEROUT Sdat1, Baud+$8000,["!SC", MRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 600 SEROUT Sdat1, Baud+$8000,["!SC", RRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 RETURN Lower_Body: '--------------Front left leg-------------------------------------------- ra = 11 pw = 780 SEROUT Sdat1, Baud+$8000,["!SC", FLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 700 SEROUT Sdat1, Baud+$8000,["!SC", FLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 300 SEROUT Sdat2, Baud+$8000,["!SC", FLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '--------------Middle left leg------------------------------------------- ra = 11 pw = 720 SEROUT Sdat1, Baud+$8000,["!SC", MLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 700 SEROUT Sdat1, Baud+$8000,["!SC", MLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 300 SEROUT Sdat2, Baud+$8000,["!SC", MLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '--------------Rear left leg--------------------------------------------- ra = 11 pw = 750 SEROUT Sdat1, Baud+$8000,["!SC", RLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 700 SEROUT Sdat1, Baud+$8000,["!SC", RLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 300 SEROUT Sdat2, Baud+$8000,["!SC", RLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '---------------Front right leg------------------------------------------ ra = 11 pw = 700 SEROUT Sdat1, Baud+$8000,["!SC", FRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 800 SEROUT Sdat1, Baud+$8000,["!SC", FRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 1200 SEROUT Sdat2, Baud+$8000,["!SC", FRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '----------------Middle right leg--------------------------------------- ra =11 pw = 750 SEROUT Sdat1, Baud+$8000,["!SC", MRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 800 SEROUT Sdat1, Baud+$8000,["!SC", MRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 1200 SEROUT Sdat2, Baud+$8000,["!SC", MRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '----------------Rear right leg------------------------------------------ ra = 11 pw = 750 SEROUT Sdat1, Baud+$8000,["!SC", RRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 800 SEROUT Sdat1, Baud+$8000,["!SC", RRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 1200 SEROUT Sdat2, Baud+$8000,["!SC", RRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 RETURN High_Stance: '--------------Front left leg-------------------------------------------- ra = 11 pw = 780 SEROUT Sdat1, Baud+$8000,["!SC", FLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 1200 SEROUT Sdat1, Baud+$8000,["!SC", FLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 750 SEROUT Sdat2, Baud+$8000,["!SC", FLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '--------------Middle left leg------------------------------------------- ra = 11 pw = 720 SEROUT Sdat1, Baud+$8000,["!SC", MLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 1200 SEROUT Sdat1, Baud+$8000,["!SC", MLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 750 SEROUT Sdat2, Baud+$8000,["!SC", MLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '--------------Rear left leg--------------------------------------------- ra = 11 pw = 750 SEROUT Sdat1, Baud+$8000,["!SC", RLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 1170 SEROUT Sdat1, Baud+$8000,["!SC", RLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 750 SEROUT Sdat2, Baud+$8000,["!SC", RLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '---------------Front right leg------------------------------------------ ra = 11 pw = 720 SEROUT Sdat1, Baud+$8000,["!SC", FRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 300 SEROUT Sdat1, Baud+$8000,["!SC", FRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 650 SEROUT Sdat2, Baud+$8000,["!SC", FRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '----------------Middle right leg--------------------------------------- ra =11 pw = 750 SEROUT Sdat1, Baud+$8000,["!SC", MRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 300 SEROUT Sdat1, Baud+$8000,["!SC", MRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 750 SEROUT Sdat2, Baud+$8000,["!SC", MRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 '----------------Rear right leg------------------------------------------ ra = 11 pw = 750 SEROUT Sdat1, Baud+$8000,["!SC", RRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 320 SEROUT Sdat1, Baud+$8000,["!SC", RRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] pw = 730 SEROUT Sdat2, Baud+$8000,["!SC", RRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR] PAUSE 500 RETURN
I haven't annotated this code yet. This was a little demo of the spider twisting his shoulders and moving his body up and down. You can see videos of this project as it progressed at facebook.com/Robothon or facebook.com/CarolLynnHazlett.
Comments
Will she she know when her feet are on the ground? For example, "stance" on an uneven surface?
Have you worked out the algorithm for controlling the gait yet?
I'm working on my second hexapod right now. The programming is kind of mind boggling. While I'm trying to come up with code on my own for the fun of it, there is code available to control a hexapod with a Propeller.
Even with your servo control boards, I think a hexapod is a bit much for a BS2 to try to control.
What incompatibility is this? Most 5V devices see the 3.3V output from a Propeller as logic high and the Propeller can receive 5V logic if a series resistor of 4.7K or more is used. I know the Scribbler 2's level shifters interfere with its ability to interface with a Ping, but I don't know if the PSC would have a problem communicating with a Ping or not.
I'd think you could probably use one of your PSC boards as the main brain for your bot so you wouldn't even need to purchase another Propeller board to upgrade the brains of your hexapod. If you do want to use a third Propeller board there are several options. The PropBOE has lots of cool features that would likely come in handy with your robot. The main downside to the PropBOE is that many of the IO pins are used by the devices on the board so only 20 of the 32 IO pins are available to use to directly control servos. This wouldn't be a problem in your case since you have the PSC boards.
I'm using a Propeller Proto board on my current hexapod, but I used a QuickStart board to control my popsicle stick hexapod.
Whichever Propeller board you use, I doubt it would have a problem interfacing with your PSC boards.
IIRC, you were planning on using the software that comes with the PSCs to program the positions of each servo as it walks. I'd think trying to assign a position to each servo as the robot walks would be exceedingly tedious. I think an equation that expresses the way you want the servos to move would be a lot easier (though far from easy).
Ideally, you don't want the feet of the hexapod to slide on the ground as it walks. It should move its legs together in unison while keeping the feet from sliding on the ground. This generally requires inverse kinematics.
Have you seen what Paul K's hexapods can do? I think they're amazing. Paul has posted his code for controlling hexapods so you wouldn't need to come up the the equations yourself.
I just watched a few of your hexapod videos. I think the center positions of your servos are different than the way Paul and myself have ours centered. I think Paul's code would still work with your robot, but it might need to be modified a little.
Your robot looks cool just standing there; I think it's going to be a lot of fun to see it walk.