forked from wpilibsuite/RobotBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New command framework for C++ (wpilibsuite#248)
Update to export New Command Framework. Fixes wpilibsuite#191 Use uniform initialization in header. Fixes wpilibsuite#80 Co-authored-by: Joe <sciencewhiz@users.noreply.github.com>
- Loading branch information
1 parent
1ff721f
commit d2c1d73
Showing
78 changed files
with
732 additions
and
627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#set($command = $helper.getByName($command_name, $robot)) | ||
#if ( $command.getProperty("Run When Disabled").getValue() ) | ||
return true; | ||
#else | ||
return false; | ||
#end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
#set($command = $helper.getByName($command_name, $robot)) | ||
#macro( klass $cmd )#if( "#type($cmd)" == "" )frc::Command#else frc::#type($cmd)#end#end | ||
#macro( klass $cmd ) frc2::CommandHelper<#type($cmd), $cmd.name>#end | ||
#header() | ||
|
||
#pragma once | ||
|
||
\#include "frc/commands/Command.h" | ||
\#include "frc/commands/Subsystem.h" | ||
\#include "Robot.h" | ||
#@autogenerated_code("includes", " ") | ||
#parse("${exporter_path}command-includes.h") | ||
#end | ||
|
||
/** | ||
* | ||
* | ||
* @author ExampleAuthor | ||
*/ | ||
class #class($command.name): public #klass($command) { | ||
class #class($command.name): public frc2::CommandHelper<#type($command), #class($command.name)> { | ||
public: | ||
#@autogenerated_code("constructor", " ") | ||
#parse("${exporter_path}Command-constructor-header.h") | ||
#end | ||
|
||
void Initialize() override; | ||
void Execute() override; | ||
bool IsFinished() override; | ||
void End() override; | ||
void Interrupted() override; | ||
void Initialize() override; | ||
void Execute() override; | ||
bool IsFinished() override; | ||
void End(bool interrupted) override; | ||
bool RunsWhenDisabled() const override; | ||
|
||
|
||
private: | ||
#@autogenerated_code("variables", " ") | ||
#@autogenerated_code("variables", " ") | ||
#parse("${exporter_path}Command-constructor-variables.h") | ||
#end | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/export/cpp/CommandBasedRobot-declarations.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#foreach ($component in $components) | ||
#if ($helper.exportsTo("Robot", $component)) | ||
#declaration($component) | ||
#declaration($component) | ||
|
||
#end | ||
#end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
#set($autonomous = $robot.getProperty("Autonomous Command").getValue()) | ||
#if($autonomous != "None")\#include "Commands/#class($autonomous).h" | ||
#if($autonomous != "None")\#include "commands/#class($autonomous).h" | ||
#end | ||
#foreach( $component in $components ) | ||
#if ($component.getBase().getType() == "Command" | ||
&& $component.getProperty("Autonomous Selection").getValue()) | ||
\#include "Commands/#class($component.getName()).h" | ||
\#include "commands/#class($component.getName()).h" | ||
#end | ||
#end | ||
${helper.getImports($robot, "Robot")} |
3 changes: 1 addition & 2 deletions
3
src/main/resources/export/cpp/CommandBasedRobot-initialization.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#foreach ($component in $components) | ||
#if ($helper.exportsTo("Robot", $component)) | ||
std::shared_ptr<#class($component.name)> Robot::#variable($component.name); | ||
#class($component.name)* m_#variable($component.name); | ||
#end | ||
#end | ||
std::unique_ptr<OI> Robot::oi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
#header() | ||
#pragma once | ||
|
||
\#include "frc/TimedRobot.h" | ||
\#include "frc/commands/Command.h" | ||
\#include "frc/livewindow/LiveWindow.h" | ||
\#include "frc/smartdashboard/SendableChooser.h" | ||
\#include <frc/TimedRobot.h> | ||
\#include <frc2/command/Command.h> | ||
|
||
#@autogenerated_code("includes", "") | ||
#parse("${exporter_path}CommandBasedRobot-includes.h") | ||
#end | ||
\#include "OI.h" | ||
\#include "RobotContainer.h" | ||
|
||
class Robot : public frc::TimedRobot { | ||
public: | ||
frc::Command* autonomousCommand = nullptr; | ||
static std::unique_ptr<OI> oi; | ||
frc::LiveWindow *lw = frc::LiveWindow::GetInstance(); | ||
frc::SendableChooser<frc::Command*> chooser; | ||
#@autogenerated_code("declarations", " ") | ||
#parse("${exporter_path}CommandBasedRobot-declarations.cpp") | ||
#end | ||
void RobotInit() override; | ||
void DisabledInit() override; | ||
void DisabledPeriodic() override; | ||
void AutonomousInit() override; | ||
void AutonomousPeriodic() override; | ||
void TeleopInit() override; | ||
void TeleopPeriodic() override; | ||
public: | ||
void RobotInit() override; | ||
void RobotPeriodic() override; | ||
void DisabledInit() override; | ||
void DisabledPeriodic() override; | ||
void AutonomousInit() override; | ||
void AutonomousPeriodic() override; | ||
void TeleopInit() override; | ||
void TeleopPeriodic() override; | ||
void TestPeriodic() override; | ||
|
||
private: | ||
// Have it null by default so that if testing teleop it | ||
// doesn't have undefined behavior and potentially crash. | ||
frc2::Command* m_autonomousCommand = nullptr; | ||
|
||
RobotContainer m_container; | ||
}; |
Oops, something went wrong.