Valkyrie 2026
Loading...
Searching...
No Matches
NeoController.h
1#pragma once
2
3#include <memory>
4#include <string>
5
6#include <rev/SparkMax.h>
7#include <rev/config/SparkMaxConfig.h>
8#include <rev/sim/SparkMaxSim.h>
9#include <units/base.h>
10#include <valkyrie/controllers/BaseController.h>
11
12namespace valor {
13
14enum NeoControllerType { NEO, NEO_550 };
15
16class NeoController : public BaseController, public rev::spark::SparkMax {
17 public:
18 NeoController(valor::NeoControllerType, int canID, valor::NeutralMode mode, bool inverted);
19
20 static constexpr frc::DCMotor getMotorSpec(NeoControllerType controllerType) {
21 switch (controllerType) {
22 case NEO_550:
23 return frc::DCMotor::NEO550();
24 default:
25 return frc::DCMotor::NEO();
26 }
27 }
28
29 void ApplyConfig() override;
30
32
34
35 Signal<units::volt_t> GetVoltage() const override;
36
38
39 Signal<units::turns_per_second_squared_t> GetAcceleration() const override;
40
41 void SetEncoderPosition(units::turn_t position) override;
42
43 units::turn_t GetAbsoluteEncoderPosition() const override;
44
45 void SetContinuousWrap(bool wrap, bool saveImmediately = false);
46
47 void PositionSetter(units::turn_t positon, Output feedforward, int slot = 0) override;
48 void SpeedSetter(units::turns_per_second_t speed, Output feedforward, int slot = 0) override;
49
50 void SetupFollower(int canID, bool followerInverted = false) override;
51
52 void SetPIDF(valor::PIDF<> pidf, int slot = 0, bool saveImmediately = false) override;
53
54 void SetForwardLimit(units::turn_t forward, bool saveImmediately = false) override;
55
56 void SetReverseLimit(units::turn_t reverse, bool saveImmediately = false) override;
57
58 void SetGearRatios(double rotorToSensor, double sensorToMech, bool saveImmediately = false) override;
59
60 void SetCurrentLimits(units::ampere_t statorCurrentLimit, bool saveImmediately = false);
61
62 void SetNeutralMode(valor::NeutralMode mode, bool saveImmediately = false) override;
63
64 void SetOpenLoopRamp(units::second_t time, bool saveImmediately = false) override;
65
66 void PowerSetter(Output out) override;
67
68 void LoggablePeriodic() override;
69
70 units::volt_t CalculateAppliedVoltage() override;
71
72 using BaseController::SetSimState;
73 void SetSimState(units::turn_t pos, units::turns_per_second_t vel, units::turns_per_second_squared_t accel) override;
74 void SetSimState(frc::sim::DCMotorSim&) override;
75 void SetSimState(frc::sim::FlywheelSim&) override;
76
77 private:
78 static constexpr units::ampere_t STATOR_CURRENT_LIMIT = 40_A;
79
80 valor::PIDF<> pidf;
81
82 rev::spark::SparkMaxConfig config;
83 std::unique_ptr<rev::spark::SparkMax> followerMotor;
84 rev::spark::SparkMaxSim sim;
85};
86} // namespace valor
Definition BaseController.h:62
BaseController(frc::DCMotor _motorSpec)
Construct a new Valor Controller object.
Definition BaseController.h:95
void SpeedSetter(units::turns_per_second_t speed, Output feedforward, int slot=0) override
Send the motor to a specific speed.
void SetGearRatios(double rotorToSensor, double sensorToMech, bool saveImmediately=false) override
Set the gear ratios for the motor.
void PositionSetter(units::turn_t positon, Output feedforward, int slot=0) override
Send the motor to a specific position.
void SetForwardLimit(units::turn_t forward, bool saveImmediately=false) override
Set the forward soft limit for the motor.
void SetNeutralMode(valor::NeutralMode mode, bool saveImmediately=false) override
Set the neutral mode of the motor.
Signal< units::ampere_t > GetCurrent() const override
Get the motors output current.
void SetReverseLimit(units::turn_t reverse, bool saveImmediately=false) override
Set the reverse soft limit for the motor.
Signal< units::turns_per_second_t > GetSpeed() const override
Get the motors speed.
Signal< units::turn_t > GetPosition() const override
Get the motors position.
void SetupFollower(int canID, bool followerInverted=false) override
If a motor is paired with another motor, setup that other motor as a follower.
void LoggablePeriodic() override
Periodic callback for logging updates.
void SetPIDF(valor::PIDF<> pidf, int slot=0, bool saveImmediately=false) override
Change the PIDF values for the motor.
Container to hold PID and feed forward values for the motor controller.
Definition PIDF.h:26