5#include <units/angle.h>
6#include <units/angular_acceleration.h>
7#include <units/angular_velocity.h>
8#include <units/current.h>
10#include <rev/CANSparkMax.h>
12#include "rmb/motorcontrol/AngularPositionController.h"
13#include "rmb/motorcontrol/feedforward/SimpleFeedforward.h"
17namespace SparkMaxPositionControllerHelper {
20 rev::CANSparkMax::MotorType motorType =
21 rev::CANSparkMax::MotorType::kBrushless;
22 bool inverted =
false;
24 units::ampere_t currentLimit = 40.0_A;
28 double p = 0.0, i = 0.0, d = 0.0, ff = 0.0;
29 units::turn_t tolerance = 0.0_rad;
30 double iZone = 0.0, iMaxAccumulator = 0.0;
31 double maxOutput = 1.0, minOutput = -1.0;
35 units::radian_t minPosition =
36 -std::numeric_limits<units::radian_t>::infinity();
37 units::radian_t maxPosition =
38 std::numeric_limits<units::radian_t>::infinity();
39 bool isContinuous =
false;
43 bool useSmartMotion =
false;
44 units::radians_per_second_t maxVelocity = 0.0_rad_per_s,
45 minVelocity = 0.0_rad_per_s;
46 units::radians_per_second_squared_t maxAcceleration = 0.0_rad_per_s_sq;
47 rev::SparkMaxPIDController::AccelStrategy accelStrategy =
48 rev::SparkMaxPIDController::AccelStrategy::kTrapezoidal;
51enum EncoderType { HallSensor, Quadrature, Alternate, Absolute };
52enum LimitSwitchConfig { Disabled, NormalyOpen, NormalyClosed };
55 double gearRatio = 1.0;
56 EncoderType encoderType = HallSensor;
58 LimitSwitchConfig forwardSwitch = Disabled, reverseSwitch = Disabled;
72 using EncoderType = SparkMaxPositionControllerHelper::EncoderType;
73 using LimitSwitchConfig = SparkMaxPositionControllerHelper::LimitSwitchConfig;
79 const std::shared_ptr<Feedforward<units::radians>> feedforward =
80 std::make_shared<SimpleFeedforward<units::radians>>();
81 const Range range = {};
84 std::initializer_list<const MotorConfig> followers;
181 rev::CANSparkMax sparkMax;
182 std::vector<std::unique_ptr<rev::CANSparkMax>> followers;
183 rev::CANSparkMax::ControlType controlType;
185 rev::SparkMaxPIDController pidController;
186 units::radian_t targetPosition;
187 units::radian_t tolerance;
189 const std::shared_ptr<Feedforward<units::radians>> feedforward;
191 units::radian_t minPose;
192 units::radian_t maxPose;
194 std::unique_ptr<rev::MotorFeedbackSensor> encoder;
195 EncoderType encoderType;
Definition AngularPositionController.h:19
Definition SparkMaxPositionController.h:66
units::radians_per_second_t getVelocity() const override
units::radian_t getMinPosition() const override
units::radian_t getTolerance() const override
void setPosition(units::radian_t position) override
units::radian_t getMaxPosition() const override
virtual void setPower(double power) override
units::radian_t getTargetPosition() const override
units::radian_t getPosition() const override
virtual double getPower() const override
void setEncoderPosition(units::radian_t position=0_rad) override
the master namespace of librmb
Definition LogitechGamepad.h:9
Definition SparkMaxPositionController.h:76
Definition SparkMaxPositionController.h:54
Definition SparkMaxPositionController.h:18
Definition SparkMaxPositionController.h:27
Definition SparkMaxPositionController.h:42
Definition SparkMaxPositionController.h:34