[wpilib] Rewrite DutyCycleEncoder and AnalogEncoder (#6398)

This commit is contained in:
Thad House
2024-05-24 11:53:56 -07:00
committed by GitHub
parent 294c9946ae
commit d05c7c125b
18 changed files with 638 additions and 883 deletions

View File

@@ -28,28 +28,16 @@ class AnalogEncoderSim {
explicit AnalogEncoderSim(const AnalogEncoder& encoder);
/**
* Set the position using an Rotation2d.
* Set the position.
*
* @param angle The angle.
* @param value The position.
*/
void SetPosition(Rotation2d angle);
/**
* Set the position of the encoder.
*
* @param turns The position.
*/
void SetTurns(units::turn_t turns);
void Set(double value);
/**
* Get the simulated position.
*/
units::turn_t GetTurns();
/**
* Get the position as a Rotation2d.
*/
Rotation2d GetPosition();
double Get();
private:
hal::SimDouble m_positionSim;

View File

@@ -33,55 +33,18 @@ class DutyCycleEncoderSim {
explicit DutyCycleEncoderSim(int channel);
/**
* Get the position in turns.
* Get the position.
*
* @return The position.
*/
double Get();
/**
* Set the position in turns.
* Set the position.
*
* @param turns The position.
* @param value The position.
*/
void Set(units::turn_t turns);
/**
* Get the distance.
*
* @return The distance.
*/
double GetDistance();
/**
* Set the distance.
*
* @param distance The distance.
*/
void SetDistance(double distance);
/**
* Get the absolute position.
*
* @return The absolute position
*/
double GetAbsolutePosition();
/**
* Set the absolute position.
*
* @param position The absolute position
*/
void SetAbsolutePosition(double position);
/**
* Get the distance per rotation for this encoder.
*
* @return The scale factor that will be used to convert rotation to useful
* units.
*/
double GetDistancePerRotation();
void Set(double value);
/**
* Get if the encoder is connected.
@@ -99,8 +62,6 @@ class DutyCycleEncoderSim {
private:
hal::SimDouble m_simPosition;
hal::SimDouble m_simDistancePerRotation;
hal::SimDouble m_simAbsolutePosition;
hal::SimBoolean m_simIsConnected;
};