Sorry – I was tight for time and a little terse, which may have come across as a bit harsh and judgmental. I’m still short for time, but here’s a longer answer…
I don’t recall you explicitly saying, but it seems we are talking about using Falcons here. I’ll assume this in order to hold down the number of variables and keep things at least a little more focused. I’ll try not to make unstated assumptions.
The 10,000 ft. description of the problem is you need to control two motors. In the context of diff swerve, the control function for each motor will need input from at least one external sensor, whether this is something like a CANcoder, or the other (CAN-connected) motor. If you are not doing the math on the motor controller, things are a little different, but let’s start here, since this seems to be what you are thinking.
If you are going to do the math on the motor controller, the motors will also need the desired module state (typically, position for the steering angle and power/velocity/position for driving the wheel). And, the motor controllers will have to expose some means of running the desired math. This last point is important, it’s not as if you can legally change the motor controller firmware – even if you chose to go there.
For the moment, let’s not worry about the latency or update frequency of the desired module state – as a simplifying assumption, we can just say this is known everywhere and then come back to this assumption later, as needed. At this point, the control for motor A is going to be a function of the sensor for motor A and the sensor for motor B (no absolute encoder). Or, it is going to be a function of an external/absolute steering angle sensor. In the latter case, it might also need the sensor for the local motor, depending on what kind of control is desired for driving the wheel.
Now that there’s a general outline, we can turn to response/latency in the control loop. With an absolute position sensor on the turn angle, the mechanical side of things is pretty optimal. When using the built-in motor encoders, there’s backlash. The resolution of these encoders also differs, so there’s going to be a different quantization error. And, you still have to get the sensor data from one motor to the other, across CAN (and not CANivore-rate CAN, based on info in this thread). The 1000Hz (1 ms) PID loop is starting to be suspect…
Importantly, it isn’t the frequency you really care about, it’s the latency. Sure, a higher frequency can help average and worst-case latency, but it doesn’t get around the CAN transfer (there are other sources of latency as well). Running a really fast control loop that has stale feedback data isn’t really where you want to be. And now, we come to the question of what math can the motor controller actually do with the two inputs (there’s no provision for working with three on the Talon FX, AFAIK).
I have no expertise with Talon FX and can’t even claim to have used one. There’s also the two-API (Pro) thing. But, the most recent thing I recall in this area is Auxiliary Closed Loop PID[1]. This does let you use two sensors to control a Falcon. The question then becomes: “Can Talon FX do the necessary math with the two sensors?” I don’t know the answer, and until the math is set out, it’s impossible to know. But, what can be done here is limited – you don’t get to run arbitrary math on the motor controller. Is this a problem? Maybe; it’s certainly a risk.
So this is what was behind my earlier comment on not being so quick to jump to running diff swerve control on the motor controllers. Let’s briefly turn to the alternative of running on the RIO. To start, one can get way more than 50Hz (20 ms) if needed/desired, you just have to do a little more work. I’m not going to go into this here, but it’s been done and written up on CD.
In this scenario, you can use something like an SRX Mag Encoder – no CAN from here to the RIO. The sensor data is processed by the FPGA, which is going to be very low latency. The RIO can do arbitrary math. And, the RIO can send CAN messages to the motors with good latency, with CAN accounting for the bulk of this. This does not seem like an option to write off and not consider so early in any analysis.
Don’t want to run the control on the RIO? Want an advanced project – or maybe something to request of a vendor? Run the control on a CAN-attached absolute encoder and have the two motors “follow” a pair of outputs it publishes. Send the module state info to the encoder, have it do the computations, and send the follower data. You can legally change firmware on a sensor, and the devices these use have firmware development toolchains you can download. At this point, you can do what you want. I actually think the RIO would be the thing to do right now, but this might be a cool offseason project for a team looking for a high ceiling for S/W, given the interest and people.
I hope this helps. I still think you do not want to rule out using an external absolute encoder, and I hope this explains why a little more clearly.