![]() |
Encoders for testing
When implementing tests for an off season evaluation I've run into a lack of documentation on how to mock out encoders. Obviously, for booleans and analogs it is possible to do stuff like:
Code:
hal_data['analog_in'][2]['voltage'] = self.positionWas curious if anyone had tried to do this and found a good way to do it? (65% test coverage is bothering me) |
Re: Encoders for testing
In case someone else comes along curious about the same thing, because it wasn't intuitive to me, you can access the encoder count value by using:
Code:
hal_data['encoder'][index]['count'] |
Re: Encoders for testing
The encoders are driven by the way that they're initialized underneath the hood, and it's a bit odd. Perhaps the HAL implementation will get updated this fall and it'll get better. Sorry about the lack of documentation. Feel free to improve it and submit a PR. :)
You'll note of course that the place where the implementation tends to be strong is in stuff that we used, and as you mentioned I like to attach encoders to the CAN devices directly instead of using them standalone. :D |
Re: Encoders for testing
I suspect a good utility function to add to the test HAL would be 'get_encoder(pinA, pinB)' that would scan the list of encoders and find a matching encoder, and return that dictionary. (Bug report now at https://github.com/robotpy/robotpy-wpilib/issues/152)
|
Re: Encoders for testing
Quote:
And don't worry, I'll take a whack at a PR (or one of my students will) once we have something to contribute back. And we haven't (yet) made the leap to CAN though I suspect that might be coming in the near future. But possibly one major change in the software is enough for the time being. |
Re: Encoders for testing
When I said 'driven', I should have said 'the design for the encoders was driven'
|
Re: Encoders for testing
Quote:
|
| All times are GMT -5. The time now is 19:51. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi