View Single Post
  #13   Spotlight this post!  
Unread 30-09-2014, 21:57
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: Mecanum Wheels & Encoders -- Java code

Quote:
Originally Posted by aweso_meme View Post
At this point in time, that is our aspiration. I am the only one who knows how to program the robot on our team, and I simply do not have the time right now to put into learning about PID. I will learn about that for competition, but right now we are doing some out of competition practice. I have been having trouble with setting up the encoders and the master/slave wheels. Do you guys have some kind of set-up for that?
No one here has been very helpful yet with OP's original project goals, so I'll chime in here. I see exactly what what you want to do, so here's what I suggest:

First, learn how the mecanum drive classes actually map joystick inputs to individual motor powers and generate an equation describing them. Stick with linear control and it should be relatively simple to interpolate.

For example, look at the constraints first:

When JoyY1 = 1 and JoyX = 0, all four motors output "1" (for purposes of this exercise, reverse polarity on the opposing wheels due to gearbox orientation)

When JoyY1 = -1 and JoyX = 0, all four motors output "-1"
When JoyY1 = 0 and JoyX = 1, Front outputs "1" and rear outputs "-1"
When JoyY1 = 0 and JoyX = -1, Rear outputs "-1" and front output "1"
When JoyY1 = 1 and JoyX = 1, Front outputs "1" and rear outputs "0"
...
etc etc

Anyway, map the entire region on an XY plane and you can see how the X input and Y input varies each motor power. Note that they are dependent.

Now, in your code you can record the X and Y input values, and calculate the "expected" motor output powers. Use your reference encoder to relate power vs rpm (say, 100 rpm = 0.7 power output) and calculate a "control" constant (although this could be a function and not a constant -- determine this by testing at different powers). C = 100/0.7 (or whatever units you want).

For the rest of the wheels, read in encoder values and calculate new power ratios based on how different each wheel's power correlates to their rpm.
100 rpm / C = output power.
If "output power" is exactly 0.7 here as well, the wheel speeds are equal. But since they're not due to friction or other reasons, you will need to generate new constants for each wheel.
100 rpm / C = 0.7 * constant

that constant will be close to 1 -- maybe 0.95 if that particular wheel has less friction, 1.05 if it has more.
Anyway, take this constant and bias the mecanum drive output: motor1.set(motor1_output*constant);

That way, in the case where JoyY = 1 and JoyX = 0 (for example), Motor1 = 1 but Motor2 = 0.95, thus keeping the robot driving straight.

Last thing -- you'd have to determine the "worst-case" motor, the one that performs the worst for a given output power, and use that as your limiting output power. Otherwise the less powerful wheel will saturate (above calc will be >1) and the power will truncate to 1. So all the constants to 3 motors should be <1, and the least effective motor is exactly 1.
__________________
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)
Reply With Quote