View Full Version : [Question(s)] autonomous hexbot markII basic programming help

09-22-2014, 03:33 PM
our school is attempting to use the hexbot markII [ http://www.trossenrobotics.com/phantomx-ax-hexapod.aspx ] as our school mascot. to that end we want it to be autonomous and wander around the school guided only by sensors we will add to the robot. thus we need some help with programming. after a very long time we finally got the robot to work via the wireless commander hence everything should now be correctly set up. next we need to retire the wireless commander and start programming the ArbotiX Robocontroller (http://www.trossenrobotics.com/p/arbotix-robot-controller.aspx) directly. the question is how? as a reference point we have limited experience with Arduino robotics [i.e. wheeled robots] with simple motor control based on IR distance sensors.

my first assumption is to mimic the messages coming from the commander to tell the robot to walk?

thanks in advance

09-22-2014, 04:44 PM
my first assumption is to mimic the messages coming from the commander to tell the robot to walk?

That would be a good place to start. You can get some decent mileage out of existing code and still be able to control it manually when need be. Have you discussed battery life? I'm not sure specific time but I thought that 2000 mAh battery gave you under one hour of run time.

09-23-2014, 03:57 PM
we will have a solar panel on top, so how would we mimic the messages from the commander?

09-24-2014, 11:12 AM
The solar panel will not be able to power the robots motors directly. Even if your using the panel to charge the battery (which you will need some on board charging circuitry for), it won't be enough to keep the robot running indefinitely -i.e. it will need periods of sitting somewhere charging. Keep in mind that you don't want the battery to fall below 9.9v (3.3v/cell) so you'll need a way to cut power to the motors when the battery is low and re-start them when you get high enough.

The Hexapod Commander code is a good place to start

You don't actually need to mimic or use the commander library or packets. The commander structure is just a communication protocol that interacts with the IK engine on the crawler. So for example, at line 89 of Hexapod_MArk_II.ino

if((command.walkV) > 5 || (command.walkV < -5) ){
Xspeed = (multiplier*command.walkV)/2;

The command.walkV value coming in will be between -127 and 127, and the default speed multiplier is 3 - so your final walk speed will be between ~-190 and 190. So if you just were to set

Xspeed = 190;

The crawler would start walking forward as fast as possible. Negative values set is backwards, lower number set it slower. You can do the same with Yspeed (left/right) and Rspeed (rotate) - though Rspeed will be a float between 0.00 and 1.27.

I've got some code here that's based off the commander code that accepts input from a joystick and maps it to the IK engine
The idea was to make a Hexapod that you could walk on a leash
You should be able to map your sensor data similarly to what I've done.

09-24-2014, 11:26 AM
I am not sure which code base you are using, but for the most part that does not mater.

With the Phoenix code base, I have some different types of input code bases, including, Commander, our DIY xbee remote code, PS2, simple RC... I also have one called Serial. You can do the exact same code with the standard Mark2 code base, geared around the commander.

I am not sure what types of commands, you expect to receive from the Solar panel, so hard to give any advice here. If you have some other processor on the panel, you might be able to connect it up to the Serial port of the Arbotix and then you simply need to have that processor send out some simple packets which have the same format as the commander packets. These packets are pretty simple to emulate. You send a packet start byte: 0xff, followed by 4 bytes associated with the 2 joysticks (center point of 128), followed by a byte for the state of the buttons (1 bit per button), followed by an ext byte which normally is 0, followed by a checksum byte, which is easy to calculate.

So for example to make the robot walk foreword, you simply need to output a packet that outputs a value for the Walk vertical field that is positive like maybe (128+100). I know the default Commander limits the joysticks to something like +-100, I don't remember the exact limits. The reason for these limits is they don't want the value of 255 for a joystick as if they detect two values of 255 in a row they know something is wrong.

Not sure what else to say yet as don't know enough of how you are setup and the like

10-01-2014, 02:59 PM
thanks a bunch, i'll play with the code, it would be really great if we could get our hands on an even simpler code that just had the bot walk forward when it was turned on.

10-06-2014, 11:44 AM
You can make the crawler just start walking by replacing the entire if statement that starts with

if(command.ReadMsgs() > 0){

With the line i mentioned earlier

Xspeed = 190;

Though it would probably be wise to slow it down, maybe a quarter speed for starting

Xspeed = 47;