![]() |
Cannot allocate an object of type 'Command'
Guys,
I think I understand why this is throwing an error, but I am looking for the correct way to do this. In Brad Miller's last Robot Builder video on youtube he writes the following java code: Code:
autonomousCommand = (Command) autonomousModes->GetSelected();C:/WindRiver/workspace/TestProject/Robot.cpp: In member function `virtual void Robot::AutonomousInit()': C:/WindRiver/workspace/TestProject/Robot.cpp:40: error: cannot allocate an object of type `Command' C:/WindRiver/workspace/TestProject/Robot.cpp:40: error: because the following virtual functions are abstract: C:/WindRiver/vxworks-6.3/target/h/WPILib/Commands/Command.h:79: error: virtual void Command::Initialize() C:/WindRiver/vxworks-6.3/target/h/WPILib/Commands/Command.h:84: error: virtual void Command::Execute() C:/WindRiver/vxworks-6.3/target/h/WPILib/Commands/Command.h:95: error: virtual bool Command::IsFinished() C:/WindRiver/vxworks-6.3/target/h/WPILib/Commands/Command.h:101: error: virtual void Command::End() C:/WindRiver/vxworks-6.3/target/h/WPILib/Commands/Command.h:114: error: virtual void Command::Interrupted() C:\WindRiver\vxworks-6.3\host\x86-win32\bin\make.exe: *** [CommandBasedRobotTemplate/Debug/Objects/TestProject/Robot.o] Error 1 The idea is to cast to the "Command" type in order to be able to set autonomousCommand equal to the output of a SelectableChooser object (which is set by the user clicking on the desired command on the Smartdashboard) - which is then the command that gets run in autonomous. Any thoughts? Thanks in advance. - Bryce P.S. Here's the complete code in Robot.cpp Code:
void Robot::RobotInit() { |
Re: Cannot allocate an object of type 'Command'
You can't cast to Command class because it is an abstract class and therefore cannot have any instances. Try casting to CommandBase
|
Re: Cannot allocate an object of type 'Command'
There's a new example of doing this in C++ at the bottom of this page:
http://wpilib.screenstepslive.com/s/...smartdashboard Brad |
Re: Cannot allocate an object of type 'Command'
Thanks Brad. Just missing a *. I could have sworn that I tried that, but obviously not...
- Bryce |
| All times are GMT -5. The time now is 02:08. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi