REVrobotics / SPARK-MAX-Examples

Example code for SPARK MAX
BSD 3-Clause "New" or "Revised" License
103 stars 105 forks source link

Incorrect setting in SmartMotion example. #5

Open tekdemo opened 5 years ago

tekdemo commented 5 years ago

The SmartMotion example incorrectly uses the kVelocity control option, instead of kSmartVelocity. This makes the example pretty confusing as selecting Velocity causes the PID control to disable smart motion entirely.

https://github.com/REVrobotics/SPARK-MAX-Examples/blob/b56d301c5291dcd0b22f6b46eb44e1dced850abb/Java/Smart%20Motion%20Example/src/main/java/frc/robot/Robot.java#L171

willtoth commented 5 years ago

Thanks for the feedback. The intent for that particular example is to allow you to switch between a velocity PID controller and the Smart Motion mode based on a control on the smart dashboard. This allows you to tune the velocity PID which is the underlying controller for the Smart Motion.

So one tuning method would be:

  1. Set the 'mode' control to true set velocity PID as the control mode
  2. Tune the mechanism using the velocity PID controller
  3. Configure the min output, max velocity, and max acceleration
  4. Switch to Smart Motion and control the position
tekdemo commented 5 years ago

That makes sense. I think a note in the code, or ability to select the SmartVelocity would help clarify this. It confused the heck out of our team, and took me a while to catch on our bench. We pulled this example to test SmartVelocity on a non-positional system, and didn't think about that application.

Would you accept a PR to use a Smart dashboard Chooser to switch between the 3 modes? That would help with clarity, while still working with your intended use case. Should take just a few minutes to cook up, but no idea about your test frameworks.

On Sun, Mar 10, 2019, 19:27 William Toth notifications@github.com wrote:

Thanks for the feedback. The intent for that particular example is to allow you to switch between a velocity PID controller and the Smart Motion mode based on a control on the smart dashboard. This allows you to tune the velocity PID which is the underlying controller for the Smart Motion.

So one tuning method would be:

  1. Set the 'mode' control to true set velocity PID as the control mode
  2. Tune the mechanism using the velocity PID controller
  3. Configure the min output, max velocity, and max acceleration
  4. Switch to Smart Motion and control the position

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/REVrobotics/SPARK-MAX-Examples/issues/5#issuecomment-471383779, or mute the thread https://github.com/notifications/unsubscribe-auth/AAgJbbZTWQ9570n6uBV7f4KIlA1u_nZPks5vVb8igaJpZM4bnrMo .

willtoth commented 5 years ago

You can go ahead and change this PR to switch between the 3 modes, that would be helpful!