Id like to control the target speed of the TalonSRX motors (speed perhaps in ticks/cycle?) But I’m not sure if this is possible or where to look, I’ve heard of motion magic but it’s my understanding that generates a trapezoidal PID loop? I’m looking only to set the target speed for a motor and continue at that speed until updated or told otherwise any ideas? Thanks!
There are several control modes, but most fall into one of two categories, “open-loop” and “closed-loop”. Open-loop takes input and drives the motor simply with this input. You could illustrate this on a piece of paper with a box in the middle, an arrow pointing into it representing the input(i.e. an activation percentage), and an arrow pointing out of it representing the output(i.e. the output voltage). The alternative to this is “closed-loop”; Closed-loop acts like open-loop, but it has an extra step, on the output, there is also a feedback device which can be illustrated in our example as another box on the output and that feeds back into the input. This is called closed-loop because when illustrated in this manner, the arrows make a complete loop. The following are examples of closed-loop control modes:
Position Closed-Loop Control Mode
Velocity Closed-Loop Control Mode
Current Closed-Loop Control Mode
Motion Profile Arc Control Mode
Motion Profile Control Mode
Motion Magic Control Mode
There is only one open-loop control mode which is PercentOutput and ranges from -1 to 1, 1 being full power forward and -1 being full power in reverse. For your application, I would recommend closed-loop velocity control since it seems as though you want to control the real-world speed of your motors. Open-loop is used in situations where you do not need feedback, such as in intakes. I do not know what you mean by
But I would suggest that you read up on the CTRE Docs, they just started using Read the Docs recently and I’m personally a huge fan, I also love the transition that WPILib made from ScreenSteps but that’s another topic. It’s a lot of reading, but in my opinion, it’s pretty darn good documentation and they usually provide some pretty solid examples. You can read up on PID(I believe?) and Closed Loop control here. You will, of course, need an encoder if you go the closed-loop route, so you need to know how to configure that. All of the main closed-loop control modes attempt to make the error between the goal(setpoint) and real-world value using PID which is a mechanism that takes the difference between the goal and real-world value(error) and uses a bit of math to compensate. Motion magic adds on to this and is a way of saying, “I want you to go here” but it also uses physical parameters you set such as “I want you to go no faster than this speed” or “I want you to not accelerate faster this acceleration”. Again, check the docs for more detail.
I’ve actually used PID a lot but never in software before, its always been with physical components on boards, storing your I value in a cap, Ill read up on the docs and thank you I knew there was a mode out there for what I needed! I was only struggling with syntax.
And sorry about the “trapizoid” confusion, just the way the acceleration looks if you graph it, with the servo hitting a max movement speed and coming back at the end.