Log in

View Full Version : Parallel commands that depend on the same subsystem?


AutoBotAM
31-01-2014, 20:27
How would the two commands be ran in this situation? Either by running them in parallel in a command group, or if both commands were default commands of different subsystems.

I know that if one command is run that depends on a subsystem that another running command depends on, either of the commands are terminated depending on the circumstances. Is there a way to get two commands to literally run in parallel, accessing the same subsystem? So if commands A and B depend on subsystem C, the scheduler will execute A, then B, A, B, and so on.

Is there a way to get that working?

EDIT:

If there is not, I'll explain my design further. In this case command A would only read information from subsystem C. It would only use accessor methods and no mutator methods. So would it be safe to just omit the "requires" call?

Joe Ross
31-01-2014, 21:43
If there is not, I'll explain my design further. In this case command A would only read information from subsystem C. It would only use accessor methods and no mutator methods. So would it be safe to just omit the "requires" call?

Command A does not require exclusive access to Subsystem, so you should not use the requires call.

AutoBotAM
31-01-2014, 22:17
Command A does not require exclusive access to Subsystem, so you should not use the requires call.

So there isn't a way to do the former. Otherwise answers my question, thanks!

BigJ
01-02-2014, 00:33
If A and B both "require" C in your case, either you are trying to control the same physical parts of the robot (motor controllers, solenoids, etc) with 2 commands (bad and can have unexpected results), or your subsystem has 2 different (sets of) physical parts that the commands are controlling (in which case you should refactor said subsystem into 2 subsystems).