Skip to content
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

Add driver station warning if named command is not known #579

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pathplannerlib-python/pathplannerlib/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
PathfindThenFollowPathLTV
from .geometry_util import flipFieldPose
import os
from wpilib import getDeployDirectory, reportError
from wpilib import getDeployDirectory, reportError, reportWarning
import json
from commands2.command import Command
from commands2.subsystem import Subsystem
Expand Down Expand Up @@ -51,6 +51,7 @@ def getCommand(name: str) -> Command:
if NamedCommands.hasCommand(name):
return CommandUtil.wrappedEventCommand(NamedCommands._namedCommands[name])
else:
reportWarning(f"PathPlanner attempted to create a command '{name}' that has not been registered with NamedCommands.registerCommand", False)
return cmd.none()


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pathplanner.lib.auto;

import edu.wpi.first.math.Pair;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj2.command.*;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -61,6 +62,11 @@ public static Command getCommand(String name) {
if (hasCommand(name)) {
return CommandUtil.wrappedEventCommand(namedCommands.get(name));
} else {
DriverStation.reportWarning(
"PathPlanner attempted to create a command '"
+ name
+ "' that has not been registered with NamedCommands.registerCommand",
false);
return Commands.none();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "pathplanner/lib/auto/NamedCommands.h"
#include "pathplanner/lib/auto/CommandUtil.h"
#include "frc/Errors.h"

using namespace pathplanner;

Expand All @@ -10,5 +11,8 @@ frc2::CommandPtr NamedCommands::getCommand(std::string name) {
return CommandUtil::wrappedEventCommand(
NamedCommands::namedCommands.at(name));
}
FRC_ReportError(frc::warn::Warning,
"PathPlanner attempted to create a command '{}' that has not been registered with NamedCommands::registerCommand",
name);
return frc2::cmd::None();
}
Loading