Talon SRXs with Simple Trajectory

Is there an example of how to use Talon SRXs (with the SRX magnetic encoders) with a timed-robot structure for trajectories? I cannot seem to find any, and the program I have starts to follow a simple trajectory then drives forward quickly in the middle of the trajectory. Are there any resources for using these systems together?

Have you looked at the https://github.com/CrossTheRoadElec/Phoenix-Examples-Languages

Thank you for sending these! I cannot seem to find anything relating specifically to trajectories in autonomous, it seems that the closest thing would be the arc following example. Are there any resources specific to autonomous trajectories, or should I try using the logic behind arc following for the trajectory?

I am not sure if there is a good way to use the WPILib trajectory stuff if you aren’t using command based

1 Like

You can; you just have to essentially re-implement the bodies of a few of the commands (which you may want to do anyway, even if you’re using command-based, as the prebuilt ones with the large functional argument lists are brittle).

You do have to understand how the thing works, though. It’s a bit late in the season to be starting on trajectory-following from scratch…


The examples provided by CTR have two main ways to do it - MotionMagic and MotionProfile

MotionMagic allows you to quickly run a trapezoid profile on the encoder up to the value you specify when you enable it. You need to enable it ONCE; no need to re-set the value in a middle, unless you need to change the trajectory.

With two sides you will need to set the values for the left and right sides of the robot separately. You only need to do so for master controllers. The followers will follow as needed.
Note that Motionmagic is useful for one movement (e.g. drive straight, or turn, or do something else).

The main advantage of MotionMagic - it’s set-it-and-forget-it - you just need to watch in RIO when it’s done (the ClosedLoop will not just cancel itself, you know). In addition, you do not need to worry about “Pose” etc. It is simply driven my encoder values.

The MotionProfile, on the other hand, is a way to drive trajectories. There is a way to generate them, though in my opinion not nearly as easy as using PathWeaver. But there you feed complex path to the talons and they will do something similar to MotionMagic for the trajectory.

Personally, if you need this for autonomous, and you need to do it quickly, I’d stay with simple MotionMagic. It’s easy to do, and works fine. It will also offload your CAN and RIO, since the PID and closed loop will run on the talon itself.

And as others mentioned, you really need to understand PID and characterization basics before you start working on all this.

We did both MotionMagic and Kinematic driving with our robots. Kinematic driving requires much more code, work on generation trajectories, and more prone to mistakes, though you can do much fancier things with it.

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