Thread: Spike Relay
View Single Post
  #2   Spotlight this post!  
Unread 17-02-2013, 00:43
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Spike Relay

The problem is one of initialization and instantiation. It's unfortunate that C++ is so darned heavily laden with nomenclature and syntax, but alas it is... Please see a snip of your code with my added '// Initialize here' and '// don't initialize here comment

Code:
public:
	RobotDemo(void):
		myRobot(1, 2, 3, 4),	// these must be initialized in the same order
		stick(1)		// as they are declared above.
// Initialize here	
	{
	
		stick.SetAxisChannel(Joystick::kTwistAxis, 3);// Add the 3rd axis 
		myRobot.SetExpiration(0.1);// The time the motors stop moving after a value is sent  
// Don't initialize here
		Relay relay1(1,Relay::kForwardOnly);
		Relay relay2(2,Relay::kForwardOnly);
	}
As an example, you'll see, the template declares 'stick' above the snip that I have pasted above, but it INITIALIZES it just above my comment as 'stick(1)'. This is similar to what you want to do. You have properly declared relay1 and relay2 up top, but you didn't initialize them. See the changes below marked with // CHANGE

Code:
public:
	RobotDemo(void):
		myRobot(1, 2, 3, 4),	// these must be initialized in the same order
		stick(1),		// as they are declared above.
// CHANGE - added			
                relay1(1,Relay::kForwardOnly),
		relay2(2,Relay::kForwardOnly)
	{
	
		stick.SetAxisChannel(Joystick::kTwistAxis, 3);// Add the 3rd axis 
		myRobot.SetExpiration(0.1);// The time the motors stop moving after a value is sent  
// CHANGE - removed from here
	}
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote