View Single Post
  #7   Spotlight this post!  
Unread 23-03-2004, 16:47
TomJoseph TomJoseph is offline
The Pirate
#0247 ('Da Bears)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Michigan
Posts: 3
TomJoseph is an unknown quantity at this point
Send a message via ICQ to TomJoseph Send a message via AIM to TomJoseph
Re: Need help programming our swerve with feedback?

It's much easier to try to map joystick values to pot values than to try to determine the angle and everything. The end effect is just the same, and it's much easier to code. Here's some pseudo code to start you out:
Code:
Compare joystick to pot:
JOYSTICK > POT + LEEWAY:  Check to see how far apart
  JOYSTICK > SET RANGE > POT + LEEWAY:
    Power motor fast
  SET RANGE > JOYSTICK > POT + LEEWAY:
    Power motor slower
  POT - LEEWAY <= JOYSTICK <= POT + LEEWAY:
    Set motor Neutral

POT - LEEWAY > JOYSTICK:
  JOYSTICK < SET RANGE < POT - LEEWAY:
    Set motor fast opposite dir
  SET RANGE < JOYSTICK < POT - LEEWAY:
    Set motor slower opp dir

ELSE
    Set motor neutral
If you're keeping the joystick in a set position (like a dial for example), then it's silly to use proportional speeds. Just make sure that the slower speed is slow enough for it to stop without much drift. The friction between the tires and the floor should take care of the rest. Last year we had unidirectional drive with a dial-control, and used almost the exact same code (IIRC, we used two set ranges instead of one)