Does anyone have examples of using the output current on a motor to detect whether an intake successfully taken in a cone or cube? We’ve done some testing in the lab and think we may have a few methods to monitor the output current and scrub the signal for noise to determine whether we’ve successfully taken in an object in our intake, but I’m curious if other teams have used this method before and if there any gotcha’s we should watch out for.
I’m aware that an IR sensor is probably the best way to do object detection. We have a few IR sensors, but they are bigger and slightly bulkier than we would want in our intake, and so am thinking a little outside of the box.
My students are doing exactly what you described, mainly using the SparkMax getOutputCurrent method and checking if the current has passed a certain threshold. I’m not entirely sure what the Talon/Victor equivalent would be. It will depend on your design, but the only real issue we ran into was having the threshold set too low and getting some false positives that made our grip weaker than we would have liked.
Here’s a command based implementation that’s worked well for us.
We read the output current from the spark max and feed it through a moving average filter (this probably isn’t needed) and then through a 1s debouncer to ensure we don’t get false positives from intake startup or other momentary loads.
I can confirm that Ryan’s code works great, but we found that the time for the debouncer to detect a gamepiece was a little excessive, we use .33s and detect for 7 Amps.