• aditya mehrotra.

dino/control updates: getting new interfaces between the jetson and the rio [updates]

So this morning we were looking through the RobotPy documentation: https://robotpy.readthedocs.io/projects/rev/en/stable/rev/CANSparkMax.html (it's similar to the Java documentation but much easier to read). We've also been looking at the software examples and here's a few more things...

https://github.com/REVrobotics/SPARK-MAX-Examples/blob/master/Java/Bus%20Measurements/src/main/java/frc/robot/Robot.java (measuring outputs).

The above shows only one new option as to how to get the "output" from the motor which is getAppliedOutput().

These both seem like what we want, but we'll try logging both the current and the duty cycle and see what happens (we'll try checking our code to make sure the graphs last time were actually current).

This is another good piece of code to look at if we want the motor to be able to "servo" to a location at a certain speed as opposed to just relying on the saturated PID position controller. (https://github.com/REVrobotics/SPARK-MAX-Examples/blob/master/Java/Smart%20Motion%20Example/src/main/java/frc/robot/Robot.java)

The other thing to maybe consider is dropping the system all down to 12V instead of the 18V we are running at just to see how well this works at 12V (if the voltage is messing it up). The controller was designed to work at 12V and maybe it's expecting 12V and since we're giving it 18V it's not doing as well on the control side? Let's check the docs. --> conclusion is it really shouldn't matter since there's a current sensor.

Some other things to try:

  • Seems in the control loop above, what is applied to the motor is a duty cycle (not super sure what this means but I think this is equivalent to the 0-100 PWM duty cycle that is set in PWM mode.

  • Curious if we somehow find a way to determine the sign of the current, the magnitude seems somewhat accurate, and the question is do we really need to know anything but the magnitude of the torque based on the current for now for testing?

Re-looking at this graph from yesterday...

It seems like our control signal is not matching the estimated control signal super well. There are random spikes in the current but the current command does not smoothly track the position command. So here's another next step.

  • Plot the applied output duty cycle as well to see if that control command makes more sense then the current command. They may be doing everything in terms of something called duty cycle who knows.

  • Note that m1_current is the APPLIED CURRENT BY THE CONTROLLER (so think of this as the control signal to the motor).

  • It's possible many of the issues from yesterday will go away with basic PID tuning.

Here's some new Pseudo-code to implement at a later date.

Also kept digging through documentation and here are all the possible control modes for the SparkMAX.

Also note this control types ENUM shows a duty cycle control type? Maybe we can relate torque directly to duty cycle or something similar to that, maybe duty cycle will be more indicative to control effort for this controller, let's tune the controller a little more and try both (instead of calculating at tau, send back the duty cycle value). Also curious to see if this will be both +/- values. For position hold (like in the graph above), the current should be OPPOSITE sign in position as the position was a disturbance that was inputted to the controller.

Anyyyywayssss seems we will need to play A LOT more before we can consider much else here. Smartmotion may be the way to go for Smooth motions incase the RIO control loop is not fast enough but we will find out - that's what the dyno is for!

#updates #omgrobots #yay

3 views0 comments
© copyright 2019 | aditya mehrotra