# X-Drive Position Tracking

Does anyone know how to do position tracking for a X-Drive?
I’m thinking of 7 wheels in total, 2 on left/right and 1 on the back.
Also, could anyone give me a general guide in the position tracking program?

The extra 3 wheels would be unpowered? Would only the unpowered wheels have encoders?

I’m confused by the math of both of you. 2L +2R +1B = 5 wheels, right?

Tabor does provide a clue to the issues and possible solution of tracking X-drive. The issue is that the powered wheels likely slip (loose traction) more than would be expected on a typical drive base. If you are using encoders reading those wheels’ rotation, you will get bad numbers. The answer might be to have two un-powered wheels for the X and Y axis, each monitored by a shaft encoder, plus a gyroscope to asses turns.

I was under the impression that it was 4 wheels for the x drive. And then 3 extra that he had named, left right and back.

I see. Makes sense, and would eliminate the need for a gyro.

In that case, you can drive an x base a set distance much like you would a tank drive… power the holonomic motors in a while loop that is checking the values of the unpowered wheel encoders. There are several videos and tutorials that cover that process. A search for “robotC programming shaft encoder” results in some good solutions. I put some videos together a few summers ago for robotC 3.x that include programming for optical shaft encoders. Full disclaimer, I am pretty wordy in those videos (i.e. they are a bit slow.)

Would you really need 3 for the left ,right, and side; why not just have one for forward and one for strafing?

Probably something like a swing turn where 1 side is moving more than the other…

For a holonaumic drive you’ll need at least 3 encoders to fully track your motion including turns. For that reason i think a number of teams use ime’s

Would a gyroscope work better?
I was thinking of a wheel connected to an encoder on both left & right because I didn’t know where to put the wheel if there was only one.

No. Encoder wheels are better.

@cody made a pretty good position tracking program a while ago. Search his old threads to find it.

The rule is to take out shear, then rotation, then you get displacement/position. Luckily with most robots you don’t have to worry about the shape changing too much.

Gyro plus the red quads work well together. But you can use the IME’s too.

So this opinion was just quickly typed on my phone while laying in bed. Let me try to give a better response

Using real robotics approaches the best solution would be to have a gyro and as many encoders as possible and combine the sensors together using a good sensor fusion technique. (Kalman Filter)

Without a proper sensor fusion algorithm gyros can still be pretty good over short time frames or with a low pass filter. (might be high pass, I always forget which part of complimentary filter in IMU is for gyro or accel.)

In most cases though unpowered sensor wheels can give incredibly good data with no drift or wheel slip.

Why not use a accel instead of gyros and encoders?

Have you tried using the vex legal one? Also in general even with good sensors it is difficult.

even with the most expensive accelerometer for robotics you can buy will have the same fundamental issue

encoders measure distance with little error, gyros measure yaw rate which can be used to calculate yaw with a bit of error accumulating

with accelerometers you get acceleration which accumulates error in velocity rather than distance, meaning small errors in the measured value will exponentially affect the position, a robot that stands still will appear to be moving at a constant velocity

you also have to deal with gravity, if your robot tips over then gravity will affect your x and y axis making the error a LOT worse, you will literally move off of the field in seconds if your accelerometer gets tilted even slightly

Luke323Z did a lot of work with position tracking last season, so you may want to PM him. I don’t recall what all sensors he used, but it was pretty cool watching their turret and flywheel automatically adjust based on their position on the field.

One of the first things I did when I had a “robot” (a terrible chassis) was position tracking. I’ve gotten it working, and it works amazingly.

If you need any help feel free to PM me

The robot in the 2nd video has 2 wheels in the middle for position tracking. Did you consider making them friction wheels? The robot can’t detect if it drifts left or right, right?

Yeah, I didn’t have another shaft encoder at the time to put one perpendicular to the rest. I will now once I have time on our current robot.

But if the middle wheels are the traction wheels, then will the robot still drift left or right?