Go to Post Robot: Aww, the FMS doesn't want to chat with me anymore. Was it something I said? - EricVanWyk [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 29-09-2011, 16:34
AndrewD's Avatar
AndrewD AndrewD is offline
Programming/Electrical Mentor
AKA: Andrew Dolio
FRC #1243 (Dragons)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Swartz Creek, MI
Posts: 23
AndrewD is an unknown quantity at this point
Driver Station I/O in C++

Hello all,
I'm trying to read buttons from the cypress board to fire relays on the 'bot.
My code so far (just for the relays and dsio) is:
Code:
class RobotDemo : public SimpleRobot
{
     Relay barrel1;
     Relay barrel2;
     Relay barrel3;
     DriverStation ds;

public:
     RobotDemo(void):
          barrel1(3),
          barrel2(4),
          barrel3(5),
          ds()
     {
           GetWatchdog().SetExpiration(0.1);
     }
     void OperatorControl(void)
     {
          GetWatchdog.SetEnabled(true);
          while (IsOperatorControl())
          {
               GetWatchdog().Feed();
               if (ds.GetDigitalIn(3)) {
                    barrel1.Set(Relay::kOn)
               } else {
                    barrel1.Set(Relay::kOff)
               }
          }
     }
}
of course there is more code for the drive train but this is all that needs help. i need to know what to put in the parentheses for "ds()" under "RobotDemo(void):"

Thanks in advance,
Andrew D.
__________________



____________________________________________
Programming/Electrical Mentor
FRC Team #1243 - The Dragons
Reply With Quote
  #2   Spotlight this post!  
Unread 29-09-2011, 17:53
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Driver Station I/O in C++

If I did not know WPILib, your question is already answered (that is where you put the parens). However, I do know WPILib, and you are initializing the ds wrong (because you are getting an error you did not post, which are helpful, no matter how odd it may seem to you). The DS is a singleton, and so you need to initialize it based on the singleton. If you looked at the WPILib docs, you would notice the constructor is private.
Code:
..
     Relay barrel3;
     DriverStation &ds;

public:
     RobotDemo(void):
          barrel1(3),
          barrel2(4),
          barrel3(5),
          ds(*(DriverStation::GetInstance()))
     {
           GetWatchdog().SetExpiration(0.1);
     }
     void OperatorControl(void)
...
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
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 13:31.

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