This is our first year running WPILib and so far we like it a lot. However, I was wondering how we can get the current value of the motors on the robot. I read through the entire WPILib documentation and I couldn’t find any functions for getting current motor values. With the default code, we could just look at pwm01 through pwm16 to get the motor values. I know I could just store the value I last gave the motor and use that when I need to, but with WPILib your code can loop faster than 26.2 ms, so it is possible to assign values to motors faster than the processor does. So how can I find the current actual value for the motors?
Is the question: “How do I read the motor values last sent to the master processor?”
I don’t believe there is an interface call that can do this… and I’m not entirely sure you need that info.
If you just want to know what is the current packet to be transmitted to the master processor, check out ifi_defaults.h and the txdata packet. Specifically you should be able to read the data I think you’re looking for in
We’re using WPILib, but we copied over ifi_aliases.h and a few other header files from the default code. After commenting out a few lines, we got rid of all duplicate functions and #defines. Once you have that, you can call pwm01 as normal. You don’t even have to use WPILib’s SetMotor function. You can just say pwm01 = 127 or printf("%d\r", (int)pwm01) or whatever you’d normally say without WPILib.