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