Setting Double acting solenoid at Enable

Trying to get a double acting solenoid to set to kReverse when we enable the robot in Teleop.

We put the method for opening the hooks (setting it to reverse) in TeleopInt(). It works great the first time we enable the robot, but if close the hooks then disable the robot and reenable the robot without power cycling or changing the code it reverts back to its last state not the state we necessarily want it on.

public void teleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand != null) {

In our Climber subsystem…

public void openHook(){

We also set it to reverse in the constructor of the climber subsystem, but I believe that only runs upon boot up of the rio. We have also tried adding this in robotInt() which also I believe only runs upon boot up of the rio.

1 Like

Is your full code posted somewhere like github? Maybe you’ve got some other command or something running that is setting the kForward that you’re not noticing.

I can put it up tonight. The only other place that we have it putting the solenoid in forward is in periodic if 2 limit switches are pressed so the hooks close automatically when we hit the bar. I will have them upload the newest version of code to GitHub when they get in tonight

The spot you added it in teleopInit() is also inside this conditional. If you put it in teleopInit() but outside this if statement it will do what you want.

1 Like

Thanks much for this. Missed the bracket to put it in. Students report it is working!

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