Arm starting position reading problems with Falcons

Hi guys, I was beginning tuning our arm mechanism today and it’s driven by 2 Falcons (TalonFX motors of course) with 1:200 Ratio gearboxes. I’d like it’s starting position to be read -0.2 rotations on boot, however the RotorOffset in the config only allows an offset between -1 and 1 which results in only -0.005 to 0.005 in the offset of the arm position feedback. Any solutions to that?

final double ARM_GEAR_RATIO = 200;
final double ARM_READING_AT_BOOT = -0.2;

you can reset the arm position by executing this line:

armTalon.setPosition(ARM_GEAR_RATIO * ARM_READING_AT_BOOT)

BTW, because you are using relative encoders in the motor to sense the absolute position of an arm, it’s better to add a limit switch and execute the line every time the limit switch is pressed.
Remember not to call the line periodically because it is thread-blocking and waits for 50ms on default.
Good luck and see you in WRC! :grinning:

Just to clarify the answer above, setPosition() is a method in the TalonFXConfigurator class. I’m guessing that you happened across methods in the FeedbackConfig class, which is not the right place to be looking to set the starting position of the internal relative encoder on the Falcons.

1 Like

Thanks for the correction.
And I think you can simply call to the setPosition() method in the TalonFX class directly, which points to

    /**
     * Sets the mechanism position of the device in mechanism rotations.
     * 
     * @param newValue Value to set to. Units are in rotations.
     * @param timeoutSeconds Maximum time to wait up to in seconds.
     * @return StatusCode of the set command
     */
    public StatusCode setPosition(double newValue, double timeoutSeconds) {
        return getConfigurator().setPosition(newValue, timeoutSeconds);
    }

Not so much a correction, but just additional information. Your clarification of my post is also valuable. It is perfectly acceptable to call setPosition() on the TalonFX object as well as using the configurator.

1 Like

Thanks a lot! I’ll try this out later.
GL too! See you there in Beijing.

2 Likes

Is there a simple way to reset the relative encoder of a Falcon using Phoenix 6?

Invoke setPosition(0) on the FalconFX controller.