Our team is looking to use PID with one of our talons, and from what we’ve researched Motion Magic is the simplest option. Our problem is that we don’t seem to know exactly how to use the motion magic capabilities of the SRX. We tried out the following code but to no avail.
#some thing to run the motor
self.talon.set(self.talon.ControlMode.MotionMagicArc, ctre.wpi_talonsrx.MotionMagicArc.PercentOutput, 1)
This obviously doesn’t work, but does anybody here have experience using motion magic with the CAN TalonSRX? What worked for you?
Unfortunately, I’ve not used Motion Magic myself personally, but in theory the Python API should be really close to the Java API (and if it’s not, please file a bug on github highlighting the discrepancy!).
“Not working” is a very large class of things. Please expand on the behavior you’re seeing and your expected behavior.
However I see a few problems right away.
You should be passing one of FeedbackDevice depending on what sensor you’re using into configSelectedFeedbackSensor.
What do you expect to happen by feeding the current position of the sensor into configMotionAcceleration and configMotionCruiseVelocity? You should be giving these methods numbers related to the physical properties of your robot, not the current position of its wheels.
talon.set() takes a ControlMode (which you should be using MotionMagic, not MotionMagicArc probably) and a demand, which for MotionMagic is the distance you want to travel.
If you’re interested, we used motion magic last year. Our code uses the old API, with different methods and units, but you may be able to get a general sense of what needs to happen. Please do not just copy this code, as it plain does not work any more.
Other than that I highly recommend reading the documentation as Dustin suggested. Read through the Motion Magic section of the Software Reference Manual, then check out the examples.