Best way to zero out the Target of Talon SRX when disabling robot

This is our first year using Talon SRX motor controllers so we are having some problems figuring out some of the nuances of how to use them safely. We are programming in Java. What we are currently struggling with is trying to figure out how to zero out the PID target when we disable the robot so that when we re-enable the robot, the talon doesn’t try to go to the last PID. We’ve tried setting the target to 0 in both TelelopInit and DisableInit, but Talon still seems to retain the old set point. When we re-enable, the talon initially tries to go to old setpoint and then it gets the hint and goes to 0. I’m sure that we are missing an obvious solution to this problem, and we’d appreciate it if some could point it out to us.

Thanks for your time.

Kevin

Could you post your code? We usually zero everything in our robotInit() when we boot our robot.

We have stuff in RobotInit() and that part is working fine when the robot is powered up for the first time. The problem is coming from when we are doing are testing. We disable and enable the robot a lot, which doesn’t call robotInit(), just teleopeInit() to my understanding. Sorry, don’t have access to my code right now.

Kevin

This suggests there is delay between enabling the robot, and your software where you update your actuators. Additionally it is not clear if "setting the target to 0 " literally means you are telling the Talons to closed-loop to position 0 or if you mean neutral motor output.

A minimum solution is to set all Talons neutral output with:

 _myTalon.set(ControlMode.PercentOutput, 0);

so that they do not closed-loop on enable until you tell them to.

If the cause is a noticeable delay between enable and your first teleop-update, that would be worth root-causing. Check the DS error log for any clues.

My reference to “setting target to 0” meant that we were calling _myTalon.set(ControlMode.MotionMagic, 0) during the disableInit() method in robot. We used Tuner and verified that the talon still had a non-zero target after the bot was disabled. We had put in the _myTalon.set( ControlMode.PercentOutput, 0) right afterwards and that seemed to solve the issue since the talon wasn’t in motionmagic mode when the bot was disabled/re-enabled. I just wasn’t sure if that was the best way to do it or not. Would you expect us to be able to put that in teleopInit() instead and have it effective fast enough for the talon not to try and move if we didn’t do the PercentOutput, 0 call in the disableInit() method?

I agree that it just seems like there is a delay between enabling the robot and enabling of the actuators. I don’t recall seeing any warning signs on the driverstation but I’ll be sure to check tonight. We’d just like to know what the best practices are for dealing with Talons when disabling and enabling the robot without restarting the robot code.

Thanks,

Kevin

If you want to ensure that the motor does not move on enable, and we assume that it has gone to some arbitrary position during disable, you would have to read the current position as you enable, and use this as the initial setpoint. Enabling closed-loop with a setpoint other than the current position will cause motion.

If I’m reading your descripton properly, you’re saying there’s no issues on initial power on. This could be explained by the fact that most encoder logic will assume it’s at “0” at power-on. Setting 0 as the first setpoint in this case would cause no motion.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.