Quote:
Originally Posted by duane
Thank you for sharing the code for the gyro. A couple of comments:
|
no problem
Quote:
Originally Posted by duane
You used a Task and Timers rather than a notifier. Seems like a notifier could make the code easier, but there are also two timers which indeed complicate a bit. Are two timers needed? I'd have to read closer to work it out.
|
I did not change the original code all that much. The changes you recommend make sense. One could use a single timer for both the calibration and update functions. I've not used a WPI notifier yet. Is it a wrapper for a counting semaphore? The gyro started working right and I wanted to get it to the students to work on their autonomous behaviours.
Quote:
Originally Posted by duane
The floating point values are floats instead of doubles. Any particular reason? I'm used to thinking of doubles as being just fine for most uses. WPI Lib seems to use doubles everywhere.
|
I did not think the precision was necessary. One can only "point" the robot with a certain amount of accuracy anyways. Doubles will work.
Quote:
Originally Posted by duane
The float values are being updated from a task and read from the robot loop. I think a mutex is needed to protect the values being read. Keep in mind that this year, we really do have multiple processors which means we should pay attention to atomic operations. I don't think a double or float is atomic.
|
Floats are atomic as they are word-sized on a 32-bit machine. But a more portable implementation would protect the data - good idea.
Quote:
Originally Posted by duane
This should be great for us to get going with the gyros.
I'll be happy to contribute to any changes we make.
|
good luck!
adding averaging would be nice
Quote:
Originally Posted by duane
ps Gotta luv github!
|
ditto