Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   WPILib Cookbook's Example Code Doesn't Work (http://www.chiefdelphi.com/forums/showthread.php?t=111696)

danielcg25 20-01-2013 19:08

WPILib Cookbook's Example Code Doesn't Work
 
I followed all the instructions for C++ up until page 30, and when I tried to build my project it doesn't work. I'm sure I have the exact same code as is shown in the cookbook, and I get these errors.

Code:

C:/WindRiver/workspace/CommandBasedRobotTemplate_Cookbook/CommandBase.cpp:9: error: `Chassis*CommandBase::Chassis' is not a static member of `class CommandBase'
C:/WindRiver/workspace/CommandBasedRobotTemplate_Cookbook/CommandBase.cpp: In static member function `static void CommandBase::init()':
C:/WindRiver/workspace/CommandBasedRobotTemplate_Cookbook/CommandBase.cpp:13: error: `chassis' undeclared (first use this function)
C:/WindRiver/workspace/CommandBasedRobotTemplate_Cookbook/CommandBase.cpp:13: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\WindRiver\vxworks-6.3\host\x86-win32\bin\make.exe: *** [CommandBasedRobotTemplate_partialImage/Debug/Objects/CommandBasedRobotTemplate_Cookbook/CommandBase.o] Error 1
Build Failed in Project 'CommandBasedRobotTemplate_Cookbook' (Process Exit Value was 2):  2013-01-20 18:01:32  (Elapsed Time: 00:01)


Alan Anderson 20-01-2013 20:36

Re: WPILib Cookbook's Example Code Doesn't Work
 
Disclaimer: I don't have any real experience with command/subsystem programming, so I might not be a good person to take advice from. That said...

Double-check page 27. Does your code match? Specifically, did you leave out any spaces, or get a word miscapitalized?

kenfox 20-01-2013 20:55

Re: WPILib Cookbook's Example Code Doesn't Work
 
Quote:

Originally Posted by danielcg25 (Post 1219193)
I followed all the instructions for C++ up until page 30

If you are using the cookbook from 2012, there are a few things that changed. I think http://wpilib.screenstepslive.com/s/3120 will eventually have all the content of the old documentation, but until then you have to pick through the old examples and watch for changes.

In your case it sounds like you have a chassis subsystem. The old way of handling that was to put all subsystems into the CommandBase class so all commands have easy access to subsystems. That's not a good design.

The 2013 approach is better. Put your subsystems into the Robot class and in your commands refer to Robot::chassis. If you use Robot Builder it follows this convention.

Since you are new to the command-based robot approach, you definitely should experiment with Robot Builder and carefully read the code it generates. It's quite good. Even if you decide not to use Robot Builder, you'll probably adopt a lot of what you learn from reading that code.

Toa Circuit 20-01-2013 22:11

Re: WPILib Cookbook's Example Code Doesn't Work
 
I think somewhere you have "Chassis" written as "chassis"... maybe. Thats what I can gather off your build console. I'd have to see your source code.
(We do not use subsystems and commands for our robots, just FYI. I find it to be messy-disgusting layers of OOP and abstractions... so if it is a command-based issue, I dont know what it would be)

danielcg25 20-01-2013 22:47

Re: WPILib Cookbook's Example Code Doesn't Work
 
Quote:

Originally Posted by Alan Anderson (Post 1219221)
Disclaimer: I don't have any real experience with command/subsystem programming, so I might not be a good person to take advice from. That said...

Double-check page 27. Does your code match? Specifically, did you leave out any spaces, or get a word miscapitalized?

Yes, the code matches exactly (except for the tabs, those were omitted for some reason when I copy/pasted the code into WindRiver)

danielcg25 20-01-2013 22:57

Re: WPILib Cookbook's Example Code Doesn't Work
 
Quote:

Originally Posted by kenfox (Post 1219227)
If you are using the cookbook from 2012, there are a few things that changed. I think http://wpilib.screenstepslive.com/s/3120 will eventually have all the content of the old documentation, but until then you have to pick through the old examples and watch for changes.

In your case it sounds like you have a chassis subsystem. The old way of handling that was to put all subsystems into the CommandBase class so all commands have easy access to subsystems. That's not a good design.

The 2013 approach is better. Put your subsystems into the Robot class and in your commands refer to Robot::chassis. If you use Robot Builder it follows this convention.

Since you are new to the command-based robot approach, you definitely should experiment with Robot Builder and carefully read the code it generates. It's quite good. Even if you decide not to use Robot Builder, you'll probably adopt a lot of what you learn from reading that code.

I do have a Chassis subsystem; I'll look into the 2013 documentation instead now. Thanks.


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

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