-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
command.withName
crashes when run from dashboard
#7352
Comments
Could you post a link to the full code? Note that command instances cannot be reused, so decorating a stored command is a bad idea, since then the stored command can no longer be used (except from the first time you decorated it). Applying the following diff to a freshly generated robot project using the Robot Command Skeleton (Advanced) Java template works just fine: diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java
index b68462c..73007cd 100644
--- a/src/main/java/frc/robot/Robot.java
+++ b/src/main/java/frc/robot/Robot.java
@@ -5,8 +5,10 @@
package frc.robot;
import edu.wpi.first.wpilibj.TimedRobot;
+import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
+import edu.wpi.first.wpilibj2.command.Commands;
public class Robot extends TimedRobot {
private Command m_autonomousCommand;
@@ -16,6 +18,7 @@ public class Robot extends TimedRobot {
@Override
public void robotInit() {
m_robotContainer = new RobotContainer();
+ SmartDashboard.putData("SD Key", Commands.print("Hello World").withName("Name"));
}
@Override (After opening the command from the SmartDashboard tab at the top of the Sim GUI, I can click Run multiple times and get a corresponding number of print statements) |
Thats essentially what I have, except I did it in robot container. I didn't mention that this was with |
This is due to #6471. Calling initSendable on the wrapped command is fundamentally flawed as the wrapper is the command being sent. |
Describe the bug
If you publish a command over networktables and add a
.withName
decorator, the code crashes. Furthermore the name is no longer reflected in the buttons on the dashboard before you schedule the commandTo Reproduce
Run the simulator, click the command, and the code crashes.
The text was updated successfully, but these errors were encountered: