View Single Post
  #2   Spotlight this post!  
Unread 06-11-2013, 14:01
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