Closed agausmann closed 8 years ago
I made the proposed changes to the code in DriveSystem, and I removed the unassigned fields in Robot. The code should execute without error now.
Looks great. I did add a few comments above. Also, how about a unit test? It could act as a regression test to ensure the turn speed is not negated when the direction is flipped.
@AGausmann: Can you please squash the commits into one?
Squashed.
@AGausmann: Fantastic!
This PR adds a
DriveSystem
class to the robot. It is given an arcade-style drive interface and has anOrientation
that specifies which side of the robot is considered to be "forward." I also added a set of inputs to theRobot
class that are used to control the robot's motion and orientation.Execution of this code is likely to throw a
NullPointerException
due to the lack of field assignment inRobot
; however, we cannot assign meaningful values until we know what kinds of motor controllers are used and what ports are assigned to I/O.On Sunday, we had a discussion about different ways to implement subsystems. Zach favored implementations where the components of a subsystem are accessed directly by the user. However, I prefer implementations that abstract the control of subcomponents by providing methods for the actions you would want the user to take. For example, I provide methods like
setSpeed()
andstop()
instead of letting the user individually control the left and right motors. This can provide the user with a descriptive interface and has the potential to reduce redundancy in code, especially for complex calculations like arcade drive. Speaking of the complexity of code, we both agreed that any continuous/repetitive/looping/whatever you call it logic (like waiting for a switch to trigger) should be implemented as commands instead of methods. Thus, there is no such methodvoid driveForwardFor(double seconds)
orvoid driveForwardUntil(BooleanSupplier trigger)
as such would require continuous checking of a condition.