Sequential Commands Not Working When One Includes Setting a Solenoid Valve State

We are trying to do several commands in a row using a sequential command. When we do several commands sequentially that involve moving a motor using PID position control, the sequence works. When we add a command at the end to set a solenoid valve to kReverse (release grip on game piece), then the first command (which is a PID position control commands) initializes, begins execute, but then gets interrupted (goes to “end”) before isFinished is reached. Nothing moves and none of the other commands get executed.

We are tying this command to a button “whileTrue”. I believe we have also tried it by linking the sequential command to the Autonomous command, and it also didn’t work. We will try “onTrue” today in case there is some issue with setting a solenoid state with “whileTrue”.

Any ideas???

Providing the relevant code will make it wildly easier for others to help you. Seems possible the commands don’t set requirements appropriately, but it’s impossible to do anything but guess without the code. :man_shrugging:

1 Like

Need to see your code to help. However you said:

What I’m hearing is that if the sequence is:
1 - Do stuff
2 - Do stuff
3 - Do stuff

Then the sequence executes properly. If the sequence is:
1 - Do stuff
2 - Do stuff
3 - Do stuff
4 - Release Solenoid

Then 1 gets interrupted before completion and the whole sequence is canceled.

As stated, need to see your code to help you for sure but my psychic debugger tells me that you have a separate command (let’s call it Command B that is requiring the subsystem that owns the Solenoid object. Command B is getting scheduled, and is interrupting all other commands that use that subsystem.

Given this is a sequential command group, a sequential command group requires ALL the subsystems that are in the sequence. So if Command B does indeed require the subsystem, and it gets scheduled to run while the sequence is running, then it will interrupt the sequential command group.

To troubleshoot this easily, use SmartDashboard to put all your subsystems to be visible. The SmartDashboard object will show you the command scheduler for the given subsystem.

SmartDashboard.putData("Drive Subsystem", m_drivetrain);

Only do one of those method calls per subsystem so you can better debug your problem.

1 Like

The code is posted here:

For example, the Commands under Scoring Positions, such as ScoreMiddlePosition use sequential commands 1, 2, 3 (PivotPID, ArmPID, GrabReleaseToggle) or we also try (PivotPID, ArmPID, ReleasePiece). These commands are in the Arm and Gripper subsystems.

If we comment out the third command (which uses the Gripper solenoid), then it works. After taking out the Gripper command, we can add additional PID commands and they work also. But once we include the GrabReleaseToggle (or ReleasePiece) Gripper command, then the first command ends (gets interrupted - never gets to finish), and nothing moves.

I read a Chief Delphi blog from a while ago where someone said they had a similar issue, and they found out it was code which had contradictory logic for the solenoid state.

Also, if we run this sequential command with JUST the Gripper command, it works on its own.

Did this work out for you using on true? My theory is yes it should work.

Sadly, no. It didn’t work when called in Autonomous either. Have spent several days trying to fix this to no avail.

As mentioned, this type of sequence could be interrupted in case the 4th “Release Solenoid” ends up requiring some subsystem and that subsystem is then required by another command while your sequence is running:

To test this case, you could wrap the 4th command into new ProxyCommand(that_original_release_solenoid_command).
The ProxyCommand will not require its embedded command. Not saying that’s the solution, but could be useful to test if your issue is based on concurrent requirements for the same subsystem.

The proxy command worked!!! (adding: .asProxy after the solenoid command).

Thank you!!!

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