Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand on discussion of Units in SysId #2974

Open
DeltaDizzy opened this issue Feb 7, 2025 · 1 comment
Open

Expand on discussion of Units in SysId #2974

DeltaDizzy opened this issue Feb 7, 2025 · 1 comment

Comments

@DeltaDizzy
Copy link
Contributor

The unit dropdown is only for labeling the gains, and units should align with the units that the sensor/controller in the robot code uses.

@thenetworkgrinch
Copy link
Contributor

thenetworkgrinch commented Feb 7, 2025

Example that would generate only relevant Feedforward but invalid Feedback constants

SysIdRoutine


private final SysIdRoutine      m_sysIdRoutine   =
      new SysIdRoutine(
          // Empty config defaults to 1 volt/second ramp rate and 7 volt step voltage.
          new SysIdRoutine.Config(Volts.per(Second).of(ElevatorConstants.kElevatorRampRate),
                                  Volts.of(9),
                                  Seconds.of(10)),
          new SysIdRoutine.Mechanism(
              // Tell SysId how to plumb the driving voltage to the motor(s).
              m_motor::setVoltage,
              // Tell SysId how to record a frame of data for each motor on the mechanism being
              // characterized.
              log -> {
                // Record a frame for the shooter motor.
                log.motor("elevator")
                   .voltage(
                       m_appliedVoltage.mut_replace(
                           m_motor.getAppliedOutput() * RobotController.getBatteryVoltage(), Volts))
                   .linearPosition(m_distance.mut_replace(getHeight()))
                   .linearVelocity(m_velocity.mut_replace(getVelocity()));
              },
              this));
// getHeight() returns Meters
// getVelocity() returns Meters Per Minute

Controller setpoint for Spark

m_controller.setReference(Elevator.convertDistanceToSensorUnits(Meters.of(goal)).in(Rotations), // Problem here
                              ControlType.kMAXMotionPositionControl,
                              ClosedLoopSlot.kSlot0,
                              m_feedforward.calculate(getVelocity().in(Meters.per(Minute))));
// getVelocity() returns the MetersPerMinute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants