Correcting Travel Direction

On a mecanum drive base, is there a way to correct for driving direction? For instance, if I want to go 40 degrees to the left of straight, how can I correct any error? I know encoders would be ideal, but is this possible with an accelerometer?

I could use an integrator on an accelerometer to get velocity, but that’s not always very accurate. Any other ideas?

Perhaps I need to elaborate a bit. I don’t mean to be a bother, and I know that people have talked about correcting mecanum drive, but I just want to expand on this.

I would assume that to use an accelerometer to correct for travel direction, one must integrate the accelerometer readings to get velocity to get heading. Does anyone have any hints on this, or is it just integrating? Do I want to filter in case of collisions or other such things? How or when should I calibrate? How do I account for drift?

Using accelerometers on FRC robots to derive position is a hard problem. So hard, in fact, that I don’t know of any teams who have reliably solved it. I wouldn’t even attempt it. Closed-loop control of the wheel speeds using encoders is easy.

I understand that position is difficult, but what about velocity?

Unfortunately, wheel encoders are impossible at this point, due to our design. Also, there’s no time to tune 4 PID loops for velocity…

Use a gyro.

Take your desired heading angle and subtract the gyro angle from that. Do a little math on the result and run it through a PID.

What you do with the PID output depends on what you mean by “I want to go 40 degrees to the left of straight”.

For example, if you want the robot to stay pointed in the commanded direction, the output of the PID would drive the mec’s rotation command.

**

We already have a gyro for facing direction, but a gyro does not help with travel direction, correct? I might be wrong about this…

Is this for autonomous? or for driving in teleop? If it’s autonomous, you might want to make use of line sensors or camera targets instead. For adding rotation encoders, look for creative ways to drive them using belts, small wheels, etc

It’s for driving in Teleop. Our robot doesn’t drive all that straight when strafing, and I was hoping to correct with the accelerometer.

As Alan said, good luck. It’s a tough problem.

Look at team 488 robot, I think they added encoders to little wheels that move on the floor. you could use two Vex omni wheels, oriented 90 degrees to each other, to get feedback on how the robot is moving in both directions.

Might have trouble implementing it in one day though.

Again, it depends on what you mean by “travel direction”.

You could use the gyro to rotate the vehicle to point to and hold a particular direction, and then issue a robot-centric “straight forward” command.

It’s for driving in Teleop. Our robot doesn’t drive all that straight when strafing, and I was hoping to correct with the accelerometer.

That’s a different problem statement from what you said earlier (“40 degrees to the left of straight”).

When you say “Our robot doesn’t drive all that straight when strafing” do you mean

a) It drives in a straight line, but not perfectly perpendicular to the robot’s fore/aft axis, or

b) It rotates as it strafes, and travels along a curved path, or

c) something else?

The problem solution depends on the problem.

**

If the travel direction is different than the facing direction, such as strafing left and right while facing forward, it does not always drive in the given direction.

That didn’t answer the question.

Does the robot rotate as it strafes, or does it maintain its orientation?

Does it drive in a curved path or a straight path?

Does it always do pretty much the same thing each time for a given command, or does it do one thing one time and another thing another time?

**

I’m not 100% sure, because I’m not with the robot right now, but if I remember correctly it’s straight but in the wrong direction. We are correcting facing direction with the gyro, so that’s not a problem. What are the significances of that, might I ask? We’re new to mecanum, so we’re not up to par with all the tips and tricks to get it working properly…

OK. Now, does it always do pretty much the same thing each time for a given command, or does it do one thing one time and another thing another time? (There’s a reason I keep asking this).

if I remember correctly it’s straight but in the wrong direction. What are the significances of that, might I ask?

Many factors could cause this behavior, including friction, free play, alignment, motor tolerances, wiring, and software. To get to the root cause would require time and patience, things which I’m guessing you probably don’t have right now.

**

After a bit of tweaking, our Drivetrain is driveable. The accelerometer didn’t work, but I didn’t put a whole lot of effort into trying to (by filters or anything) because in the end, it isn’t significant enough to be worth the copious amounts of work needed to get it done.

At any rate, thank you so much for your help and input. I learned a lot about what does and doesn’t work.