TalonFX following another TalonFX?

Now that I’ve gotten Intellisense to behave with the assistance of this thread, I can ask my actual question:

This is our first year attempting to use CAN to communicate with any motor controller. We’ve been learning how to do the basics with a Talon SRX starting last fall, with success, but now that we’ve got Falcon 500’s in hand, we’re running into a bit of a roadblock. Hopefully, someone can help us find a solution.

We would like to use 2 Falcon 500’s in our shooter (a common setup, I’m guessing). One will run in Closed Loop Velocity mode. The other will be belted to the same driving mechanism - we simply want the 2nd Falcon to follow the master TalonFX doing its PID thing.

  1. Is it possible for a TalonFX to be a master to a follower? I’ve read documentation that a TalonFX can BE a follower, but I’m not sure I’ve seen where it can be FOLLOWED.
    Intellisense makes me wonder - see screenshot…


  1. If this is not possible (sad face), is there a bit of code we can execute to simulate motor following in a straightforward manner? Such as read the calculated output from the master and then set the slave to the same?

Many thanks in advance.

1 Like

Not familiar with C++, so looking at the Java documentation (the libraries are functionally equivalent, I think:

Source: https://www.ctr-electronics.com/downloads/api/java/html/classcom_1_1ctre_1_1phoenix_1_1motorcontrol_1_1can_1_1_base_motor_controller.html#ad4f61f2782b6048c7f905bbf38b066ac

The follow method takes anything which implements IMotorController, which all CTRE CAN-based motor controllers implement. That includes the Talon FX, Talon SRX, and Victor SPX. In fact, the follow method is inherited from the BaseMotorController class which is extended by all three of those classes.

TL;DR: you should be able to both follow a Talon FX and have a Talon FX follow other CTRE motor controllers.

That follow command can also be used for Talon FX’s (the motor controller built into the falcon) the exact same way as it was used with Talon SRX’s. It appears that CTRE just didn’t update the details of the command to include “Talon FX” in it, but functionally it is the exact same thing.

OK - I’m trying to use the Follow method per the docs I could find and am getting errors. I do believe every line of code we’ve written related to the Falcons has compiled just fine except for the “Follow” line. I posted a full readout of compiler barf below. The middle line below is what is causing trouble:

>     shootertop->SetInverted(false);
>     shooterbottom->Follow(shootertop);
>     shooterbottom->SetInverted(InvertType::OpposeMaster);

I think the gist of the errors centers on the following -

no known conversion for argument 1 from ‘ctre::phoenix::motorcontrol::can::TalonFX*’ to ‘ctre::phoenix::motorcontrol::IMotorController&’

It seems I am in the ballpark but grounding out to first. Any thoughts?

Ah, it’s expecting a reference not a pointer. Dereference shootertop while passing it to follow.

Like the following


1 Like

That works. Thank you.

I had to Google what you meant (I didn’t see you post the code). I was somewhat certain, but programming terminology has always escaped me. As I always say, I’ve never taken a dedicated C++ programming class in my life (and they do not teach anything similar at our school). It’s amazing we’ve managed to accomplish anything constructive (and haven’t killed anyone) since I’ve been around as the only programming “mentor”.

Thanks again for the assist.

If you aren’t too deep into this year’s codebase yet, you might find Java a lot easier than C++.