Shop OBEX P1 Docs P2 Docs Learn Events
hexcrawler - fine tune walking with code? — Parallax Forums

hexcrawler - fine tune walking with code?

playfightplayfight Posts: 6
edited 2005-11-14 05:33 in Robotics
My hexcrawler is pulling to the left when I have it's gait set to forward ($20).

I was wondering if there is a way to tweak the code to make it go to the right?
If I set it to a forwardRight position for selectedMode ($22) it is almost straight, but
pulls slightly to the right.

( I am referring to the hexcrawler sample code btw)

There is this line -

LeftRamp = (Ramp+$2)



where I am going to try something like this:

LeftRamp = (Ramp+$2) * .8



but I know this is my 'C / actionscript - programming - brain' talking - this stuff in pbasic, using bits, bytes and
hex's doesn't work this way.

if someone could tell me where to change the sample hexcrawler code to tweak the gaits, i would be very appreciative.

-Doug Easterly

Comments

  • playfightplayfight Posts: 6
    edited 2005-11-12 18:04
    I should have looked through the sample code more -- I was looking mainly through the pdf files at first.
    But! Since I posted a stupid question, I will at least answer it to help anyone else having the same problem in the future.

    All of the hexcrawler sample code works with the interplay of Ramp values between $1 and $3F. If you are like me, and aren't familiar with hex numbers, see appendix A in the Basic Stamp Manual (I have 2, but I assume 2.5 would have a similar appendix). There you can see that $1 (or $01) is like a regular number 1. This is the case through number 9 ( or $09 in hex). But then at number 10, hex writes as ($0A). And so on until $3F, which is 63.

    In my hexcrawler walking application, there is this variable declaration:
    Fast            CON     $A     ' Walk fast
    



    which I changed to

    Fast            CON    $14    'my Walk fast
    



    which is used later when determining the walk gait (selectedMode) after the Ramp variable is passed along to Fast,
    ' Check LowNib to determine
    ' left and right leg ramps
    ' for gradual turns
    ' 0 = straight
    ' 1 = slow left side
    ' 2 = slow right side
      SELECT selectedMode.LOWNIB
        CASE $0
          'DEBUG "Straight ", CR
          RightRamp = Ramp
          LeftRamp = RightRamp
        CASE $1
          'DEBUG "left ", CR
          RightRamp = Ramp
          LeftRamp = (Ramp+$2)
        CASE $2
          'DEBUG "Right ", CR
          LeftRamp = Ramp
          RightRamp = (Ramp+$2)
      ENDSELECT
      'DEBUG HEX ?RightRamp, HEX ?LeftRamp
    'END
    
    



    since my robot was pulling to the left, when I had 'straight' selected ($20) - I simply slowed the left side down a bit to accomodate.

        CASE $0
          'DEBUG "Straight ", CR
          RightRamp = Ramp
          LeftRamp = (RightRamp + $1)  ' debugging this returns RightRamp = 14 and LeftRamp = 15
    
    

    Post Edited (playfight) : 11/12/2005 6:08:25 PM GMT
  • AlexAlex Posts: 20
    edited 2005-11-14 05:33
    ·Rather than tweak code, this is usually something that is easily corrected by adjusting·the legs. What I do if the hexcrawler is going to the right or left is to look at the legs as it is walking from a top view. You will usually find one side of the hexcrawlers·leg(s) pushing slightly more than the opposite side. This is caused by slight differences in·servo tolerances. Simply·adjust one or more legs slightly forward on the opposite side that the hexcrawler is turning by popping the·horizontal servo from its servo horn and turn it forward about 10 - 20 degrees.

    Of course you could adjust it programatically by adjusting the legs using the "tune legs" program from the crustcrawler web site, and use the adjusted values in your program. Any one of these adjustements works well.



    Alex
Sign In or Register to comment.