18 #include <nlohmann/json.hpp>
20 #include "nav2_core/route_exceptions.hpp"
21 #include "nav2_route/interfaces/graph_file_loader.hpp"
22 #include "nav2_util/lifecycle_node.hpp"
24 #ifndef NAV2_ROUTE__PLUGINS__GRAPH_FILE_LOADERS__GEOJSON_GRAPH_FILE_LOADER_HPP_
25 #define NAV2_ROUTE__PLUGINS__GRAPH_FILE_LOADERS__GEOJSON_GRAPH_FILE_LOADER_HPP_
37 using Json = nlohmann::json;
54 const rclcpp_lifecycle::LifecycleNode::SharedPtr node)
override;
65 GraphToIDMap & graph_to_id_map,
66 std::string filepath)
override;
83 const Json & features, std::vector<Json> & nodes, std::vector<Json> & edges);
91 void addNodesToGraph(Graph & graph, GraphToIDMap & graph_to_id_map, std::vector<Json> & nodes);
99 void addEdgesToGraph(Graph & graph, GraphToIDMap & graph_to_id_map, std::vector<Json> & edges);
137 rclcpp::Logger logger_{rclcpp::get_logger(
"GeoJsonGraphFileLoader")};
140 NLOHMANN_JSON_SERIALIZE_ENUM(
142 {OperationTrigger::NODE,
"NODE"},
143 {OperationTrigger::ON_ENTER,
"ON_ENTER"},
144 {OperationTrigger::ON_EXIT,
"ON_EXIT"},
A GraphFileLoader plugin to load a geojson graph representation.
Coordinates convertCoordinatesFromJson(const Json &node)
Converts the coordinates from the json object into the Coordinates type.
bool doesFileExist(const std::string &filepath)
Checks if a file even exists on the filesystem.
Operation convertOperationFromJson(const Json &json_operation)
Converts the operation from the json object into the operation type.
Operations convertOperationsFromJson(const Json &properties)
Converts the operations data from the json object into the operations type if present.
~GeoJsonGraphFileLoader()=default
Destructor.
void addNodesToGraph(Graph &graph, GraphToIDMap &graph_to_id_map, std::vector< Json > &nodes)
Add nodes into the graph.
GeoJsonGraphFileLoader()=default
Constructor.
Metadata convertMetaDataFromJson(const Json &properties, const std::string &key="metadata")
Converts the metadata from the json object into the metadata type.
void configure(const rclcpp_lifecycle::LifecycleNode::SharedPtr node) override
Configure, but do not store the node.
void addEdgesToGraph(Graph &graph, GraphToIDMap &graph_to_id_map, std::vector< Json > &edges)
Add edges into the graph.
EdgeCost convertEdgeCostFromJson(const Json &properties)
Converts the edge cost data from the json object into the edge cost type.
bool loadGraphFromFile(Graph &graph, GraphToIDMap &graph_to_id_map, std::string filepath) override
Loads the geojson file into the graph.
void getGraphElements(const Json &features, std::vector< Json > &nodes, std::vector< Json > &edges)
Get the nodes and edges from features.
A plugin interface to parse a file into the graph.
An object to store Node coordinates in different frames.
An object to store edge cost or cost metadata for scoring.
An object to store operations to perform on events with types and metadata.