OCCRA
Go to Post the entire arena broke into applause when that first robot climbed that first robot ramp. - RoboMom [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 01-21-2018, 06:47 PM
egaudet's Avatar
egaudet egaudet is offline
Software Team Mentor
FRC #4917 (Sir Lancerbot)
Team Role: Mentor
 
Join Date: Nov 2016
Rookie Year: 2012
Location: Ontario, Canada
Posts: 19
egaudet will become famous soon enough
2018 Robot C++ Template broken? - What happened to CommandBase.cpp/h?

When you create a new WPI Robot C++ project using the 2018 software, you get a template project that no longer includes CommandBase.cpp and CommandBase.h.

In previous years, when you add a subsystem, you initialized it in CommandBase and then you could use that variable name in commands to access it.
e.g.
Quote:
In CommandBase:
std::unique_ptr<DrivetrainSub> CommandBase::drivetrainSub = std::make_unique<DrivetrainSub>();
drivetrainSub.reset(new DrivetrainSub());
In a command:
drivetrainSub->drive(1.0, 1.0);
The template does include ExampleSubsystem but how do you access that subsystem?

The WPI documentation does give an example on this page: https://wpilib.screenstepslive.com/s...imple-commands (see "Simple Command Example" about half-way down the page)

The example accesses the subsystem with "Robot::<subsystem>" but the template doesn't seem to expose Robot globally (which makes sense since it's defined and implemented in Robot.cpp).

If you create a Command-based Robot example (GearsBot or Pacbot), you get Robot.h in which the subsystems are created. So why doesn't the default template come with a Robot.h?

Am I missing something or is the template really broken? It doesn't seem to match the examples or the little documentation that I could find.

Any assistance (answers or pointing me to the correct documentation) would be appreciated.

P.S. I also find it odd that the iterative command-based template inherits from TimedRobot (class Robot : public frc::TimedRobot ) instead of IterativeRobot like the Gearbot/Pacbot examples.
__________________

Reply With Quote
  #2   Spotlight this post!  
Unread 01-21-2018, 09:41 PM
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Santa Maria, CA
Posts: 108
calcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud of
Re: 2018 Robot C++ Template broken? - What happened to CommandBase.cpp/h?

Quote:
Originally Posted by egaudet View Post
When you create a new WPI Robot C++ project using the 2018 software, you get a template project that no longer includes CommandBase.cpp and CommandBase.h.

In previous years, when you add a subsystem, you initialized it in CommandBase and then you could use that variable name in commands to access it.
e.g.

The template does include ExampleSubsystem but how do you access that subsystem?

The WPI documentation does give an example on this page: https://wpilib.screenstepslive.com/s...imple-commands (see "Simple Command Example" about half-way down the page)

The example accesses the subsystem with "Robot::<subsystem>" but the template doesn't seem to expose Robot globally (which makes sense since it's defined and implemented in Robot.cpp).

If you create a Command-based Robot example (GearsBot or Pacbot), you get Robot.h in which the subsystems are created. So why doesn't the default template come with a Robot.h?

Am I missing something or is the template really broken? It doesn't seem to match the examples or the little documentation that I could find.
PacGoat and GearsBot declare the subsystems as public static variables. I would follow how those examples do it. We should declare a subsystem in the template as an example and create a header for the Robot class.

Quote:
Originally Posted by egaudet View Post
P.S. I also find it odd that the iterative command-based template inherits from TimedRobot (class Robot : public frc::TimedRobot ) instead of IterativeRobot like the Gearbot/Pacbot examples.
The main difference is that button triggers with two toggles really close together wouldn't be missed by IterativeRobot but could be by TimedRobot. Besides that, they provide the same interface.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-22-2018, 07:22 AM
egaudet's Avatar
egaudet egaudet is offline
Software Team Mentor
FRC #4917 (Sir Lancerbot)
Team Role: Mentor
 
Join Date: Nov 2016
Rookie Year: 2012
Location: Ontario, Canada
Posts: 19
egaudet will become famous soon enough
Re: 2018 Robot C++ Template broken? - What happened to CommandBase.cpp/h?

Ok, I'll follow those examples, thanks.

Quote:
Originally Posted by calcmogul View Post
We should declare a subsystem in the template as an example and create a header for the Robot class.
That would be a very good idea because it seems pointless to have an example subsystem that you can't access. Plus the online code snippets and comments inside the code keep referencing things like Robot::<subsystem> and you can't actually do that out-of-the-box.

It makes it really frustrating for the students. They see a comment that says

Quote:
// Use Requires() here to declare subsystem dependencies
// eg. Requires(&Robot::chassis);
but when you type it out, Robot:: gives you an error.

Thanks for the quick response!
__________________

Reply With Quote
  #4   Spotlight this post!  
Unread 01-22-2018, 08:12 PM
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Santa Maria, CA
Posts: 108
calcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud of
Re: 2018 Robot C++ Template broken? - What happened to CommandBase.cpp/h?

The examples have been modified/fixed in https://github.com/wpilibsuite/allwpilib/pull/906.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-26-2018, 06:47 AM
egaudet's Avatar
egaudet egaudet is offline
Software Team Mentor
FRC #4917 (Sir Lancerbot)
Team Role: Mentor
 
Join Date: Nov 2016
Rookie Year: 2012
Location: Ontario, Canada
Posts: 19
egaudet will become famous soon enough
Re: 2018 Robot C++ Template broken? - What happened to CommandBase.cpp/h?

I've finally gotten around to creating a new project to try this fix.

I went to New -> "Robot C++ Project" (command based) and I get a project with a Robot.h in it but the file only exists in the Eclipse tree (under src). If you try to open it, you get "Resource '/<myproject>/src/Robot.h' is not local." and the file isn't in the project folder on the computer.

I tried the same thing on a second computer with the same results. I also tried creating a timed robot and it's the same thing there too.

Looks like the Eclipse template is created properly but the Robot.h isn't getting copied over. Another odd thing is that the project does build. Nowhere is Robot.h included. Might be that it's the new template but the old files getting copied in?

Should I log a bug somewhere?

Thanks.

Eric

P.S. As far as I know, I'm using the latest software. 2018.3.3 for the plugin.
__________________

Reply With Quote
  #6   Spotlight this post!  
Unread 03-07-2018, 07:53 AM
egaudet's Avatar
egaudet egaudet is offline
Software Team Mentor
FRC #4917 (Sir Lancerbot)
Team Role: Mentor
 
Join Date: Nov 2016
Rookie Year: 2012
Location: Ontario, Canada
Posts: 19
egaudet will become famous soon enough
Re: 2018 Robot C++ Template broken? - What happened to CommandBase.cpp/h?

Looks like it's fixed in 2018.04.01 plugin.

Thanks!
__________________

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:34 AM.

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


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