We were having trouble getting our RobotBuilder generated code to compile. Whenever we set a default command for a subsystem, we would get an error:
void Elevator::InitDefaultCommand() {
// Set the default command for a subsystem here.
//setDefaultCommand(new MySpecialCommand());
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND
SetDefaultCommand(new ElevatorToBottom());
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND
}
Info: Internal Builder is used for build
arm-frc-linux-gnueabi-g++ -std=c++1y -I/Users/davidingraham/wpilib/cpp/current/include "-I\\$\\{workspace_loc:/2015RobotBuilder/src}" -O0 -g3 -Wall -c -fmessage-length=0 -o src/Subsystems/Elevator.o ../src/Subsystems/Elevator.cpp
../src/Subsystems/Elevator.cpp: In member function 'virtual void Elevator::InitDefaultCommand()':
../src/Subsystems/Elevator.cpp:62:24: error: expected type-specifier before 'ElevatorToBottom'
SetDefaultCommand(new ElevatorToBottom());
We were able to fix this by including the header file for the command we wished to set as the default:
#include "../Commands/ElevatorToBottom.h"
at the top of the “Subsystems/Elevator.cpp” source file.
It seems that RobotBuilder is not automatically including the the header file for the default command in the <subsystem>.cpp file. Is this a bug, or are we expected to add this manually?