Why are SwerveModule status signals inaccessible in Phoenix6?

There’s a method in Phoenix 6’s swerve module class which returns status signals for odometry. Unfortunately it has a default access specifier, and hence can’t be used outside of it’s package. I’m not using SwerveDrivetrain for odometry, and want to access these signals myself, is there a way outside of reflection or other hacks to access this method? Is there a reason why I shouldn’t be able to?

You could invoke the public getModule method to get a reference to each SwerveModule and then invoke the public getDriveMotor and getSteerMotor methods to get references to the underlying TalonFX objects. From there, you can get whichever signal you want.

1 Like

What do you want to do with the signals? The telemetry callback gives quite a bit of information.

I want to access the signals used in the SwerveModule class, to set their update rate as well as mass refresh them, as opposed to calling getPosition(true) on each module individually. It honestly barely matters, but there’s also no real reason why the API shouldn’t let you do that. I’m not using SwerveDrivetrain, but instead writing my own, and SwerveDrivetrain has access to the signals, while general robot code doesn’t.

While I’m not sure why you don’t want to use SwerveDrivetrain, an option to consider is to extend SwerveDrivetrain instead of writing a class completely from scratch.

If you are using a CANivore, the library does automatically set the update frequency to 250Hz, and it’s not configurable, yes. If you are not using a CANivore, the frequency is configurable.

if (OdometryUpdateFrequency == 0) {
    UpdateFrequency = IsOnCANFD ? 250 : 100;
} else {
    UpdateFrequency = OdometryUpdateFrequency;
}

The signals are refreshed all together by the library. You don’t have to do anything.

if (IsOnCANFD) {
    status = BaseStatusSignal.waitForAll(2.0 / UpdateFrequency, m_allSignals);
} else {
    /* Wait for the signals to update */
    Timer.delay(1.0 / UpdateFrequency);
    status = BaseStatusSignal.refreshAll(m_allSignals);
}

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.