View Single Post
  #1   Spotlight this post!  
Unread 06-03-2014, 13:26
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Grabbing subsystem data to use in another subsystem in Command Based

Yes, you can access other subsystems to get information; depending on how strictly you want to adhere to the command based approach, this may be 'cheating' a little, but for read only access it doesn't do any harm.

The Robot class has static instances of all subsystems, so you can access them from anywhere that includes Robot.h (just as is done in commands).

The syntax is as follows:
Code:
bool ShooterPiston::Fire()
{
    bool returnValue = false;
    
    if ((Robot::shooterWheels->IsUpToSpeed() == true) &&
        (Robot::shooterArm->IsOnTarget() == true) &&
         ....
    {
        firingSolenoid->Set(DoubleSolenoid::kReverse);
        returnValue = true;
    }
    return returnValue;
}
Reply With Quote