Use sensors to collect data about the surrounding environment, then discard it and drive into walls. - Jared Russell [more]
 Chief Delphi Need help programming our swerve with feedback?
 User Name Remember Me? Password
 CD-Media CD-Spy
 portal register members calendar search Today's Posts Mark Forums Read FAQ rules

#1
03-21-2004, 11:35 PM
 activemx A M X AKA: Akshay Dodeja no team Team Role: College Student Join Date: Jan 2002 Rookie Year: 2000 Location: Portland, Oregon Posts: 312
Need help programming our swerve with feedback?

Our programmers need help and guidance in programming a swerve drive with Pot feed bnack

--------
| \\ \\ |

| \\ \\ |
--------

joystick
-----
| \ |
-----

thats pretty much how its set up
all the wheels are linked up by one chain and a Window motor. there is aidler nylon sprocket on the chain witha potentiometer.

we want the pot to give us the angle of the wheel and want the wheels to turn to the position where the joystick is pointed to.
I hope those illustrations help.

If team who have tackled this type of problem befoer please help us out. aka wildstang or anyothers would be great.
__________________
2005 - Present - FIRST Volunteer(Inspector, Ref, Judge)
2000-2004 MVRT 115
#2
03-22-2004, 01:44 AM
 Cyris12 Registered User AKA: Ajay Reddy #0254 (Cheesy Poofs) Team Role: Programmer Join Date: Feb 2004 Location: San Jose, CA Posts: 6
Re: Need help programming our swerve with feedback?

Have you tried a PID loop? We faced a similar problem with our arms. We needed to drive the motors just enough to reach a position and fight gravity, but not enough to overshoot. The trick is to set your motor value proportional to the distance you want to go.

A solution (run through this every so often with timers):
1) Find the difference between your current pot position and your target position. This is your error value.
2) You want your motor value to be proportional to the error. Multiply the error by a constant (you'll have to figure it out through experimentation). This gives you your proportional value.
3) As your wheels approach the right orientaion, your motor value will decrease more and more. To compensate for this, integrate the error (ie add the current error to a running total). Multiply this by another constant (again, you'll have to figure it out). This will give you your integral value.
4) Add the two values together to get your motor value.

It sounds a little complicated, but the code is actually pretty simple. The object does tend to overshoot some, and then oscillate a little. This can be minimized by adjusting the constants.

This system may allow you to plug in a certain angle and have your wheels find that position automatically. On our robot, we use this to create preset arm positions. You might be able to do the same with wheel positions.

EDIT: On second thought, using an integral probably wouldn't be best for you. Instead, you might want to just use a proportional value. To get the wheel to its target position when the proportional drops too low, you could have a range close to the target with a different constant (to multiply by).

Last edited by Cyris12 : 03-22-2004 at 01:58 AM.
#3
03-22-2004, 02:16 AM
 10intheCrunch Who's John V-Neun? AKA: Alex Baxter None #0254 (Cheesy Poofs) Team Role: College Student Join Date: Feb 2004 Rookie Year: 2004 Location: San Jose, CA Posts: 129
Re: Need help programming our swerve with feedback?

You are probably going to need a trig table in order to interpret the x and y axes of the joystick. This can be a slow process and dramatically slow down your performance, the same (or worse) as using floating point numbers. I don't really know all the machinations of EEPROM (Ajay knows more than I), or much about swerve, but you are going to need to find that angle if you want to get anywhere...

From there I would use a proportional value to move the motors that decreases as you close on the right position.
__________________
~Alex Baxter
Programming, Arms operation, Team 254
#4
03-22-2004, 02:20 AM
 FotoPlasma \: | no team Join Date: Jul 2001 Rookie Year: 2001 Location: San Jose Posts: 1,900
Re: Need help programming our swerve with feedback?

Akshay, if you could have Rebecca IM me sometime in the next week or two, I'll do everything I can to help you out with your system.

Pretty much, if you can determine the arctangent of the joystick position, you can determine the angle you want your wheel modules at, and using the Pythagorean Theorem, you can determine magnitude of your drive motors.

Because of the fact that you cannot rotate your wheel modules around completely, I think that if the sine of your joystick value is negative (id est, less than or equal to 127) you should invert the cosine value and the magnitude, in order to have the wheel modules only travel 180degrees, total.

This could prove to be a problem when you make the transition from some small positive angle from normal to an angle just below normal (300+degrees), in which case your wheel modules would have to traverse almost all of 180 degrees in order wind up pointing in the proper direction.

There're many other considerations when you're programming a system like this, and I'm really more than willing to help you guys out with anything I can. I really want to say that I'm sorry that I didn't get to help you at Sacramento, this weekend.

<edit>
About PID control, we used a P control loop on our swerve, last year (with the BasicStamp-based control system), so I don't think that getting too far (farther than P) into feedback control systems is very necessary.
</edit>
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos

Last edited by FotoPlasma : 03-22-2004 at 02:26 AM.
#5
03-22-2004, 02:34 PM
 Astronouth7303 Why did I come back? AKA: Jamie Bliss FRC #4967 (That ONE Team) Team Role: Mentor Join Date: Jan 2004 Rookie Year: 2004 Location: Grand Rapids, MI Posts: 2,071
Re: Need help programming our swerve with feedback?

Why not just make a look-up table custom made for your bot?
#6
03-23-2004, 01:58 AM
 Alex1072 Registered User AKA: Alex #1072 (Harker Robotics Team) Team Role: Leadership Join Date: Jan 2003 Rookie Year: 2003 Location: San Jose Posts: 110
Re: Need help programming our swerve with feedback?

If you need help getting the wheels to servo to angle, I can give you the PID code for our arm. We use a window motor to servo it to a pot angle. Works like a charm (after a adjusting the constants to hell).
__________________
--------------------------------------
Alex
President
Team 1072 Harker Robotics
#7
03-23-2004, 03:47 PM
 TomJoseph The Pirate #0247 ('Da Bears) Team Role: Mentor Join Date: Mar 2004 Location: Michigan Posts: 3
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)
#8
03-23-2004, 04:19 PM
 KenWittlief . no team Team Role: Engineer Join Date: Mar 2003 Location: Rochester, NY Posts: 4,211
Re: Need help programming our swerve with feedback?

why not simply use a potentiometer on the operator interface?

then all your control loop has to do is get the feedback pot to match the OI pot

and your wheels will turn in the direction the pot is pointing on the OI - like a steering wheel?
#9
03-23-2004, 05:10 PM
 Mike Soukup Software guy FRC #0111 (Wildstang) Team Role: Engineer Join Date: May 2001 Rookie Year: 1996 Location: Schaumburg, IL Posts: 797
Re: Need help programming our swerve with feedback?

Quote:
 Originally Posted by KenWittlief why not simply use a potentiometer on the operator interface? then all your control loop has to do is get the feedback pot to match the OI pot and your wheels will turn in the direction the pot is pointing on the OI - like a steering wheel?
He is using a potentiometer, the one built into the joystick. Have you ever tried driving a robot with a pot? It's not easy. It's essential to have a controller that bounces back to the neutral position, exactly like the joystick does.

The controls may not be a 1:1 mapping, in most cases for crab/swerve it is not. We map the full range of the joystick to 180 degrees of motion - full left to full right. That ends up being about 66% of the full pot range. Besides the scaling, we calibrate the crab pot such that 127 does not have to be the center position, this makes putting the pot in its place much easier.
#10
03-23-2004, 05:46 PM
 KenWittlief . no team Team Role: Engineer Join Date: Mar 2003 Location: Rochester, NY Posts: 4,211
Re: Need help programming our swerve with feedback?

with crab steering I would think you would want a pot that stays where you left it - because the bot does not turn in an arc like a car or a bot with conventional 2 or 4 wheel drive - it goes where you point it

why would you want your bot to always default to pointing straight down the field?
#11
03-24-2004, 01:37 PM
 Mike Soukup Software guy FRC #0111 (Wildstang) Team Role: Engineer Join Date: May 2001 Rookie Year: 1996 Location: Schaumburg, IL Posts: 797
Re: Need help programming our swerve with feedback?

Quote:
 Originally Posted by KenWittlief with crab steering I would think you would want a pot that stays where you left it - because the bot does not turn in an arc like a car or a bot with conventional 2 or 4 wheel drive - it goes where you point it why would you want your bot to always default to pointing straight down the field?
It's not a bot that defaults to pointing straight down the field, it's a bot that defaults to wheels pointing straight ahead. Our driver doesn't want to mess around with centering a pot when he wants to drive straight forward. He wants to let the springs in the stick find the center point for him & have the wheels snap to straight ahead without much effort or thought.
#12
03-24-2004, 01:52 PM
 Matt Reiland 'The' drive behind the drive None #0226 (TEC CReW Hammerheads) Team Role: Engineer Join Date: May 2001 Rookie Year: 1999 Location: Troy Michigan Posts: 712
Re: Need help programming our swerve with feedback?

Activemx

Here is the code we used 2 years ago in pBasic. It was the identical setup to yours with a 4 wheels linked and one pot and one steering motor. When the top joystick button was pressed, the wheels followed the joystick around, when released they went forward and steered like a tank.
Attached Files
 Sidestep.zip (4.5 KB, 106 views)
__________________
Robonaut Next Generation Control System Development

2003 GLR Champions (302,67,226)
2003 Buckeye Semi-Finalists(902,494,226)
2002 Nationals QuarterFinalists
2001 West MI QuarterFinalists
2000 GLR Semi-Finalists
#13
03-24-2004, 03:57 PM
 activemx A M X AKA: Akshay Dodeja no team Team Role: College Student Join Date: Jan 2002 Rookie Year: 2000 Location: Portland, Oregon Posts: 312
Re: Need help programming our swerve with feedback?

I would like to thank all of you: Matt, Mike, Jay, Alex, Jim, ken and whoever i missed

I am going to get our programmers to get some help from this post and i will keep you guys update.THanks again!

Akshay
__________________
2005 - Present - FIRST Volunteer(Inspector, Ref, Judge)
2000-2004 MVRT 115
#14
03-25-2004, 09:41 PM
 rosebud Registered User #0115 (MVRT) Join Date: Sep 2002 Location: California Posts: 24
Re: Need help programming our swerve with feedback?

hi everyone,
thanks for all ur answers to the swerve program! i think the table i made for inverse tangent was incorrect. also, when i compared and displayed the pot value and the value the pot should be at according to the joystick, printf displays garbage. but when i use it in an equation, it works, so maybe its something with printf, although both variables are signed ints, so it should be ok. anyways, i used the taylor power series expansion to find inverse tangent, and used the difference between pot and where pot should be to find a variable speed of rotation, so the code works. thanks again everyone, and check out mvrt 115 in silicon valley.
rebecca
#15
03-26-2004, 07:10 PM
 Alex1072 Registered User AKA: Alex #1072 (Harker Robotics Team) Team Role: Leadership Join Date: Jan 2003 Rookie Year: 2003 Location: San Jose Posts: 110
Re: Need help programming our swerve with feedback?

If you use only a P term you should be careful of resonance. That may not be an issue becaue the wheels don't have much momentum when they start turning, but if they start shaking back and forth it means you need a D term.
__________________
--------------------------------------
Alex
President
Team 1072 Harker Robotics

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     User Announcements FIRST     General Forum         FIRST E-Mail Blast Archive     Rumor Mill     Career     Robot Showcase Technical     Technical Discussion     Robotics Education and Curriculum     Motors     Electrical         CAN     Programming         NI LabVIEW         C/C++         Java         Python     Control System         FRC Control System         Sensors     Pneumatics     Kit & Additional Hardware     CAD         Inventor         SolidWorks         Creo     IT / Communications         3D Animation and Competition         Website Design/Showcase         Videography and Photography         Computer Graphics     National Instruments LabVIEW and Data Acquisition         LabView and Data Acquisition Competition     Unsung FIRST Heroes     Awards         Chairman's Award     Rules/Strategy         Scouting         You Make The Call     Team Organization         Fundraising         Starting New Teams         Finding A Team         College Teams     Championship Event     Regional Competitions     District Events     Off-Season Events     Thanks and/or Congrats     FRC Game Design     OCCRA         OCCRA Q&A         OCCRA Programming Other     Chit-Chat         Games/Trivia             Fantasy FIRST     Car Nack's Corner     College & University Education     Dean Kamen's Inventions     FIRST-related Organizations         Western Region Robotics Forum         Southern California Regional Robotics Forum         The Blue Alliance             Video Archives     FIRST In the News...     FIRST Lego League         Lego Mindstorm Discussion     FIRST Tech Challenge     VEX         VEX Robotics Competition         VEX IQ     Televised Robotics     Math and Science         NASA Discussion ChiefDelphi.com Website     CD Forum Support     Extra Discussion

 Similar Threads Thread Thread Starter Forum Replies Last Post Programming Compatition Angela06 Programming 30 04-08-2005 10:12 PM Feedback LEDs on OI bstempi Programming 1 02-22-2004 08:18 PM A few questions on programming the Control System Avarik Control System 21 02-08-2004 10:42 AM Help On Coding 2K1 Controller GregTheGreat Programming 9 12-05-2003 05:35 PM Chamionship Qualification - feedback needed ASAP! dlavery General Forum 97 10-11-2003 06:17 AM

All times are GMT -5. The time now is 04:17 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.

 -- English (12 hour) -- English (24 hour) Contact Us - Chief Delphi - Rules - Archive - Top