Shop OBEX P1 Docs P2 Docs Learn Events
Looking for skid steering algorithm — Parallax Forums

Looking for skid steering algorithm

Tom CTom C Posts: 461
edited 2007-10-08 19:49 in Robotics
Hi all,

I have searched all the forums here and have come up empty handed.

I need a skid steering algorithm to implement the BS2 code to·control two independent motor controllers ([url=mailto:HB@%s]HB25s[/url]) as one would use a single Sabertooth 2X10 motor controller with the built-in skid steering function.

Regards,
TCIII

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If you are going to send·a Robot·to save the world, you·better make sure it likes it the way it is!

Comments

  • stephenwagnerstephenwagner Posts: 147
    edited 2007-10-08 16:22
    This might help.

    http://www.parallax.com/dl/docs/prod/datast/ApplyEncoder.pdf

    Its a document that may help you derive your own. You will need the wheel encoder kit or an equivalent.


    SJW
  • ZootZoot Posts: 2,227
    edited 2007-10-08 17:16
    Just so the question is clear -- are you looking for an algorithm for mixing, rather than individual control of the two motors?

    In other words, I think you want to be able to use a speed value and turn value and have those mixed to the two motors, rather than using two individual motor speeds?

    Is that right? If so, there are a couple of approaches. The simplest is like this (from Dave A. at Parallax, I think):

    ' ==============================================================================
    '
    '   File......
    '   Purpose...RC CONTROL OF BOEBOT
    '
    '   {$STAMP BS2}
    '   {$PBASIC 2.5}
    '
    ' ==============================================================================
    
    
    ' ------------------------------------------------------------------------------
    ' Program Description
    ' ------------------------------------------------------------------------------
    
    'Control A boe-bot using 2-Channel R/C
    
    ' ------------------------------------------------------------------------------
    ' Constants
    ' -------------------------------------------------------------------------------
    state  CON 1
    
    ' ------------------------------------------------------------------------------
    ' I/O Definitions
    ' ------------------------------------------------------------------------------
    Ch1         PIN 12        ' Elevator channel used to drive forward and backward
    Ch2         PIN 13        ' Aileron channel used to steer left and right
    L_servo     PIN 14        ' Left servo
    R_servo     PIN 15        ' Right servo
    ' ------------------------------------------------------------------------------
    ' Variables
    ' ------------------------------------------------------------------------------
    steer        VAR Word
    drive        VAR Word
    R_Target     VAR Word
    L_Target     VAR Word
    ' -------------
    ' Program Code|
    ' -------------
    begin:
    DO
     PULSIN Ch1 , state , drive
     PULSIN Ch2 , state , steer
     R_Target = drive - 750 + steer
     L_Target = 750 - drive + steer
     PULSOUT L_servo , L_Target
     PULSOUT R_servo , R_Target
     PAUSE   10
    LOOP
    
    



    The above is for mixing from an RC with X and Y joysticks, but the theory is the same. The above uses 750 as "neutral" but you can map to whatever foward/neutral/reverse values you want and it's the same (my own controller uses 0 for reverse, 128 for stopped, 255 for forward.

    That said, the above wastes some resolution from the turn, and you do not get consistent speeds as you change turn (work through some half speed, half turn or full turns with changing speeds and you'll see what I mean). I use an algorithm (on the Stamp anyway), that proportionally mixes in the turn value with the "overall" speed so that the speed of the platform as a whole remains relatively consistent when the turn is changed (i.e. the turn value changes the turn direction and turn RADIUS of the platform and the nominal speed remains the same throughout). I can post that code later if you want -- it's on another machine and I'm not there right now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    Post Edited (Zoot) : 10/8/2007 5:23:35 PM GMT
  • Tom CTom C Posts: 461
    edited 2007-10-08 18:56
    Zoot,

    The example that you have shown is exactly what I have been looking for. I would also appreciate being able to see the additional code that you have mentioned when you get the chance.

    Thank you very much.

    Regards,
    TCIII

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If you are going to send·a Robot·to save the world, you·better make sure it likes it the way it is!
  • ZootZoot Posts: 2,227
    edited 2007-10-08 19:49
    Here's a more proportional algorithm I use on one of my 'bots. A few things to note when trying this out ---

    - my motor controller: 0 = full reverse, 128 = stopped, 255 = full forward
    - user (i.e. platform) "speed": 0 = full speed reverse, 128 = stopped, 255 = full speed forward
    - user "turn": 0 = spin CW, 128 = straight, 255 = spin CCW

    - the mixing algorithm SUBTRACTS/ADDS speed to the motor on the INSIDE of the turn, the OUTSIDE of the turn maintains the overall speed. Another way to put it -- if you have a turn of 160 (128+32) at speed X, the outside motor (in this case the right motor) will move forward at speed X and the inside motor (in this case the left motor) will move at neutral+(speedX*50%). Why? It was easy. Plus, my particular platform moves really fast, and I have it operating at no more than 80% full speed anyway. This gave me a way of knowing that my *fastest* speed on the platform at any given moment would be on the outside. A purer alogrithm would add speed to the outside wheel and subtract from the inside resulting in the "master" speed at the CENTER of the platform, between the wheels. But without encoders I'm not sure that level is nuance is worth while. Just my two cents.

    - my particular main program that uses this algorithm allows switching between "mixing" and individual motor control. Being able to do the latter can be helpful for following, certain PID, or sensory alignment routines, where accounting for turn vs. speed gets a little cumbersome and kinda silly.

    - I split forwards/backwards up so I could mess with "which way do you turn when turning and going backwards?" My implementation is reversed from many mixers, because it fit my obstacle avoidance code better, so you could think about switching that part around. Try it and see.

    motos VAR Word  'values to send to motor controller: 0 = left motor, 1 = right motor
    moto VAR motos.LOWBYTE 'implied array bytes
    ' you don't really need the above and can alias to other work/tmp vars, but hopefully this makes the code clear
    
    ioWord VAR Word 'work space
    datHi VAR ioWord.HIGHBYTE
    datLo VAR ioWord.LOWBYTE
    
    motoTrn VAR Byte 'user "turn" value
    motoSpd VAR Byte 'user "speed" value
    
    Mmode VAR Bit ' 0 = individual motor control, 1 = turn/speed mixing
    
    flag VAR Bit  'work bit
    Sign VAR flag 'work bit
    
    ON Mmode GOTO mdiff  '1 = mix, 0 = diff/ind
      motmix:
        flag = motoTrn - 128 >> 15     '(1 = turn>128 =  ccw)
        datHi = ABS ( 128 - motoTrn )  'abs turn from center
        datLo = ABS ( 128 - motoSpd )  'abs speed from neutral
        ioWord = datLo */ ( datHi * 256 / 64 )  'proportional speed reduction on inside wheel, based on turn
    
        ON motoSpd - 128 >> 15 GOTO mforwards
        mbackwards:
          moto(flag) = motoSpd
          moto(1-flag) = motoSpd + ioWord MAX 255
    
          GOTO mixdiffdone
    
        mforwards:
          moto(flag) =  motoSpd - ( ioWord MAX motoSpd )
          moto(1-flag) = motoSpd 
    
          GOTO mixdiffdone
    
      mdiff:
          moto(0) = motoTrn   'in mode 0, trn is individual control of left motor
          moto(1) = motoSpd   'in mode 0, spd is individual control of right motor
    
      mixdiffdone:
          'send moto(0) to left motor
          'send moto(1) to right motor
         ' in my case, it's an MD22 controller on an I2C bus, but hopefully you get the idea
         ' I also keep a lot of the vals in scratch pad RAM on a BS2p, but again, var management is up to you
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    Post Edited (Zoot) : 10/8/2007 8:57:03 PM GMT
Sign In or Register to comment.