Multiple commands in a parallel group cannotrequire the same subsystems

We are trying to read a sensor that is in a different subsystem and we are having problems, basically, we need the intake to stop once the feeder sensor detects a ball && the intake sensor detects a ball.

Intake ball command

Index first ball command

The parallel command that requires the same subsystem twice

Should we have a global variable that is updated when there is a ball in the feeder so we don’t need to require the same subsystem in the parallel command twice? We also found this, but we are not sure what we should do:

Additionally, requirements are enforced within all three types of parallel groups - a parallel group may not contain multiple commands that require the same subsystem.

Some advanced users may find this overly-restrictive - for said users, the library offers a ScheduleCommand class that can be used to independently “branch off” from command groups to provide finer granularity in requirement management.

By the way, when we remove the m_feeder.sense_ball() from the IntakeBall.java it works, but the intake stops once it intakes the first ball.

Thanks in advance1

You can reference a subsystem in a command without requiring it. Just don’t require it in the command that doesn’t physically move that mechanism (although nothing is preventing you from doing that either).

3 Likes

I would think you could also call that method of getting the sensor with a lambda call??? Or use periodic to constantly update a public variable that you access?

This maybe off base but what where I would first try to go myself

Your best option is to setup your commands to take the external data as a Lambda. I go into some detail with a near identical issue in this other thread:

2 Likes

It’s hard to know exactly what you’re trying to do here without knowing what you’re robot design is, but it sounds to me like you want to intake a ball with a command, advance that ball to a location in the robot that the sensor will detect, and then intake a second ball, to a location that a different sensor will detect.

Those are roughly sequential steps as I’m understanding you, so you may relieve yourself of the headache with WaitUntil.

Then your command sequene could be:

  1. IntakeBall
  2. WaitUntil.andThen(new IntakeSecondBall)

Or something like that.