|
Re: Grabbing subsystem data to use in another subsystem in Command Based
Keeping with the intent of the Command Based programming approach the only way to accomplish what you are asking is in commands. All commands inherit CommandBase and CommandBase contains static instances of each subsystem. In your command you could get the value of a sensor from your sensor subsystem and then based on it's value call different methods in your collector subsystem. This year we had a DistanceSensor subsystem. It essentially provided the distance we were from the goal in feet via a getDistance method. Our shooter had a setDistance method. In a command called AutoSetShooter we did the following. shooter->setDistance(distanceSensor->getDistance());
Depending on the application it might be better to restructure your subsystems so that the corresponding sensors for your collector are in your collector subsystem. The best example of this is limit switches and pots. They belong in the same subsystem that the actuator is in.
Kyle
__________________
"May the coms be with you"
Is this a "programming error" or a "programmer error"?
|