Go to Post According to a 6 year old I once met at a demo, our FRC machine was not a robot because, "How can it be a robot if it doesn't have a face?" - Jared Russell [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 12-03-2014, 14:08
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Grabbing subsystem data to use in another subsystem in Command Based

Quote:
Originally Posted by kylelanman View Post
All commands inherit CommandBase and CommandBase contains static instances of each subsystem.
Quote:
Originally Posted by DjScribbles View Post
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).
In case anyone is confused, both Kyle and Joe are correct, depending on how you started your project. Currently, if you build your build your project with the Windriver plugins, you get a CommandBase that contains all subsystems. If you use RobotBuilder, the Robot class contains all subsystems.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:11.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi