Skip to content

Commit c9688ee

Browse files
committed
mission syntax validation
1 parent 08d385d commit c9688ee

4 files changed

Lines changed: 444 additions & 1 deletion

File tree

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*!
2+
* @file
3+
*
4+
* @section LICENSE
5+
*
6+
* Copyright (C) 2017 by the Georgia Tech Research Institute (GTRI)
7+
*
8+
* This file is part of SCRIMMAGE.
9+
*
10+
* SCRIMMAGE is free software: you can redistribute it and/or modify it under
11+
* the terms of the GNU Lesser General Public License as published by the
12+
* Free Software Foundation, either version 3 of the License, or (at your
13+
* option) any later version.
14+
*
15+
* SCRIMMAGE is distributed in the hope that it will be useful, but WITHOUT
16+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18+
* License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public License
21+
* along with SCRIMMAGE. If not, see <http://www.gnu.org/licenses/>.
22+
*
23+
* @author Ethan M Boos <ethan.boos@gtri.gatech.edu>
24+
* @date 06 April 2026
25+
* @version 0.1.0
26+
* @brief Brief file description.
27+
* @section DESCRIPTION
28+
* A Long description goes here.
29+
*
30+
*/
31+
32+
#ifndef INCLUDE_SCRIMMAGE_PARSE_MISSIONVALIDATION_H_
33+
#define INCLUDE_SCRIMMAGE_PARSE_MISSIONVALIDATION_H_
34+
35+
#include <list>
36+
#include <map>
37+
#include <memory>
38+
#include <set>
39+
#include <string>
40+
#include <vector>
41+
42+
namespace scrimmage {
43+
44+
class FileSearch;
45+
class MissionParse;
46+
47+
struct ValidationError {
48+
enum class Type {
49+
PLUGIN_CONFIG_NOT_FOUND,
50+
PLUGIN_LIBRARY_NOT_FOUND,
51+
PLUGIN_LIBRARY_INVALID,
52+
UNKNOWN_PLUGIN_TYPE
53+
};
54+
55+
Type type;
56+
std::string plugin_name;
57+
std::string plugin_type; // autonomy, controller, motion_model, etc.
58+
std::string context; // location in mission file (entity block index or "global")
59+
std::string message;
60+
std::vector<std::string> suggestions;
61+
};
62+
63+
struct ValidationResult {
64+
bool valid() const { return errors.empty(); }
65+
std::vector<ValidationError> errors;
66+
std::map<std::string, std::set<std::string>> available_plugins;
67+
};
68+
69+
class MissionValidation {
70+
public:
71+
ValidationResult validate(
72+
const std::shared_ptr<MissionParse>& mp,
73+
FileSearch& file_search);
74+
75+
void print_errors(
76+
const ValidationResult& result,
77+
const std::string& mission_filename) const;
78+
79+
void set_verbose(bool verbose) { verbose_ = verbose; }
80+
81+
protected:
82+
bool check_plugin_config(
83+
const std::string& plugin_name,
84+
const std::string& env_var,
85+
FileSearch& file_search);
86+
87+
std::map<std::string, std::set<std::string>> discover_plugins_by_type(
88+
const std::string& env_var,
89+
FileSearch& file_search);
90+
91+
std::vector<std::string> find_similar(
92+
const std::string& name,
93+
const std::set<std::string>& available,
94+
size_t max_suggestions = 3) const;
95+
96+
size_t levenshtein_distance(
97+
const std::string& s1,
98+
const std::string& s2) const;
99+
100+
void extract_entity_plugins(
101+
const std::map<int, std::map<std::string, std::string>>& entity_descs,
102+
std::map<std::string, std::list<std::pair<std::string, std::string>>>& plugin_names) const;
103+
104+
private:
105+
bool verbose_ = false;
106+
std::set<std::string> validated_plugins_;
107+
};
108+
109+
} // namespace scrimmage
110+
111+
#endif // INCLUDE_SCRIMMAGE_PARSE_MISSIONVALIDATION_H_

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(SRCS
2121
math/StateWithCovariance.cpp
2222
metrics/Metrics.cpp
2323
network/Interface.cpp network/ScrimmageServiceImpl.cpp
24-
parse/ConfigParse.cpp parse/MissionParse.cpp parse/ParseUtils.cpp
24+
parse/ConfigParse.cpp parse/MissionParse.cpp parse/MissionValidation.cpp parse/ParseUtils.cpp
2525
#parse/XMLParser/RapidXMLParser.cpp
2626
plugin_manager/MotionModel.cpp plugin_manager/Plugin.cpp
2727
plugin_manager/PluginManager.cpp

0 commit comments

Comments
 (0)