Nathan Leong | 217cd76 | 2022-10-22 16:07:30 -0700 | [diff] [blame^] | 1 | #ifndef FRC971_WPILIB_WPILIB_UTILS_H_ |
| 2 | #define FRC971_WPILIB_WPILIB_UTILS_H_ |
| 3 | |
| 4 | #include <functional> |
| 5 | |
| 6 | #include "frc971/constants.h" |
| 7 | |
| 8 | namespace frc971 { |
| 9 | namespace wpilib { |
| 10 | |
| 11 | // Convert min and max angle positions from range to voltage and compare to |
| 12 | // min and max potentiometer voltage to check if in range. |
| 13 | |
| 14 | // subsystem_range is a ::frc971::constants::Range that defines the pot limits |
| 15 | // potentiometer_offset is a constant that is the initial offset of the pot |
| 16 | // pot_translate_inverse is a function that translates an angle to voltage |
| 17 | // reverse is a boolean that sets the pot voltage range as -5 to 0 when true |
| 18 | // limit_buffer is a constant that is the buffer for the maximum voltage values |
| 19 | |
| 20 | bool SafePotVoltageRange(::frc971::constants::Range subsystem_range, |
| 21 | double potentiometer_offset, |
| 22 | ::std::function<double(double)> pot_translate_inverse, |
| 23 | bool reverse, double limit_buffer = 0.05); |
| 24 | |
| 25 | } // namespace wpilib |
| 26 | } // namespace frc971 |
| 27 | |
| 28 | #endif // FRC971_WPILIB_WPILIB_UTILS_H_ |