[wpilib] Add DutyCycleEncoderSim (#2798)

This commit is contained in:
Tyler Veness
2020-10-23 20:18:49 -07:00
committed by GitHub
parent 4422904a2e
commit 1069019fd2
6 changed files with 158 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <hal/SimDevice.h>
#include <units/angle.h>
namespace frc {
class DutyCycleEncoder;
namespace sim {
/**
* Class to control a simulated duty cycle encoder.
*/
class DutyCycleEncoderSim {
public:
/**
* Constructs from a DutyCycleEncoder object.
*
* @param dutyCycleEncoder DutyCycleEncoder to simulate
*/
explicit DutyCycleEncoderSim(const DutyCycleEncoder& encoder);
/**
* Set the position tin turns.
*
* @param turns The position.
*/
void Set(units::turn_t turns);
/**
* Set the position.
*/
void SetDistance(double distance);
private:
hal::SimDouble m_simPosition;
hal::SimDouble m_simDistancePerRotation;
};
} // namespace sim
} // namespace frc