FRC1076 / 2019-Competition

Code for 2019 Competition
2 stars 1 forks source link

Implement VisionSensor #49

Open mcolinj opened 5 years ago

mcolinj commented 5 years ago

Current stub implementation is in subsystems.remoteSensors.py

VisionSensor should create a communication channel to the vision processor and listen for angle updates about every 5 robot cycles. A receiveAngleUpdates() method should be called in the robot loop to receive the update, parse the payload, and save the angle value to be returned to the PIDController on demand. The latest angle update value is cached in the VisionSensor object so it can be returned to the PID Controller using it via the getPid() method. This should be initialized to 0 so the value is returned when the vision sensor is not in contact with the vision processor.

This needs a crash free creation of the communication channel to the vision processor. It should be robust enough to not fail if that doesn't work right away. As long as the channel is not successfully initialized, it should keep trying it every time receiveAngleUpdates is called. e.g. if self.channel is None. So, it should squirrel away all of the values necessary to retry creating the channel.

mcolinj commented 5 years ago

You should be able to create this in the context of some unit test framework. Check with @EPrograming or @WilliamBallbach if you want help creating a unit test that talks both ends of a communication channel.

mcolinj commented 5 years ago

Ultimately it will need to listen for packets sent by the vision subsystem, so be sure to discuss with @CharlieMonk about the wire format he will be using for the vision packets.

mcolinj commented 5 years ago

VisionSensor object has to be the source of data for the PIDController, so it must identify itself as providing a displacement (rather than a rate). Be sure to add this method to it.

def getPIDSourceType(self): return wpilib.interfaces.pidsource.PIDSource.PIDSourceType.kDisplacement