3#include <initializer_list>
5#include <rev/CANSparkMax.h>
7#include <units/angle.h>
8#include <units/angular_acceleration.h>
9#include <units/angular_velocity.h>
10#include <units/current.h>
11#include <units/time.h>
13#include "rmb/motorcontrol/AngularVelocityController.h"
17namespace SparkMaxVelocityControllerHelper {
20 rev::CANSparkMax::MotorType motorType =
21 rev::CANSparkMax::MotorType::kBrushless;
22 bool inverted =
false;
24 units::ampere_t currentLimit = 40.0_A;
25 units::second_t openLoopRampRate = 0.5_s;
29 double p = 0.0, i = 0.0, d = 0.0, ff = 0.0;
30 units::radians_per_second_t tolerance = 0.0_rad_per_s;
31 double iZone = 0.0, iMaxAccumulator = 0.0;
32 double maxOutput = 1.0, minOutput = -1.0;
36 bool useSmartMotion =
false;
37 units::radians_per_second_t maxVelocity = 0.0_rad_per_s,
38 minVelocity = 0.0_rad_per_s;
39 units::radians_per_second_squared_t maxAcceleration = 0.0_rad_per_s_sq;
40 rev::SparkMaxPIDController::AccelStrategy accelStrategy =
41 rev::SparkMaxPIDController::AccelStrategy::kTrapezoidal;
43 units::second_t closedLoopRampRate = 0.5_s;
46enum EncoderType { HallSensor, Quadrature, Alternate, Absolute };
47enum LimitSwitchConfig { Disabled, NormalyOpen, NormalyClosed };
50 double gearRatio = 1.0;
51 EncoderType encoderType = HallSensor;
53 LimitSwitchConfig forwardSwitch = Disabled, reverseSwitch = Disabled;
66 using EncoderType = SparkMaxVelocityControllerHelper::EncoderType;
67 using LimitSwitchConfig = SparkMaxVelocityControllerHelper::LimitSwitchConfig;
75 std::initializer_list<const MotorConfig> followers;
83 rev::CANSparkMax &getMotor();
85 rev::SparkMaxPIDController &getPIDCOntroller();
87 std::unique_ptr<rev::MotorFeedbackSensor> &getFeedbackSensor();
98 void setVelocity(units::radians_per_second_t velocity)
override;
163 rev::CANSparkMax sparkMax;
164 std::vector<std::unique_ptr<rev::CANSparkMax>> followers;
165 rev::CANSparkMax::ControlType controlType;
167 rev::SparkMaxPIDController pidController;
168 units::radians_per_second_t targetVelocity = 0.0_rpm;
169 units::radians_per_second_t tolerance;
171 std::unique_ptr<rev::MotorFeedbackSensor> encoder;
172 EncoderType encoderType;
Definition AngularVelocityController.h:19
Definition SparkMaxVelocityController.h:61
void setEncoderPosition(units::radian_t position=0_rad) override
virtual units::radians_per_second_t getTolerance() const override
virtual void stop() override
virtual double getPower() const override
virtual void setPower(double power) override
units::radians_per_second_t getTargetVelocity() const override
units::radians_per_second_t getVelocity() const override
virtual void disable() override
void setVelocity(units::radians_per_second_t velocity) override
units::radian_t getPosition() const override
the master namespace of librmb
Definition LogitechGamepad.h:9
Definition SparkMaxVelocityController.h:70
Definition SparkMaxVelocityController.h:49
Definition SparkMaxVelocityController.h:18
Definition SparkMaxVelocityController.h:28
Definition SparkMaxVelocityController.h:35