WPILibC++ 2023.4.3-108-ge5452e3
FlywheelSim.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
9
13
14namespace frc::sim {
15/**
16 * Represents a simulated flywheel mechanism.
17 */
18class FlywheelSim : public LinearSystemSim<1, 1, 1> {
19 public:
20 /**
21 * Creates a simulated flywheel mechanism.
22 *
23 * @param plant The linear system representing the flywheel.
24 * @param gearbox The type of and number of motors in the flywheel
25 * gearbox.
26 * @param gearing The gearing of the flywheel (numbers greater than
27 * 1 represent reductions).
28 * @param measurementStdDevs The standard deviation of the measurement noise.
29 */
30 FlywheelSim(const LinearSystem<1, 1, 1>& plant, const DCMotor& gearbox,
31 double gearing,
32 const std::array<double, 1>& measurementStdDevs = {0.0});
33
34 /**
35 * Creates a simulated flywheel mechanism.
36 *
37 * @param gearbox The type of and number of motors in the flywheel
38 * gearbox.
39 * @param gearing The gearing of the flywheel (numbers greater than
40 * 1 represent reductions).
41 * @param moi The moment of inertia of the flywheel.
42 * @param measurementStdDevs The standard deviation of the measurement noise.
43 */
44 FlywheelSim(const DCMotor& gearbox, double gearing,
45 units::kilogram_square_meter_t moi,
46 const std::array<double, 1>& measurementStdDevs = {0.0});
47
48 /**
49 * Returns the flywheel velocity.
50 *
51 * @return The flywheel velocity.
52 */
53 units::radians_per_second_t GetAngularVelocity() const;
54
55 /**
56 * Returns the flywheel current draw.
57 *
58 * @return The flywheel current draw.
59 */
60 units::ampere_t GetCurrentDraw() const override;
61
62 /**
63 * Sets the input voltage for the flywheel.
64 *
65 * @param voltage The input voltage.
66 */
67 void SetInputVoltage(units::volt_t voltage);
68
69 private:
70 DCMotor m_gearbox;
71 double m_gearing;
72};
73} // namespace frc::sim
Holds the constants for a DC motor.
Definition: DCMotor.h:20
A plant defined using state-space notation.
Definition: LinearSystem.h:31
Represents a simulated flywheel mechanism.
Definition: FlywheelSim.h:18
FlywheelSim(const LinearSystem< 1, 1, 1 > &plant, const DCMotor &gearbox, double gearing, const std::array< double, 1 > &measurementStdDevs={0.0})
Creates a simulated flywheel mechanism.
units::radians_per_second_t GetAngularVelocity() const
Returns the flywheel velocity.
units::ampere_t GetCurrentDraw() const override
Returns the flywheel current draw.
void SetInputVoltage(units::volt_t voltage)
Sets the input voltage for the flywheel.
FlywheelSim(const DCMotor &gearbox, double gearing, units::kilogram_square_meter_t moi, const std::array< double, 1 > &measurementStdDevs={0.0})
Creates a simulated flywheel mechanism.
This class helps simulate linear systems.
Definition: LinearSystemSim.h:31
Definition: BatterySim.h:14