Go to Post Enlighten a man who sometimes has difficulty understanding why others stray outside the box, when the box appears to be an optimized and elegant solution. - JVN [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-14-2018, 11:50 AM
IsaacB's Avatar
IsaacB IsaacB is offline
Registered User
FRC #5437 (Rocky Balboabots)
Team Role: Mentor
 
Join Date: Jun 2018
Rookie Year: 2017
Location: Booneville, AR
Posts: 1
IsaacB is an unknown quantity at this point
Help with Swerve Drive programming (Java)

Our team bought the AndyMark Swerve and Steer modules, however our program only causes the swivel motors to spin continuously when a joystick is moved. I am not the "chief" programmer for our team but we would like to get the chassis going in the off season.

We are still using the hall effect encoders on the rear of the motor in stead of the absolute encoder they recommend for it.

Here is a link to our code: https://github.com/FRC5437/2017-Swerve-Code

Thanks for any help!
Reply With Quote
  #2   Spotlight this post!  
Unread 06-14-2018, 12:23 PM
nickbrickmaster nickbrickmaster is offline
Human left pad
AKA: Nick Schatz
no team (3184 Alum)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Eagan MN
Posts: 423
nickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond repute
Re: Help with Swerve Drive programming (Java)

It's probably an issue with your steer control loops. First of all I would double check your in/out polarity- a positive output from the PID controller should reduce a positive error.

Then comes tuning. I would set all your gains (kP, kI, kD) to 0, then start with a small kP and slowly increase it. You also probably want just a PD loop (0 kI) as you want fast rise time with little overshoot.

Last of all an absolute encoder is almost essential for swerve. You'll need either that or a limit switch/hall effect sensor to set zero on your modules. Otherwise your quadrature encoder will only measure changes in angle while the robot is on, and not absolute angle.
__________________
Proceed as if success is inevitable.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-14-2018, 12:50 PM
gerthworm's Avatar
gerthworm gerthworm is online now
Making the 1's and 0's
FRC #1736 (Robot Casserole)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Peoria, IL
Posts: 515
gerthworm has a reputation beyond reputegerthworm has a reputation beyond reputegerthworm has a reputation beyond reputegerthworm has a reputation beyond reputegerthworm has a reputation beyond reputegerthworm has a reputation beyond reputegerthworm has a reputation beyond reputegerthworm has a reputation beyond reputegerthworm has a reputation beyond reputegerthworm has a reputation beyond reputegerthworm has a reputation beyond repute
Re: Help with Swerve Drive programming (Java)

Definitely start with making sure your angles are being read properly by all encoders. Positive/increasing angle should be in the same direction as when the motors are given positive control effort.

A couple "code review" items to look into:

This code handles bad encoders. Do all calls to getAngle() check if -1 is returned and do something appropriate, or is -1 ever used as an actual angle later on?

I believe this code attempts to wrap "angle" to the 0-360 degree range. Is it ever possible to get angle = -370 as input to this function? If so, the wrap logic may not work as expected. I haven't dug deep enough to determine if this is true, just something to double check.

The encoder appears configured to return 0.875 degrees per pulse. Can you confirm this is accurate?

To the absolute encoder logic: What physical state is defined as "0 degrees of module rotation" on the robot? What logic in software (or mechanism in hardware?) guarntees that during at least one point of operation, the robot will know you're in the zero degree state, and reset the encoder readings to 0?

Check the "desired" angles coming in from the controller too. Print out all four angles passed into your swerve modules objects. Are all of these angles reasonable, based on driver inputs?

Same comment as above - once you've verified encoders are reading in the correct direction, try to re-tune. I'd start by setting your I/D gains to zero, P very small. Double P until you get oscillations in steady state. Back it off slowly until the oscillations cease. Then pull in some I to overcome steady state error. Historically, I've avoided D for cases like this. Then again, I've historically been dealing with high-stiction systems with low controllability. YMMV.

You may also want to add logic to prevent integrator windup. Perhaps only "accumulate" your I term when your actual is within a few degrees of setpoint? There's a couple other ways to accomplish this....

Last edited by gerthworm : 06-14-2018 at 12:55 PM.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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


All times are GMT -5. The time now is 08:49 AM.

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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi