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
}