Hey, I was wondering where a good place to look for help with making field oriented holonomic code. Thanks a ton.
I assume by this you mean a holonomic drive where forwards on the stick means that your robot moves forwards no matter what the bot’s orientation.
The first thing you need is normal holonomic code. You probably want it to be closed-loop (i.e. velocity feedback control). There are plenty of other threads on that here.
The next thing you need is a gyro to get the robot heading. Kevin Watson’s gyro code is well written, and a good jumping off point.
Note that since the gyro measures angular velocity - not displacement - you must integrate its output (i.e. sum the velocities and divide by time) to get your orientation. This is the biggest hurdle for true orientation-independent holonomic code: your gyro will drift by a little bit, especially once you start bumping into things. I’ve seen other teams with omni/mecanum drives give the driver a button to reset the gyro heading to 0 when the drift gets bad enough.
You could try to use an electric compass as well, but these are more expensive, slower to respond, and shouldn’t be used near magnets - like electric motor.
Once you have your robot heading, things are easy. Get out a piece of paper and figure out the trig - take the forward (in the robot coordinate system) and left/right translation (in the robot c.s.) commands, and multiply them by the sine and cosine of the heading angle (which one goes to which depends on which direction the gyro thinks is positive). Leave the yaw command untouched. This correctly moves your robot in a straight path regardless of orientation.
Like I said, be mindful of gyro drift, and you will most likely need a tight feedback loop on the drive motors, but it has and can be done.
Also, gyros need to be hard mounted to the frame. If they are ziptied or other loose mount they will be innacruate.
Also, check the angular turning speed of the gyro. Some can’t do more than 180 degrees a second (or some other number, I forgot the exact one) and aren’t suitable for this use as any fast turns can throw them off.
Thanks for the replies, they helped a lot.
This ones pretty easy…
Code the robot so the frame moves in vectors relative to the base. (Velocity and direction)
Determine the input vector (trig)
Subtract the difference in direction (heading of robot - direction of input vector)
Do it.