Skip to content

Commit

Permalink
Add comment on configuring gear ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
bhall-ctre committed Jun 6, 2024
1 parent c10ee98 commit b732e2d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions cpp/MotionMagic/src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ void Robot::SimulationPeriodic() {
void Robot::RobotInit() {
configs::TalonFXConfiguration cfg{};

/* Configure gear ratio */
configs::FeedbackConfigs &fdb = cfg.Feedback;
fdb.SensorToMechanismRatio = 12.8;
fdb.SensorToMechanismRatio = 12.8; // 12.8 rotor rotations per mechanism rotation

/* Configure Motion Magic */
configs::MotionMagicConfigs &mm = cfg.MotionMagic;
mm.MotionMagicCruiseVelocity = 5; // 5 rotations per second cruise
mm.MotionMagicCruiseVelocity = 5; // 5 (mechanism) rotations per second cruise
mm.MotionMagicAcceleration = 10; // Take approximately 0.5 seconds to reach max vel
// Take approximately 0.1 seconds to reach max accel
mm.MotionMagicJerk = 100;
Expand Down
5 changes: 3 additions & 2 deletions java/MotionMagic/src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ public void simulationPeriodic() {
public void robotInit() {
TalonFXConfiguration cfg = new TalonFXConfiguration();

/* Configure gear ratio */
FeedbackConfigs fdb = cfg.Feedback;
fdb.SensorToMechanismRatio = 12.8;
fdb.SensorToMechanismRatio = 12.8; // 12.8 rotor rotations per mechanism rotation

/* Configure Motion Magic */
MotionMagicConfigs mm = cfg.MotionMagic;
mm.MotionMagicCruiseVelocity = 5; // 5 rotations per second cruise
mm.MotionMagicCruiseVelocity = 5; // 5 (mechanism) rotations per second cruise
mm.MotionMagicAcceleration = 10; // Take approximately 0.5 seconds to reach max vel
// Take approximately 0.1 seconds to reach max accel
mm.MotionMagicJerk = 100;
Expand Down
5 changes: 3 additions & 2 deletions python/MotionMagic/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ def robotInit(self):

cfg = configs.TalonFXConfiguration()

# Configure gear ratio
fdb = cfg.feedback
fdb.sensor_to_mechanism_ratio = 12.8
fdb.sensor_to_mechanism_ratio = 12.8 # 12.8 rotor rotations per mechanism rotation

# Configure Motion Magic
mm = cfg.motion_magic
mm.motion_magic_cruise_velocity = 5 # 5 rotations per second cruise
mm.motion_magic_cruise_velocity = 5 # 5 (mechanism) rotations per second cruise
mm.motion_magic_acceleration = 10 # Take approximately 0.5 seconds to reach max vel
# Take apprximately 0.1 seconds to reach max accel
mm.motion_magic_jerk = 100
Expand Down

0 comments on commit b732e2d

Please sign in to comment.