Go to Post Gatting your senior pic with robot = (Cool factor * infinity). :cool: - Elgin Clock [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 04-30-2013, 09:46 AM
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Syncronous motor speed with encoders

Hello! We're considering using building another robot with Mecanum wheels for an off-season project to apply what we know as far as programming, but there may be a problem.... From what I've read, there can be a lot of problems when using holonomic steering if the motors aren't spinning at exactly the correct speed. I'm fairly certain that the absolute value of the wheel speed always has to be the same. I know that the simplest code for holonomic drive is
Code:
public void mecanumDrive_Cartesian(double x, double y, double rotation, double gyroAngle)
but, as far as I know, that code wouldn't allow us to control the motor speed independently. Do I have to modify the mecanumDrive_Cartesian.cpp file? I assume that I'll need PID loops somewhere in the program (which I have no idea how to write) to interpret the data from the encoders. Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 11-06-2013, 08:33 AM
gpetilli gpetilli is offline
Registered User
FRC #1559
 
Join Date: Jan 2009
Location: Victor, NY
Posts: 285
gpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to all
Re: Syncronous motor speed with encoders

I don't know if this is a live thread, but I will suggest two options anyway.

If you want to use the WPI code you linked, the most straight forward method would be to use CAN Jaguar speed controllers and hook up encoders on each wheel connected directly to the Jaguar. Then you setup the Jaguars to do the PID loop on each wheel. There are many posts on how to do this, but the most successful seems to be to adjust the I term first and then the P term.

The other option would be to write your own Holonomic code - it is not that difficult. Ether has a link to some pseudo code that works well. My team took this approach and the robot was driving in about an hour.

To address the wheel speed issue, the consensus is that you need gyro feedback. Keep in mind that even if the wheels are all spinning at exactly the correct speeds, the force vector they create is a function of the weight on the wheel. If the CG is off or one wheel is lifted off the ground the robot could spin violently. The gyro can help redirect power to the wheels to compensate.
Reply With Quote
  #3   Spotlight this post!  
Unread 11-06-2013, 02:01 PM
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Syncronous motor speed with encoders

Hey! This thread isn't entirely dead :P We did end up completing our mecanum chassis (3 days from start to finish). What we wound up doing was writing our own mecanum code (thanks Ether) and ten compensating for the speed differences by multiplying each value by a constant which we figured out by trial and error (probably the simplest and worst solution). It looked like this:
Code:
	//motor speed control method
	public static float fix (float fixme) {
		return fixme < 0.00f ? 1.00f : 0.95f;
		//manipulates motor values based on direction only
	}
	
	//overload motor speed control method
	public static float fix (int motorID, float fixme) {
		if      (motorID == 1){ return (fixme < 0f)? 1:0.95f; }  //frontLeft
		else if (motorID == 2){ return (fixme < 0f)? 1:0.85f; }  //frontRight
		else if (motorID == 3){ return (fixme < 0f)? 1:0.75f; }  //backLeft
		else if (motorID == 4){ return (fixme < 0f)? 1:0.65f; }  //backRight
		else return 0;
		//manipulates motor values based on direction and ID (slower, more precise)
	}
and when actually controlling the motors, we used
Code:
Motor->Set(speedval*(fix(speedval))
It's not exactly elegant, and it doesn't always work well. We've proposed two things to remedy the issues, but never tried: 1) when rotation is 0, reset the gyro and drive using the gyro, or 2) Run four consecutive PI(D?) loops to that take the desired RPM from the joystick (map +1/-1 values after the drive equations to +max_rpm/-max_rpm) and attempt to set the motors to that. I have no idea if there's something in-between, or whether or not it would be fast/consistent enough to work in real time. Any ideas about that?
Reply With Quote
  #4   Spotlight this post!  
Unread 11-08-2013, 11:09 AM
gpetilli gpetilli is offline
Registered User
FRC #1559
 
Join Date: Jan 2009
Location: Victor, NY
Posts: 285
gpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to all
Re: Syncronous motor speed with encoders

Quote:
Originally Posted by gpetilli View Post
Keep in mind that even if the wheels are all spinning at exactly the correct speeds, the force vector they create is a function of the weight on the wheel. If the CG is off or one wheel is lifted off the ground the robot could spin violently.
I would like to add a clarification to my post above. The amount of torque (and therefor force vector) that a wheel can impart is a function of the traction of the wheel, which is limited by the weight on that wheel. If the CG is such that the weight is unevenly distributed, one wheel may break traction before the others, changing it's force vector contribution and cause the robot to spin. All this assumes the wheels are spinning at the correct speeds an therefor trying to impart the correct force vector.

As for your wheel velocity correction method, yes it will work (for some time) but will not adapt for changes in the environment or robot. Your range of gains is larger than I have seen in the past, and you might want to look for the root cause. The only time I have had one wheel off that much, we tracked it down to a CIM with a very slightly bent output shaft, which caused the spur gear to over engage the gearbox and load the motor more. Start by looking at your slowest wheel and check your weight distribution. Is the frame planar? With the robot on a flat surface, try sliding a piece of paper under each wheel.
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 09:54 AM.

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