PDA

View Full Version : [Project] Quad 4DOF Mech - Immortal



cire
09-25-2010, 12:32 PM
After several years of saying I'm going to build a robot for a competition, I finally decided to go for it at the beginning of September. Mech Warfare looked like the sweetest thing since I saw it a few months ago on Botjunkie.com.

One of my main goals for this project is to learn more about electronics and programming. I have been exposed a bit to both before, but I still don't really know what I'm doing in either. Hopefully I can take away some new knowledge from this project.


After much research I decided that I'd buy a Bioloid kit since it comes with enough servo's to make a good bot and I would be able to try out a walking robot before I start designing the rest of my robot, since I've only dealt with wheeled robots before.


Edit <Added pictures of my Bioloid adventures>

The first thing I did when I got the Bioloid kit was build the humanoid, which was pretty cool. I spent a day or two playing around Robotis programs. I installed Roboplus and made some pretty cool actions.


I found it really hard to get the biped walking good, so i decided I would start off with a quadraped since this is my first step into walking robots. Here is gen 1 quad:
http://forums.trossenrobotics.com/gallery/files/4/7/8/5/100_0163.jpg



I didn't quite like my setup, I wanted to bring the legs in a little closer so I rebuilt it using the same sort of setup that the ankles of the bioloid kit has, I also added supper bouncy balls as feet since I thought it would be cool:

http://forums.trossenrobotics.com/gallery/files/4/7/8/5/100_0166.jpg


I didn't like the lack of freedom the legs had though, and this was when I decided that I should make my bot like an Immortal from Starcraft 2, bringing my other hobby of playing video games into my hobby of building robots :D

http://forums.trossenrobotics.com/gallery/files/4/7/8/5/100_0169.jpg

The shoulder joints are all very close to the center, and the legs can extend out very long.



Starcraft 2 unit "Immortal" in the map editor:

http://img180.imageshack.us/img180/4364/immortal3d.th.png (http://img180.imageshack.us/i/immortal3d.png/)

I have used this to analyze what basic shape the Immortal has, and its walking animations. I didn't really have very high hopes on the walking animation actually being useful, since its an video game and not the real world. I decided to use the Bioloid motion tools to make it walk like the immortal anyways, and it turns out that it worked REALLY well. I will post a video when my card reader gets here. It is pretty much the sweetest thing ever, although I am slightly worried if I'll be able to program it.

Here is the video of the immortal mock up walking:

YouTube - Immortal Walking


I tried to keep to the shape of the Immortal as close as possible, just because I think its cool. Eventually I want to put some sort of shell on it so it can look just like the real thing.

After I proved that it could walk, I started making the actual design in SolidWorks, it is by no means complete yet, but here is the current progress (as of this post):

http://img684.imageshack.us/i/immortalcad1.png/http://img684.imageshack.us/img684/4854/immortalcad1.png (http://img684.imageshack.us/i/immortalcad1.png/)

Question - Are those target plate position legal (red squares)? I know the rules say they have to be on your turret if you have one, but I don't want to add more weight to the turret :sad:. Although I know that the legs might interfere with the targets. Right now I am looking at having 2 tank guns, one on each side of the turret. If anyone has 3d models for those tank guns, it would be helpful!


The majority is either purchased parts or sheet metal parts that I will probably have bigbluesaw.com waterjet for me. I have limited access to tooling in my apartment so outsourcing the majority is required. I plan on buying a small brake to bend all the brackets.

My next steps are:
Finish CAD Model
Learn how to use my Arbotix
Buy a soldering Iron (I'm not even sure what I'll have to do electronic wise)
many more...


Thanks for reading!

~ Cire

cire
09-26-2010, 02:13 PM
I decided to revisit my legs and make them using a sheet metal method similar to whats used on aircraft. Instead of having thick pieces to make a sort of frame I used thinner material and made a skin for the the legs, which also allowed me to make it much closer to what the "real" thing looks like too. Overall it weighs 40 grams less as well. It will make bending the brackets much more challenging though...

http://img97.imageshack.us/img97/9798/newlegs.png (http://img97.imageshack.us/i/newlegs.png/)

Xevel
09-27-2010, 01:37 AM
This looks nice!
The second version looks much more impressive (huge legs!). I look forward to see how it will evolves.

Stobs
09-28-2010, 10:44 PM
I was wonder what drawing program you used for this cire? [Edit: SolidWorks; that's what I get for not reading the entire post & all posts in the thread first! :/] Were the servos and other pieces part of an included/add-on library, or did you create them yourself as an item/object?

cire
09-28-2010, 11:03 PM
I was wonder what drawing program you used for this cire? [Edit: SolidWorks; that's what I get for not reading the entire post & all posts in the thread first! :/] Were the servos and other pieces part of an included/add-on library, or did you create them yourself as an item/object?

I downloaded all of the brackets from Trossen's website, if you click on the individual brackets in the store you can download a zip file with an Inventor part and a SolidWorks part for all the brackets as well as the servo's. Although the ax12 link wasn't working so I downloaded it from another website, of which I cannot remember right now.

Stobs
09-29-2010, 01:14 PM
Thanks for the reply cire, much appreciated.

cire
09-30-2010, 08:09 PM
I got my card reader today, and I uploaded some better pictures and a video of it walking! (In the first post)

And your welcome Stobs

cire
10-13-2010, 08:54 PM
Its been a while since I updated this, but heres what I've been up to:

I got my battery and Arbotix all set up and got code working with some help from Fergs, although I still haven't been able to get it to walk with the NUKE code, something I will work on later. For now I have just been ignore the foot servo on each leg so I can use the 3dof code.

Last Friday I got my parts in from BigBlueSaw, which is quite impressive how fast they got those here... Here is a picture of each unique part straight from the box:

http://forums.trossenrobotics.com/gallery/files/4/7/8/5/100_0203_thumb.jpg (http://forums.trossenrobotics.com/gallery/showimage.php?i=3311&c=member&imageuser=4785)


I opted not to pay for a basic finish, so I spent a couple days filing all those rough edges down. Everything seemed to fit pretty well, although all of the holes for bearings had to be cleaned a bit to make sure they fit properly. The first thing I did was assemble Immortals chassis with the existing Bioloid legs I had made previously, and all the servo's fit properly. The chassis is quite rigid, even though the material is only 0.040" thick, mostly due to the fact that theres 5 servo's acting as spacers between the two sheets. I was also impressed at how good the "IMMORTAL" Lettering came out, I just imported StarCraft font directly into my model, and the only part that got cut out was the O, everything else stayed in tact.

On Monday I got my 24" Finger brake from Grizzly, It was pretty much ready to go straight out of the box. Since I am using 6061 Aluminum I made a few test bends before I went ahead and started bending my waterjet parts, and I was quite happy with the bends I was getting, as long as I left a decent gab between the apron and the finger knife edge. The radius is sufficient enough for the thin material to not crack, but still be a good bend.

Now I had my parts profiled out, and my brake, I started bending the parts.. This is when reality set in and I realized what I was too afraid to think about before, the fact that none of my parts can actualy be completely bent by a my little finger brake... Either it was interference with the short fingers, or just interference within the part itself, I had lots of issues with all the parts. One prime example is the foot, The way its layed out I had to bend the triangle portion and the servo mounting portions about 10 degrees at a time, so that I didn't deform the foot. This wasn't too bad though, since I only have to make 4 of them. The other big one is the shoulder bracket, which I had already known was impossible to bend since its essentialy a tube. I managed to get around these by bending them mostly on the brake, and then finishing off the bend by hand or adjustable wrench. Here are some of the first parts I bent, before the finishing touches by hand:

http://forums.trossenrobotics.com/gallery/files/4/7/8/5/100_0206_thumb.jpg (http://forums.trossenrobotics.com/gallery/showimage.php?i=3313&c=member&imageuser=4785)


Here is the first leg I put together, which also brought a bunch of realities I hadn't really thought about before when I designed it. First off, its an extreme pain to assemble the portions where I have to put 4 screws in with 2 spacers on each, on the far inside of the leg where the servo makes it impossible to get anything in there. I spent a really long time getting it together. The other thing, is that the shortest screws that come with the Bioloid kit are actually too long when bolting into the servo horns, because the sheet metal is so thin the bolts just barely run into the face of the servo... It took me a while to realize why the servo's were so hard to turn, and then I noticed little bits of black plastic coming out of them... So I temporary have solved this by using longer screws and my spacers.

http://forums.trossenrobotics.com/gallery/files/4/7/8/5/100_0204_thumb.jpg (http://forums.trossenrobotics.com/gallery/showimage.php?i=3312&c=member&imageuser=4785)


Here is the robot chassis, with 3 Bioloid legs attached, and the new leg next to it. I also have the Arbotix and battery mounted underneath, which you can't really see in the picture.

http://forums.trossenrobotics.com/gallery/files/4/7/8/5/100_0208_thumb.jpg (http://forums.trossenrobotics.com/gallery/showimage.php?i=3314&c=member&imageuser=4785)


Also, an updated Solidworks Model of Immortal, currently with 2 defenders up top... I haven't picked out the details for my guns fully yet.

http://forums.trossenrobotics.com/gallery/files/4/7/8/5/screenshot141_thumb.png (http://forums.trossenrobotics.com/gallery/showimage.php?i=3315&c=3)


I still have a ton to do, but Its starting to take shape now!

Stobs
10-13-2010, 10:09 PM
cire, did you use the same servos as original to the Bioloid kit to build Immortal, or did you change them up along with the (SWEET!) brackets? Project's looking good!

Stobs/Paul

[PS: am I misinterpreting the drawing or are the scoring panels going to cover up the "Immortal" plates? ^.o]

DresnerRobotics
10-13-2010, 10:10 PM
Really fantastic job, as a big Starcraft fan I can't wait to see this thing come to life!

cire
10-13-2010, 10:19 PM
cire, did you use the same servos as original to the Bioloid kit to build Immortal, or did you change them up along with the (SWEET!) brackets? Project's looking good!

Stobs/Paul

[PS: am I misinterpreting the drawing or are the scoring panels going to cover up the "Immortal" plates? ^.o]

I am using the same Ax-12+ Servo's, the reason I bought the Bioloid kit was because I was going to use AX-12's in the final mech. The kit just helped me save a lot of headache with understanding how the thing actually would walk before trying to put the design on a drawing to be built.

Yeah, those "Immortal" plates are really just to mount the scoring panels on. I ended up only getting the words put in one plate since it added quite a bit onto the waterjet cost and I wasn't sure if it was going to turn out any good (but it did). However, I don't always plan on having the target plates mounted, so it will still be visible some of the time.

DresnerRobotics
10-13-2010, 10:20 PM
I am using the same Ax-12+ Servo's, the reason I bought the Bioloid kit was because I was going to use AX-12's in the final mech. The kit just helped me save a lot of headache with understanding how the thing actually would walk before trying to put the design on a drawing to be built.

Yeah, those "Immortal" plates are really just to mount the scoring panels on. I ended up only getting the words put in one plate since it added quite a bit onto the waterjet cost and I wasn't sure if it was going to turn out any good (but it did). However, I don't always plan on having the target plates mounted, so it will still be visible some of the time.

As I've said before, think of target plates as a sports jersey, really only needs to be one when competing.

cire
10-20-2010, 09:33 PM
Last week I got my new legs all assembled and mounted onto the bot, everything looked pretty sweet! Here is a picture of it fully assembled:

http://forums.trossenrobotics.com/gallery/files/4/7/8/5/100_0214_thumb.jpg (http://forums.trossenrobotics.com/gallery/showimage.php?i=3331&c=3)


I then finally started playing around with NUKE and got the basic export working, using 3DOF and ignoring the feet. Here is a video of it walking around with the base export:

YouTube - Immortal Gets New Legs and Brains

I found two issues with my design/construction from this test. I wasn't satisfied with the range of motion I had on my coax joints due to the servo design, and those same joints were also too flimsy due to the fact that I haven't closed the gap in the tube yet. So it is back to the drawing board for those brackets, and I have put Bioloid brackets back in for now. I then modified the code to add the 4th DOF into the IK solver. This was pretty simple as I just want the feet to always be vertical. I think this may be an advantage over 3DOF because it allows me to stick my legs straight out and still have a very good mechanical footing on the ground. Oh, and it looks sweet?

Here is the video of Immortal with its 4th DOF and a little slower walk with a longer stride:

YouTube - Immortal Gets 4DOF Inverse Kinematics

I plan on making a new gait so that the leg has 2 positions in the air, so that it doesn't push the bot backwards whenever the leg comes down like it currently does. This is how I did it on my mock up and it worked amazingly well, the leg essentially moves straight down to its final position. I don't think I would have understood the gait nearly as much if I never made the mock up, so I am very happy that I bought the Bioloid kit.

Once I get the walking somewhat closer to what I think it should look like, I will start working on the turret more and maybe even something to control it with.

Special thanks to Fergs for the help troubleshooting NUKE and helping me understand the code :)

mannyr7
10-21-2010, 09:57 AM
It has a very industrial look to it. I like!

cire
10-31-2010, 10:16 PM
I added the turret and redid my gaits as the weight increase does effect gait performance. I ended up changing it to be a 8 step gait again more similar to the original NUKE export. I have decided to have 2 different codes, one with "show" walking and one for competition, since I don't want to sacrifice performance.

I have put together a video showing a bit of the early steps and the progress of the robot up to this point.

YouTube - Presenting Immortal The Robot


List of things to do:
1. Figure out how to mount the camera and gun on the turret properly
2. Mount some electronics so they aren't just hanging out of the bot.
3. Get a control system working with joysticks (up to this point I have just been using the NUKE test drive tool)
4. Acquire and mount Target Plates
5. Get power hooked up to my camera and gun(s?)
6. Make a hopper for my gun
7. Optimize gait once everything is mounted.
8. Many more...

Stobs
11-01-2010, 10:13 AM
Awesome job cire! I love it! Looks great, neat video, working well, what more could you ask for in a work-in-progress! +rep!

Stobs/Paul

cire
02-07-2011, 12:47 AM
Well I haven't posted an update for a while, mainly because I didn't work on it at all during December and half of January due to the holidays and whatnot. But since then - I have been busy! Mostly with electronics, and I have to thank Jes, Fergs, Andrew, Gary, and DB for all helping me out with the various issues I've had in the last 3 weeks...

I spent a lot of time trying to come up with a solution to power my guns, at first I bought a battleswitch, but it went up in smoke (literally, but it was my fault). So then I gave the arbotix motor driver a try, but I accidentally shorted it when measuring a voltage, and it also went up in smoke (the rest of the Arbotix was fine). Also because I have one of my tank guns modified to shoot faster the motor driver probably wouldn't have worked anyways. So at this point I decided to make the circuit Jes created for driving motors, with using an adjustable voltage regulator so I could manually change the speed of the guns if I so felt the need to. This was the first custom circuit board I have ever made, and I ran into a bunch of challenges mainly in wiring things to the wrong places (Ok, that was all my issues) Luckily I did not fry anything though.

Close up picture of my motor driver board:
http://img821.imageshack.us/img821/7872/1000295d.jpg

After I got the gun driver working, I added a few lines to my program to make it so my brand new Arbotix Commander v2.0 could shoot them by the press of a button. This was very simple, but I spent a lot of time on it because I had unplugged all of my ax12's and the program was checking the voltage off of them, and stopping the program because it couldn't find them.

I got my commander pre-assembled by Andrew himself because I was the first one to order one, although that is not typical. It was very easy to set up, all I had to do was plug in my paired xbee and My bot was driving around with joysticks. I decided to go with the commander because I do not want to have to bring my laptop with me every time I show it off to people, and the thing is rock solid.

http://img812.imageshack.us/img812/6255/1000298u.jpg

I also made new hoppers because I wasn't satisfied with my previous attempt. I first modeled them up in solidworks as a sheet metal part and then printed out a 1:1 scale flat pattern. I taped this pattern to some 1/32" aluminum sheet and cut it out with tin snips, and bent it using my mini box pan brake. They came out a lot nicer then the previous ones. This method of manufacturing sheet metal parts is quite easy and does not require any expensive equipment - you can do it with a 5$ pair of tin snips and a printer.

Part cut out with tin snips:
http://img138.imageshack.us/img138/8729/1000304e.jpg


Once I got the guns working, I rewired the bot so I could route everything inside rather then going outside. A few holes and a couple hours later I have this:

Organized Chaos (mounting the motor driver, wiring everything):
http://img39.imageshack.us/img39/6422/1000310f.jpg

The Electronics are now mostly mounted! I just need to clean up the wiring for the power, rather then having it hang out the side of the bot. I also need to mount the scoring system, but I made sure there was room inside the bot to mount it, and also have 2 wires already setup coming off the same 5v regulator that powers my camera.

Here is the current state of Immortal:
http://img209.imageshack.us/img209/9954/1000317n.jpg (http://img209.imageshack.us/i/1000317n.jpg/)


I also have some video, but it is too late to post that tonight!

Zenta
02-07-2011, 05:35 AM
Hi,

Your quad looks really great! Fun to see a 4 DOF crawler.
Very well made.

Looking forward to see a video.:)

gdubb2
02-07-2011, 11:00 AM
Very nicely done Cire..

Gary

jes1510
02-07-2011, 12:28 PM
Awesome work! That thing looks like a tank!

cire
02-08-2011, 08:46 PM
I have posted a new video of Immortal walking around and shooting. The Commander makes it about 10x easier to control precisely, although I have a few modifications I want to do to the code still - fine control on the turret is a big thing I think I could use. I also need to buy a new wireless router so I can test driving it without looking at it directly.

YouTube - Mech Warfare Robot - Immortal


1. Paint Job? (deciding whether I should do this or not)
2. Target panels - 50% done (mounting brackets, transponder location, and power line already wired)
3. More Gait optimization
4. Controls tweaking, additions (Fine turret control, more controls for controlling guns separately, changing walking style, walking speed.)
5. Practice! (and reliability testing)
6. Add more protective cable sheathes on exposed wires.
7. Counter weight springs on shoulder joints (probably next year)
8. Shield for Camera lens
9. Feet pads
10. more...

mannyr7
02-09-2011, 08:18 AM
All i can say is Wow!

DresnerRobotics
02-09-2011, 10:01 AM
You have to bring this to the WV event!

gdubb2
02-09-2011, 10:20 AM
Very nicely done..

Gary

Zenta
02-09-2011, 10:40 AM
Very impressive control and movement!
Great work.

elaughlin
02-09-2011, 11:52 AM
I really like it cire. It works well and came out nicely to look like the immortal from starcraft. Well done my friend.

Did you use Nuke/Pypose for the walking sequences? If so, how did you incorporate the 4 DOF legs?

As for paint, I dont know that you want to cover the aluminum up so much, I like the clean metal look personally, but the white bioloid brackets look a little out of place. I dont know what color they could be though, since the dye colors are somewhat limited. Maybe black...? Looking good though man. I can't wait til mine is ready like yours.

Congrats on getting it there!

cire
02-09-2011, 06:20 PM
I really like it cire. It works well and came out nicely to look like the immortal from starcraft. Well done my friend.

Did you use Nuke/Pypose for the walking sequences? If so, how did you incorporate the 4 DOF legs?

As for paint, I dont know that you want to cover the aluminum up so much, I like the clean metal look personally, but the white bioloid brackets look a little out of place. I dont know what color they could be though, since the dye colors are somewhat limited. Maybe black...? Looking good though man. I can't wait til mine is ready like yours.

Congrats on getting it there!

Thanks guys!

I use NUKE, to add the 4th degree I made it so the foot always stays vertical, which is as easy as adding the angles of the other 2 servo's in the same plane. I did have a few issues with the range of motion of my servo's due to my bracket size. The main advantage of the 4th degree is it looks cool, but it also makes it the foot is always in the same orientation when it touches the ground.. Which I think may be of some advantage.

As for paint, maybe I wont paint the aluminum. I have been meaning to replace the bioloid brackets with some new aluminum ones, I had some in my original design but they were not stiff enough without being welded shut.

elaughlin
02-09-2011, 06:35 PM
Do you have access to a TIG welder? When I first started thinking of making a Mech and saw Giger, I wanted an all aluminum robot that I would weld together. I am a proficient MIG welder and started practicing TIG welding for my robot, but scraped the idea, and stopped practicing. But TIG welding is a great skill to know. I would be really jealous if you had that equipment.

cire
02-09-2011, 07:56 PM
Teaser:

http://img209.imageshack.us/img209/2243/screenshot180.png

cire
02-13-2011, 10:50 PM
I have been working on a 3d printed gun shell for the defender, since Andrew got a 3d printer and there is definitely a need for easier to mount defender guns. The way I made it was by modeling all the individual parts, and then looking at how I could mount them within a gun. It turns out the defender pretty much has the optimum layout inside for the parts because otherwise they would interfere with each other.

The part itself isn't quite finished, I just need to add a few more structural ribs. I also need to print one to verify everything works properly - there is a lot of geometry in the part that requires a pretty high tolerance, which I am unsure if a hobby 3d printer can handle. Right now I have the holes that hold the shafts for the gears smaller then required, so they can be drilled out to the proper size afterward, they need to be a press fit. If a 3d printer can handle +/- .003" then I may not need to do that.

I am undecided where/or if i should add the mounts. I could make something that mounts directly onto a ax12, or onto a bioloid bracket, although I think everyone that uses this will probably want to mount it differently, so I hope people can just modify the model before printing to their needs.

Because of how it is modeled, it is pretty easy to change the outer shell as well to be more "cool" looking. If I print some to mount on my mech, I will be modifying the outside to be more mech like, the box makes it easier to mount in multiple configurations though.




http://forums.trossenrobotics.com/gallery/files/4/7/8/5/transparent_shell2.png

http://forums.trossenrobotics.com/gallery/files/4/7/8/5/shell_inside.png


Here are how the shells compare:

Note:
I bought the defender I am using in early 2007 at Walmart, I do not know if other defenders have the same inside or not. If it does not, then the shell won't work!

Width
Custom: 1.43"
Original: 1.64"

Length: (not including barrel)
Custom: 4.52"
Original: Depends on how much you chop down your defender, no change if you chop it the most you can. (4.44")

Height:
Custom: 2.39"
Original: Again, depends on how much you chop down your defender. (mine was 3")

Weight:
Custom: 77g (assuming ABS material)
Original: I don't have a scale, I think it is less though due to the thick walls I put on. The original was only 22g before I put the walls on . I could probably reduce it a bit though.

Let me know if you have any thoughts on the design, where you would like to put mount holes especially.

DresnerRobotics
02-13-2011, 11:07 PM
Fantastic work!

On something like this I'd probably go to Shapeways or i.materialize to get printed, given the tolerances needed.

Seriously awesome work though!

cire
02-13-2011, 11:50 PM
Fantastic work!

On something like this I'd probably go to Shapeways or i.materialize to get printed, given the tolerances needed.

Seriously awesome work though!
Do you know what tolerences the makerbot is capable of? It is possible to make this where it doesn't require very high tolerances, +/- .015 maybe. (shim stock would be used in a few places, and you would drill the holes after print)

cire
04-11-2011, 11:13 PM
http://img845.imageshack.us/img845/8581/1000444b.jpg


Immortal has had some.. Upgrades since my last post.

New Coxa Brackets
New tilt on turret
New guns
Better gait
Better looks
Cleaned wiring
and more..

Heres a view from the pilots perspective:
http://img193.imageshack.us/img193/7302/1000440kv.jpg

Xevel
04-12-2011, 12:42 AM
This looks seriously awesome Oo

Any more photos / videos of the beast ?
I'd like to see the improved gaits very much :)

Zenta
04-12-2011, 02:15 AM
Wow, thats awesome!
I really like the video overlay.

Great work!

elaughlin
04-12-2011, 06:13 AM
Damn cire. Looks really fierce! I do not want to see that thing with those guns on in the ring. But can't say Immortal isn't looking awesome as hell man.

Great work. +rep

cire
04-24-2011, 11:29 AM
Immortal fared well at Robogames, winning gold as well as the innovation award. There weren't any major issues besides one AX-12 gears getting stripped. Here is a video of two of the matches:

YouTube - Mech Warfare 2011 - Immortal

Since then I have been playing around with the walking a bit more, I made it more stable by changing the feet and doubled the speed.

YouTube - Immortal gets a 100% speed boost

cire
09-17-2011, 12:21 PM
Here is Immortal's main control code that I used at Robogames to help out people trying to control their robot they want to. Things you will find in this code:


Panning & tilting control for turret
3 walking modes for NUKE type quads (normal, crab, circle strafe)
Switchable burst fire and full automatic gun control
Voltage monitoring loop (no guarantees I still managed to kill a battery by leaving my robot on by accident :()




/*
* Auto-Generated by NUKE!
* http://arbotix.googlecode.com
*/

#include <ax12.h>
#include <BioloidController.h>
#include <Commander.h>
#include "nuke.h"
#include <Servo.h>
#include "poses.h"

Commander command = Commander();



void setup(){
pinMode(0,OUTPUT);
// pinMode(1,OUTPUT); // Digital Pin to drive tank gun setup
// pinMode(3,OUTPUT); // Digital Pin to drive tank gun setup

tilting = 490; //Starting position of the tilt of the turret
panning = 512; //starting position of the panning of the turret

// setup IK
setupIK();
gaitSelect(AMBLE);
// setup serial
Serial.begin(38400);

// wait, then check the voltage (LiPO safety)
delay (1000);
float voltage = (ax12GetRegister (1, AX_PRESENT_VOLTAGE, 1)) / 10.0;
Serial.print ("System Voltage: ");
Serial.print (voltage);
Serial.println (" volts.");
if (voltage < 10.0) //If voltage is below 10, then robot does not move - Note that if you dont have ax-12 id 1 plugged in, your robot will not work.
while(1);



// stand up slowly
bioloid.poseSize = 18;
bioloid.readPose();
doIK();
bioloid.interpolateSetup(1000);
while(bioloid.interpolating > 0){
bioloid.interpolateStep();
delay(3);
}
}

void loop(){



//-------------Voltage Monitoring Loop-----------

voltagecheck++;
if(voltagecheck >= 9){ //checks voltage every so many cycles to reduce the ammont of voltage checks processing
voltagecheck = 0;
voltagecalculate++;
voltageadd = (ax12GetRegister (1, AX_PRESENT_VOLTAGE, 1));
if(voltageadd < 2){ //Detects bogus voltage reads and ignores the data
voltageadd = 0;
voltagecalculate--;
}

voltagesum = voltagesum + voltageadd; //Sum of the voltage checks
if(voltagecalculate == 10){ //if average voltage is less then 10 then the guns turn off and the robot stops
if(voltagesum <1050){
digitalWrite(1, LOW);
digitalWrite(3, LOW);
ax12SetRegister2(19,32,0);
ax12SetRegister2(20,32,0);
while(1==1){
}
}
voltagesum = 0;
voltagecalculate = 0;
}

}



// -------------Inverse Kinematics Updater -----------
if(bioloid.interpolating == 0){
doIK();
bioloid.interpolateSetup(tranTime);
}


// update joints
bioloid.interpolateStep();





// #############take commands####################


//--------- Movement Control --------------
if(command.ReadMsgs() > 0){
digitalWrite(0,HIGH-digitalRead(0));
Xspeed = (command.walkV)*2; //The *2 value determines the max speed of the bot in the x direction, in multiples of 100mm/sec
if((command.buttons&BUT_R1) > 0){ //If this is true, walk in crab mode, otherwise body rotates
Yspeed = (command.walkH)*2;
Xspeed = (command.walkV)*2;
Rspeed = 0;
}
else if((command.buttons&BUT_LT) > 0){ //If this is true, walk in a reversing rotating strafe mode (For circuling a robot at a certain distance away)
Xspeed = 0;
Yspeed = (command.walkH)*2;

if (Yspeed > 0){ //If robot is moving left, rotate body right
Rspeed = ((command.walkV)/250.0);
}
else{ // If robot is moving right, rotate body left
Rspeed = (-(command.walkV)/250.0);
}
}

else{ //for normal walking mode
Rspeed = (-(command.walkH)/250.0)*2;
Yspeed = 0;
}




// --------Turret Control -------------

panadd = (-(float)command.lookH)/20; //This is the value added to the panning position each time. A higher division value means slower movement.
tiltadd = (-(float)command.lookV)/30; //This value is added to the tilting position each time the program loops.

//This section creates a deadband for the commander controller (removed because issue of turret wandering stopped)
/* if(-1 < panadd && panadd < 1){
panadd = 0;
}
if (-1 < tiltadd && tiltadd < 1){
tiltadd = 0;
} */

//This code allows the user to go into a "fast" turret control if the controller is moved past a certain range
if(panadd < -5){
panadd = -8;
}
if(panadd > 5){
panadd = 8;
}
if(tiltadd < -4){
tiltadd = -7;
}
if(tiltadd > 4){
tiltadd = 7;
}



panning += panadd; //This updates the value of panning / tilting
tilting += tiltadd;



if(tilting < 370) //Limits the max range of the pan and tilt so the robot doesnt turn too far.
tilting = 370;

if(tilting > 490)
tilting = 490;

if(panning < 200)
panning = 200;

if(panning > 800)
panning = 800;

//Return turret to front view
if((command.buttons&BUT_R2) > 0){
panning = 512;
// tilting = 450;
}



// ------------ Resting -------------

//Sits the robot down for low action times to save power
if((command.buttons&BUT_L6) > 0){
rest = true;
}
else{
rest = false;
}



//------------ Guns -------------
if((command.buttons&BUT_R3) > 0){
Gunmode = 2; //Alternating burst fire mode
}
if((command.buttons&BUT_L4) > 0){
Gunmode = 1; //Full auto mode
}


if(Gunmode == 1){ //Gun Trigger - Full auto - both guns fire at 50% voltage
if((command.buttons&BUT_RT) > 0){
ax12SetRegister2(19,32,602);
ax12SetRegister2(20,32,602);
}
else {
ax12SetRegister2(20,32,0);
ax12SetRegister2(19,32,0);
}
}


if(Gunmode == 2){ //Alternating burst fire mode
if((command.buttons&BUT_RT) > 0 && burst_gun == 1){ //first gun in the burst cycle
burst_start = millis(); //gets current time
ax12SetRegister2(20,32,602); //50% power to gun
ax12SetRegister2(19,32,0);
burst_gun = 2;
}
if((command.buttons&BUT_RT) > 0 && burst_gun == 3){ //second gun in the burst cycle
burst_start = millis(); //gets current time
ax12SetRegister2(19,32,602);
ax12SetRegister2(20,32,0);
burst_gun = 0;
}


if(burst_start > 0 && millis() > burst_start + 500){ //Turns off guns once 500ms have passed
ax12SetRegister2(20,32,0);
ax12SetRegister2(19,32,0);
burst_start = 0;
if(burst_gun == 2){
burst_gun = 3; //Alternates the gun for the next burst cycle
}
else{
burst_gun = 1;
}

}
}

//This code is just for fun, not used in normal competition. Possible usage if need to aim higher then available.
if((command.buttons&BUT_L4) > 0){
// panning = 512;
// tilting = 512;

bodyRotY = (((float)command.lookV))/600;
bodyRotX = ((float)command.lookH)/600;
// bodyRotZ = ((float)command.lookH)/250.0; */
}
}

}

cire
11-19-2011, 08:54 PM
http://www.youtube.com/watch?v=yAYZj2sIzCc

Inbreakable
08-04-2012, 12:39 AM
That is looking good my man. I love the cable job you did on that. It is so nice when cables are wrapped up! Congratz on the awards!