HuskieRobotics / 3061-lib

MIT License
26 stars 16 forks source link

support digital, single analog, and dual analog pressure sensors #8

Open gcschmit opened 1 year ago

gcschmit commented 1 year ago

The pneumatics subsystem currently only supports dual analog pressure sensors (from Rev). It would be relatively straight forward to add a parameter to the constructor to select between the above three options. (If using a digital pressure sensor, replace enableCompressorAnalog with enableCompressorDigital.)

gcschmit commented 1 year ago

From CD message: "There is a pneumatics.getCompressorConfigType() method that I believe tells you if the PDH is configured for digital or analog pressure sensor."

randomstring commented 1 year ago

I spent some time look at this today. Just detecting the compressor type requires the compressor mode to be set prior. I think the better option is to select the compressor mode when instantiating the pneumatic class. See my (yet untested): https://github.com/FRC-Sonic-Squirrels/3061-lib/commit/509db00a68b54b18da5a9475767bc0db34922378

There is also a hybrid mode, that uses both digital and analog sensors, so any calls to enableCompressorAnalog() could be replaced with enableCompressorHybrid() and I think it should work with either or both. https://first.wpi.edu/wpilib/allwpilib/docs/release/java/edu/wpi/first/wpilibj/PneumaticHub.html#enableCompressorHybrid(double,double)

gcschmit commented 1 year ago

Maybe an enumeration with more options:

or maybe two parameters – the first specifies the enumerated value related to compressor control and the second a boolean to indicate if a second analog pressure sensor is present to log pressure downstream of the regulator.

randomstring commented 1 year ago

I got my version of Pneumatics working with the digital sensor on my fork. Looks very similar to your solution.