Go to Post The GDC is the Grinch because they just stole my Christmas! - scottmacdonald [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-02-2015, 17:16
goldenguy00 goldenguy00 is offline
Registered User
FRC #0619
 
Join Date: Feb 2015
Location: Virginia
Posts: 4
goldenguy00 is an unknown quantity at this point
Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

We have the mecanum wheels set up to properly move in the Y (forwards and back) direction and to turn without any problems, but when attempting to strafe, the robot veers off to one side instead of going straight to the side. To fix this, we are using encoders, but we are running into some severe difficulties. Through a bit of troubleshooting, I found that this works...
Code:
public class TalonCan {

    CANTalon talon;

    public TalonCan(int canID){
	talon = new CANTalon(canID);
        talon.changeControlMode(ControlMode.PercentVbus);
    }
}
And this doesn't...
Code:
public class TalonCan {
    
    CANTalon talon;
    
    public TalonCan(int canID){
        talon = new CANTalon(canID);
	talon.changeControlMode(ControlMode.Speed);
	talon.setPID(0.1, 0.001, 1, 0.0001, 100, 36, 0);
	talon.set(0);
	talon.setFeedbackDevice(FeedbackDevice.QuadEncoder);
    }
}
I believe it's from not using the encoders, so my question is, what am I doing wrong in the second example? The robot does not move in autonomous, nor in teleop.

[EDIT]
We have already put the robot on blocks and the wheels are moving in the correct direction and correct speed. It's only on the floor that we have problems, hence the need for encoders.

Last edited by goldenguy00 : 07-02-2015 at 17:26.
  #2   Spotlight this post!  
Unread 07-02-2015, 17:34
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)


I don't do Java/C++ code debugging from afar so I invite Java/C++ gurus to jump in here.

In the meanwhile, it might help if you would post answers to the following questions:

What units are you using for speed commands when in Speed mode?

How did you determine the PID gains?

Have you looked at the encoder values you are getting?

Put the bot up on blocks and command pure strafe right. Observe the 4 wheels and tell us what direction each wheel is spinning, in both PercentVbus and Speed mode. Just saw your edit, so: What direction was each wheel spinning?





Last edited by Ether : 07-02-2015 at 17:47.
  #3   Spotlight this post!  
Unread 07-02-2015, 17:35
Jacob Abel Jacob Abel is offline
Registered User
FRC #1557 (12 Volt Bolt)
Team Role: CAD
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Mount Dora, FL
Posts: 5
Jacob Abel is an unknown quantity at this point
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

Well I would try setting the feedback device earlier than the PID, and the PID earlier than the speed.
EDIT: Additionally, I would say that an IMU with a Kalman's filter would work better than encoders as encoders will not report as accurately on mecanum do to discrepancies in roller resistance.

Last edited by Jacob Abel : 07-02-2015 at 17:38.
  #4   Spotlight this post!  
Unread 07-02-2015, 17:44
goldenguy00 goldenguy00 is offline
Registered User
FRC #0619
 
Join Date: Feb 2015
Location: Virginia
Posts: 4
goldenguy00 is an unknown quantity at this point
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

Quote:
Originally Posted by Ether View Post

What direction was each wheel spinning?

The top left and bottom right rotated counter-clockwise and the opposite for the other wheels.

[<--] [-->]
[-->] [<--]

Like this. It works well enough, except it veers to the right side.

Quote:
Originally Posted by Ether View Post

How did you determine the PID gains?

We just used default values given by a manual. We messed around with them a bit, but no difference to before.

Last edited by goldenguy00 : 07-02-2015 at 17:58.
  #5   Spotlight this post!  
Unread 07-02-2015, 17:49
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

Quote:
Originally Posted by goldenguy00 View Post
The top left and bottom right rotated counter-clockwise and the opposite for the other wheels.

[<--] [-->]
[-->] [<--]

Like this. It works well enough, except it veers to the right side.
I'm sure the diagram makes perfect sense, but not without some explanation. What do the arrows mean? Which wheel is which?


  #6   Spotlight this post!  
Unread 07-02-2015, 17:54
goldenguy00 goldenguy00 is offline
Registered User
FRC #0619
 
Join Date: Feb 2015
Location: Virginia
Posts: 4
goldenguy00 is an unknown quantity at this point
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

I should have added a bit of detail. The arrows are the direction of the wheels from the top down. The movement should be upwards, where the top left is the top left wheel, the top right is the top right wheel, and so on and so forth. This is assuming sliding is up and down according to the diagram.

I have already checked the movement against your explanations, and they checked out. Any errors you see above are my personal errors.

Last edited by goldenguy00 : 07-02-2015 at 17:57.
  #7   Spotlight this post!  
Unread 07-02-2015, 18:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

Quote:
Originally Posted by goldenguy00 View Post
It works well enough, except it veers to the right side.
I'm a bit uncertain what the above means. When strafing to the right, the bot should "slide" sideways to the right. How is "veers to the right side" different from that?


  #8   Spotlight this post!  
Unread 07-02-2015, 18:10
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)


In case you missed these questions:

Quote:
Originally Posted by Ether View Post
What units are you using for speed commands when in Speed mode?

Have you looked at the encoder values you are getting?

  #9   Spotlight this post!  
Unread 07-02-2015, 18:18
goldenguy00 goldenguy00 is offline
Registered User
FRC #0619
 
Join Date: Feb 2015
Location: Virginia
Posts: 4
goldenguy00 is an unknown quantity at this point
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

I'm trying to make things simpler by changing the orientation, but I guess I'm doing the opposite. So to drive forward, the wheels all move in the same direction.

<---- (movement from top down)

Forward (<)
[top right] [bottom right]
[top left] [bottom left]

Sliding right (^)
[<--] [-->]
[-->] [<--]

Sliding left (v)
[-->] [<--]
[<--] [-->]

The problem we are running into is that when sliding, it veers up and down. The right top and bottom output velocity values lower than those on the right top and bottom
  #10   Spotlight this post!  
Unread 07-02-2015, 19:07
lcoreyl's Avatar
lcoreyl lcoreyl is offline
WittyTitleGen can't link to library
AKA: Milner
no team
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Colorado Springs
Posts: 201
lcoreyl has much to be proud oflcoreyl has much to be proud oflcoreyl has much to be proud oflcoreyl has much to be proud oflcoreyl has much to be proud oflcoreyl has much to be proud oflcoreyl has much to be proud oflcoreyl has much to be proud oflcoreyl has much to be proud of
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

Quote:
Originally Posted by goldenguy00 View Post
I'm trying to make things simpler by changing the orientation, but I guess I'm doing the opposite. So to drive forward, the wheels all move in the same direction.

<---- (movement from top down)

Forward (<)
[top right] [bottom right]
[top left] [bottom left]

Sliding right (^)
[<--] [-->]
[-->] [<--]

Sliding left (v)
[-->] [<--]
[<--] [-->]

The problem we are running into is that when sliding, it veers up and down. The right top and bottom output velocity values lower than those on the right top and bottom
First off, your wheel spins look to be backwards for the strafes, unless your wheel rollers are configured in an X (worm's eye view). However, you said you can turn normally, so you are likely configured correctly to be O and just have things backwards here??

Have you checked things mechanically before you go correcting things with sensors?
-can all rollers spin freely?

-what happens when you drive at 45 degree angle?

-I have seen both a bad motor and an incorrectly assembled gearbox cause problems that you can't visually see when you put the robot up on blocks and look at wheel speeds. unplugging 2 PWMs at a time can sometimes help troubleshoot this: unplug front motors then rears and drive forward/back, then sides and strafe both ways. compare how far off course you get in each case.

for that matter, can you try to quantify how far off a perfect strafe you are in the normal configuration? Of course, a VIDEO WOULD GET YOU BETTER HELP!!!
  #11   Spotlight this post!  
Unread 07-02-2015, 19:16
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)


Have you gathered and analyzed the troubleshooting data in the status frames? What did you find?

20.1. General Status
The General Status frame has a default period of 10ms, and provides…
-Closed Loop Error: the closed-loop target minus actual position/velocity.
-Throttle: The current 10bit motor output duty cycle (-1023 full reverse to +1023 full forward).


20.3. Quadrature Encoder Status
The Quadrature Encoder Status frame has a default period of 100ms.
-Encoder Velocity: Velocity of the selected sensor


  #12   Spotlight this post!  
Unread 07-02-2015, 19:22
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)



There appears to be some confusion interpreting your ASCII art.

Please confirm that your wheel speeds conform to the attached sketches.


Attached Thumbnails
Click image for larger version

Name:	Forward.png
Views:	76
Size:	15.7 KB
ID:	18194  Click image for larger version

Name:	Rotate Right.png
Views:	54
Size:	16.6 KB
ID:	18195  Click image for larger version

Name:	Strafe Right.png
Views:	53
Size:	15.6 KB
ID:	18196  
  #13   Spotlight this post!  
Unread 07-02-2015, 19:49
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

For what it's worth, I understood the pictures immediately, and I think they look correct.

How heavy is your robot, and how is the weight distributed? The symptom sounds like the back wheels are slipping a little on the carpet, which suggests that the robot is front-heavy.

The ultimate solution is going to be to recognize that controlling wheel speed precisely isn't good enough to always prevent unwanted rotation of a mecanum drivebase. You're going to have to add some way of measuring the actual robot motion, and in this case I think the appropriate sensor to do that is a gyro.
  #14   Spotlight this post!  
Unread 07-02-2015, 20:13
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

Quote:
Originally Posted by goldenguy00 View Post

[top right] [bottom right]
[top left] [bottom left]

Sliding right (^)
[<--] [-->]
[-->] [<--]

Quote:
Originally Posted by lcoreyl View Post

your wheel spins look to be backwards for the strafes

I'd have to agree with lcoreyl here. Your diagram appears to be saying that the right-side wheels are being driven away from each other, and the left-side wheels are being driven toward each other for strafe right. If that's what you meant, it's not correct: that would be the wheel directions for strafe left.

But that's not what's causing your problem. You said in the OP that the robot doesn't move at all when it's on the ground and using ControlMode.Speed. I would recommend checking the status frames to see what the encoders are doing.


  #15   Spotlight this post!  
Unread 14-02-2015, 02:35
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 520
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
Re: Correcting Mecanum Wheels with Encoders (Ether, We Summon You!)

Quote:
Originally Posted by Alan Anderson View Post
For what it's worth, I understood the pictures immediately, and I think they look correct.

How heavy is your robot, and how is the weight distributed? The symptom sounds like the back wheels are slipping a little on the carpet, which suggests that the robot is front-heavy.

The ultimate solution is going to be to recognize that controlling wheel speed precisely isn't good enough to always prevent unwanted rotation of a mecanum drivebase. You're going to have to add some way of measuring the actual robot motion, and in this case I think the appropriate sensor to do that is a gyro.
If the weight is not distributed evenly, for a given voltage the angular acceleration of the heavier weight on wheels will will be lower relative to the lighter wheel, mecanum roller slippage or not. I think using the PID loop to even out the wheel RPMs is the right stategy.
Having said that, I rarely use the built-in PID controllers WPI provides, usually just write my own control loop. I'm not sure why OP selected values of P=0.1, I=.001, D=1 . Recommend reducing D down to near zero while testing, as this would just produce a damper which could null out your rates to near zero despite your offset.
__________________
My FIRST legacy:

Team 204 Student 2001, 2002 (Voorhees, NJ)
Team 1493 College Mentor 2006 - 2008 (Troy, NY)
Team 2150 Intern/Professional Mentor 2007, 2009 (Palos Verdes)
Team 4123 Lead Engineering Mentor 2012 (Bellflower, CA)
Team 4276 Engineering Mentor 2012-2016 (Huntington Beach, CA)
Closed Thread


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 21:06.

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


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