Skip to content

Commit

Permalink
Fix InstantCommand when no subsystem (#366)
Browse files Browse the repository at this point in the history
Replace InstantCommand-constructor with the generic Command-constructor
Add export tests for InstantCommand
Fix AddRequirements comment
  • Loading branch information
sciencewhiz authored Jan 29, 2021
1 parent 3b329f1 commit 7c1f54a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/export/cpp/Command-constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#end

// Use AddRequirements() here to declare subsystem dependencies
// eg. AddRequirements(Robot::chassis.get());
// eg. AddRequirements(m_Subsystem);
SetName("#class($command.name)");
#if (${command.getProperty("Requires").getValue()} != "None")
AddRequirements(#variable(${command.getProperty("Requires").getValue().toLowerCase()}));
Expand Down
19 changes: 0 additions & 19 deletions src/main/resources/export/cpp/InstantCommand-constructor.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/export/cpp/InstantCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
\#include "commands/#class($command.name).h"

#@autogenerated_code("constructor", "")
#parse("${exporter_path}InstantCommand-constructor.cpp")
#parse("${exporter_path}Command-constructor.cpp")
#end

}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/export/cpp/InstantCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#pragma once

\#include "frc2/command/InstantCommand.h"
#if (${command.getProperty("Requires").getValue()} != "None")
\#include "subsystems/#class(${command.getProperty("Requires").getValue()}).h"
#end

/**
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/export/cpp/files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
source: ${exporter_path}InstantCommand.cpp
update: Modify
modifications:
constructor: ${exporter_path}InstantCommand-constructor.cpp
constructor: ${exporter_path}Command-constructor.cpp
variables:
command_name: ${command.name}
- !File
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/robotbuilder/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ public static RobotTree generateTestTree() {
setpointCommand.getProperty("Requires").setValueAndUpdate("Wrist");
setpointCommand.getProperty("Button on SmartDashboard").setValueAndUpdate(false);

// Create instant command
RobotComponent instantCommand = new RobotComponent("Instant Command 1", "Instant Command", tree);
commands.add(instantCommand);

// Create instant command with requires
RobotComponent instantCommand2 = new RobotComponent("Instant Command 2", "Instant Command", tree);
commands.add(instantCommand2);
instantCommand2.getProperty("Requires").setValueAndUpdate("Wrist");

// Deal with odd references
driveTrain.getProperty("Default Command").setValueAndUpdate("Tank Drive");
armUpButton.getProperty("Command").setValueAndUpdate("Arm Up");
Expand Down

0 comments on commit 7c1f54a

Please sign in to comment.