Shop OBEX P1 Docs P2 Docs Learn Events
Math Guru assistance please — Parallax Forums

Math Guru assistance please

Hi,
I am afraid that my trig skills have atrophied over the years since high school. I am working oon a remotely controlled robot that uses diferential stearing. The motor control portion is all working fine and I have an XBEE link I can use to provide the necessary remote signals. My problem is translating the XY analog signals into digital commands for each wheel motor. I can see where the Tan function would derive the signals but not sure how to translate that into motor speeds. Any ideas where I might find the answers?
Jim

Comments

  • Hi Jim,

    You just want to convert the x and y to two motor speeds?

    I know there's a simple formula for this. No trig needed. I think it's just addition and subtraction.

    I'll be back in a bit with the formula.
  • This is what I found in my PropBOE-Bot code.
    PUB ComputeSpeedsFromJoystickRx 
    
    
      wheelSpeed[_PortWheel] := (channel[_Y] - channel[_X]) + _StopServo
      wheelSpeed[_StarboardWheel] := _StopServo - (channel[_Y] + channel[_X])
    

    In case my variable names aren't easy to follow, here's the code again.

    leftSpeed = y - x
    rightSpeed = -1*(y + x)

    I'm pretty sure these equations assume the center values of x and y are zero.

    The exact equations will depend on your joystick's pot orientations and which wheels need positive verse negative power to move forward.
  • Thanks guys, I will play with both possibilities. Duane, I am using servo control object and sending the bot commands between 500 and 1500 as a string. I will play with your XY commands and see what comes out.
    KeithE, I will study the link further to see what might be relevant .
    Jim
  • The algorithm uses Y to control the base speed and the value of X is used to modify the the base speed. One wheel gets sped up and one wheel slowed proportional to the value of X.

    When Y is zero, moving X will cause the robot to rotate in place.

    I'm pretty sure I could help adapt the algorithm to work with your setup if need it.
  • Duane,
    I tried your formula and something is not working correctly. My expectation was that when the y was advanced and the x remained neutral, both wheels would advance approximately the same amount. What is happening as y is advanced one wheel is increasing and the other is decreasing. I haven't tried it with the second set of formulas.
    Jim
  • Duh!
    Here I am trying to solve a problem in software that has an easy solution in hardware! Reverse two motor wires!
    Jim
  • Jim,

    If you're still having trouble, describe your input values (x and y ranges) and what pulse value cause forward and reverse motion on each motor and I can adjust the equations to match your setup.

    Duane
  • Heater.Heater. Posts: 21,230
    RS_Jim,
    Here I am trying to solve a problem in software that has an easy solution in hardware! Reverse two motor wires!
    I love it.

    As the famous Bob Pease said, "My favorite programming language is solder".
Sign In or Register to comment.