Extended DifferentialDrive class to use IMU and PID to drive straight when using arcade drive #85
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've noticed that the XRP is unable to drive straight due to surface textures, friction with the rollers, etc. Students find it frustrating that they have a hard time controlling the XRP, especially with the new support for gamepad control. I had previously added behavior at the application level to use the IMU with PID to allow the XRP to maintain a constant heading and thought that it would be better if the XRP library supported this capability natively.
The proposed changes extend the DifferentialDrive class to allow it to drive straight under arcade control. When enabled by the presence of the IMU parameter during instantiation, the new behavior will maintain a course heading when driving straight (turn value of 0.0). If a turn is requested, the new behavior will set a turning indicator and apply the derived left/right motor speeds without correction. Then once the turn value is 0.0 again, the heading will be reset based and the XRP will follow this new course heading until another turn is requested.
No attempt was made to refactor either the straight() or turn() behavior to match the arcade() changes, but that can be easily done so that the implementations better match.