Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Help! Timer Function in WPIlib.h (http://www.chiefdelphi.com/forums/showthread.php?t=155074)

charlier999 10-02-2017 20:51

Help! Timer Function in WPIlib.h
 
I found this inside of the WPI libary
PHP Code:

[url="http://first.wpi.edu/FRC/roborio/release/docs/cpp/classfrc_1_1Timer.html#a5f16e8da27d2a5a5242dead46de05d97"]http://first.wpi.edu/FRC/roborio/release/docs/cpp/classfrc_1_1Timer.html#a5f16e8da27d2a5a5242dead46de05d97[/url] 

I put the line
Code:

Timer::Timer();
into the code.
Timer::Timer() means
PHP Code:

Create a new timer object.

Create a new timer object and reset the time to zeroThe timer is initially not running and must be started

When I built the code in eclipse, it came back with this error >
Code:

error: cannot declare member function 'frc::Timer::Timer' within 'Robot'
  Timer::Timer();
              ^

I don't know why its doing this. If you know please tell.

Thx.

AustinShalit 10-02-2017 21:56

Re: Help! Timer Function in WPIlib.h
 
Try using this instead: frc::Timer()

charlier999 10-02-2017 22:22

Re: Help! Timer Function in WPIlib.h
 
Quote:

Originally Posted by AustinShalit (Post 1643198)
Try using this instead: frc::Timer()

Error
PHP Code:

expected unqualified-id before ')' token 


AustinShalit 10-02-2017 23:00

Re: Help! Timer Function in WPIlib.h
 
Timer is not a function. It is an object. This should work:
Code:

#include <IterativeRobot.h>
#include <Timer.h>

class Robot: public frc::IterativeRobot {
public:
        void RobotInit() {
                timer = new frc::Timer();
        }

private:
        frc::Timer* timer;
};

START_ROBOT_CLASS(Robot)

And a more complete example:
https://github.com/wpilibsuite/Eclip.../src/Robot.cpp

charlier999 10-02-2017 23:16

Re: Help! Timer Function in WPIlib.h
 
PHP Code:

double Timer::Get()const 

also a object that needs to be declared? If so how?
Thx.

Pay Me $2 11-02-2017 18:30

Re: Help! Timer Function in WPIlib.h
 
If you have a timer defined, you can Get() what its time is. For example,

Code:

timer = new frc::Timer();

timer.Reset();
timer.Start();


double time = timer.Get();



All times are GMT -5. The time now is 19:18.

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