Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e294afa
added route tool skeleton code and gui
john-chrosniak Jun 20, 2024
c4b7334
rviz2 panel can load route graph
john-chrosniak Jul 24, 2024
3fabaf2
can add nodes using route tool
john-chrosniak Jul 24, 2024
81ad975
added logic for creating edges
john-chrosniak Jul 25, 2024
b0fa2aa
graph nodes can be edited, existing edges will still connect if a nod…
john-chrosniak Jul 25, 2024
e39920f
can edit edges
john-chrosniak Jul 25, 2024
10123cc
can delete nodes and edges
john-chrosniak Jul 25, 2024
ec6e1e4
route graphs can be saved
john-chrosniak Aug 7, 2024
f4dbe7d
fixed bug for loading in route graphs
john-chrosniak Aug 7, 2024
4b66723
added dynamic text to UI, created launch file and rviz configuration
john-chrosniak Aug 7, 2024
b3c41f5
fixed bug for deleting nodes
john-chrosniak Aug 9, 2024
88e680c
actually fixed node removal bug
john-chrosniak Aug 9, 2024
bc544a2
publishing clicked point populates x and y fields
john-chrosniak Aug 9, 2024
6aede5e
removed debugging log statements
john-chrosniak Aug 9, 2024
00328b5
added check to make sure node/edges exist before editing
john-chrosniak Aug 16, 2024
859f128
bug fix
john-chrosniak Nov 6, 2024
73450a2
migrated route tool to rviz plugin
john-chrosniak Nov 19, 2024
34deb61
minor refactoring
john-chrosniak Nov 19, 2024
7e92d8b
added metadata and operations to graph saver so nothing should be erased
john-chrosniak Nov 21, 2024
ec3163c
edited set route service to clear current route before setting new
john-chrosniak Aug 12, 2024
ebf5c30
Update README.md
SaikrishnaBairamoni Sep 24, 2024
2dee68b
addressed comments
john-chrosniak Nov 25, 2024
166b800
documentation cleanup
john-chrosniak Nov 25, 2024
2098109
changed copyright
john-chrosniak Nov 25, 2024
0291f9a
addressed comments
john-chrosniak Nov 25, 2024
a1c3fa1
moved copyright due to compiler error
john-chrosniak Nov 26, 2024
9ae6180
revert removal of files
john-chrosniak Dec 4, 2024
b172a57
added gen ai comment
john-chrosniak Dec 4, 2024
c8c0d4f
fixed rebasing issue
john-chrosniak Apr 7, 2025
ac16c1b
fix linting errors
john-chrosniak Apr 8, 2025
96b4276
added export for graph saver dependencies
john-chrosniak Apr 8, 2025
036adc7
added ui file to library
john-chrosniak Apr 8, 2025
1027df0
added nav2_route_core to link libaries
john-chrosniak Apr 8, 2025
29c986f
fixed cmake error
john-chrosniak Apr 8, 2025
b146543
fixed build issues
john-chrosniak Apr 8, 2025
1eaa4cd
uncrustified
john-chrosniak Apr 8, 2025
0e60ccb
cpplint
john-chrosniak Apr 8, 2025
300d7f1
added unit tests and fixed bugs
john-chrosniak Apr 9, 2025
d50f17e
increased test coverage
john-chrosniak Apr 9, 2025
f31a92e
fixed linter errors
john-chrosniak Apr 9, 2025
3d82b64
fixed pre-commit errors
john-chrosniak Apr 9, 2025
a28c976
fixed formatting error
john-chrosniak Apr 9, 2025
911c361
double -> single quotes
john-chrosniak Apr 9, 2025
462f1e7
added test for using default filepath
john-chrosniak Apr 10, 2025
a33d1c3
fixed license
john-chrosniak Apr 10, 2025
f630c34
addressed comments
john-chrosniak Apr 14, 2025
93e3319
Update nav2_route/include/nav2_route/graph_saver.hpp
john-chrosniak Apr 14, 2025
88f2dbe
Update nav2_route/src/plugins/graph_file_savers/geojson_graph_file_sa…
john-chrosniak Apr 14, 2025
d660772
Update nav2_route/src/plugins/graph_file_savers/geojson_graph_file_sa…
john-chrosniak Apr 14, 2025
a04e42d
Update nav2_route/src/plugins/graph_file_savers/geojson_graph_file_sa…
john-chrosniak Apr 14, 2025
f51f3d8
Update nav2_route/src/plugins/graph_file_savers/geojson_graph_file_sa…
john-chrosniak Apr 14, 2025
e341c31
linter fix
john-chrosniak Apr 14, 2025
2f30737
Merge branch 'route-server-develop' of github.com:usdot-fhwa-stol/nav…
john-chrosniak Apr 14, 2025
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
39 changes: 36 additions & 3 deletions nav2_route/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ add_library(${library_name} SHARED
src/node_spatial_tree.cpp
src/path_converter.cpp
src/graph_loader.cpp
src/graph_saver.cpp
src/goal_intent_extractor.cpp
)

Expand Down Expand Up @@ -187,6 +188,37 @@ target_link_libraries(graph_file_loaders PRIVATE
tf2::tf2
)

add_library(graph_file_savers SHARED
src/plugins/graph_file_savers/geojson_graph_file_saver.cpp
)
target_include_directories(graph_file_savers
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(graph_file_savers PUBLIC
nav2_core::nav2_core
nav2_costmap_2d::nav2_costmap_2d_core
${nav2_msgs_TARGETS}
nav2_util::nav2_util_core
${nav_msgs_TARGETS}
pluginlib::pluginlib
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
${rcl_interfaces_TARGETS}
${geometry_msgs_TARGETS}
${visualization_msgs_TARGETS}
${std_msgs_TARGETS}
${nav_msgs_TARGETS}
tf2_ros::tf2_ros
nlohmann_json::nlohmann_json
)
target_link_libraries(graph_file_savers PRIVATE
${lifecycle_msgs_TARGETS}
rclcpp_components::component
tf2::tf2
)

pluginlib_export_plugin_description_file(nav2_route plugins.xml)

install(DIRECTORY include/
Expand All @@ -197,7 +229,8 @@ install(TARGETS ${executable_name}
RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(TARGETS ${library_name} edge_scorers route_operations graph_file_loaders
install(TARGETS ${library_name} edge_scorers route_operations graph_file_loaders graph_file_savers
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
Expand All @@ -216,7 +249,6 @@ if(BUILD_TESTING)
endif()

ament_export_include_directories(include/${PROJECT_NAME})
ament_export_dependencies(${dependencies})
ament_export_dependencies(
rclcpp
rclcpp_lifecycle
Expand All @@ -232,5 +264,6 @@ ament_export_dependencies(
nanoflann
nlohmann_json
)
ament_export_libraries(${library_name} edge_scorers route_operations graph_file_loaders)
ament_export_libraries(${library_name} edge_scorers route_operations graph_file_loaders graph_file_savers)
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_package()
91 changes: 91 additions & 0 deletions nav2_route/include/nav2_route/graph_saver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (c) 2024 John Chrosniak
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NAV2_ROUTE__GRAPH_SAVER_HPP_
#define NAV2_ROUTE__GRAPH_SAVER_HPP_

#include <string>
#include <memory>
#include <vector>
#include <unordered_map>
#include <nlohmann/json.hpp>
#include <pluginlib/class_loader.hpp>

#include "nav2_util/lifecycle_node.hpp"
#include "tf2_ros/buffer.h"
#include "tf2_ros/transform_listener.h"
#include "nav2_util/node_utils.hpp"
#include "nav2_util/robot_utils.hpp"
#include "nav2_route/types.hpp"
#include "nav2_route/interfaces/graph_file_saver.hpp"
#include "rclcpp/node_interfaces/node_parameters_interface.hpp"

namespace nav2_route
{

/**
* @class nav2_route::GraphSaver
* @brief An object to save graph objects to a file
*/
class GraphSaver
{
public:
/**
* @brief A constructor for nav2_route::GraphSaver
* @param node Lifecycle node encapsulated by the GraphSaver
* @param tf A tf buffer
* @param frame Coordinate frame that the graph belongs to
*/
explicit GraphSaver(
nav2_util::LifecycleNode::SharedPtr node,
std::shared_ptr<tf2_ros::Buffer> tf,
const std::string frame);

/**
* @brief A destructor for nav2_route::GraphSaver
*/
~GraphSaver() = default;

/**
* @brief Saves a graph object to a file
* @param graph Graph to save
* @param filepath The filepath to the graph data
* @return bool If successful
*/
bool saveGraphToFile(
Graph & graph,
std::string filepath = "");

/**
* @brief Transform the coordinates in the graph to the route frame
* @param[in/out] graph The graph to be transformed
* @return True if transformation was successful
*/
bool transformGraph(Graph & graph);

protected:
std::string route_frame_, graph_filepath_;
std::shared_ptr<tf2_ros::Buffer> tf_;
rclcpp::Logger logger_{rclcpp::get_logger("GraphSaver")};

// Graph Parser
pluginlib::ClassLoader<GraphFileSaver> plugin_loader_;
GraphFileSaver::Ptr graph_file_saver_;
std::string default_plugin_id_;
std::string plugin_type_;
};

} // namespace nav2_route

#endif // NAV2_ROUTE__GRAPH_SAVER_HPP_
67 changes: 67 additions & 0 deletions nav2_route/include/nav2_route/interfaces/graph_file_saver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (c) 2024 John Chrosniak
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NAV2_ROUTE__INTERFACES__GRAPH_FILE_SAVER_HPP_
#define NAV2_ROUTE__INTERFACES__GRAPH_FILE_SAVER_HPP_

#include <string>
#include <memory>


#include "rclcpp/rclcpp.hpp"
#include "rclcpp_lifecycle/lifecycle_node.hpp"
#include "nav2_route/types.hpp"

namespace nav2_route
{

/**
* @class GraphFileSaver
* @brief A plugin interface to parse a file into the graph
*/
class GraphFileSaver
{
public:
using Ptr = std::shared_ptr<GraphFileSaver>;

/**
* @brief Constructor
*/
GraphFileSaver() = default;

/**
* @brief Virtual destructor
*/
virtual ~GraphFileSaver() = default;

/**
* @brief Configure the graph file saver, but do not store the node
* @param parent pointer to user's node
*/
virtual void configure(
const rclcpp_lifecycle::LifecycleNode::SharedPtr node) = 0;

/**
* @brief Method to save the graph to the filepath
* @param graph The graph to save
* @param filepath The path to save the file to
* @return true if graph was successfully saved
*/
virtual bool saveGraphToFile(
Graph & graph,
std::string filepath) = 0;
};
} // namespace nav2_route

#endif // NAV2_ROUTE__INTERFACES__GRAPH_FILE_SAVER_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright (c) 2024 John Chrosniak
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <memory>
#include <string>
#include <vector>
#include <nlohmann/json.hpp>

#include "nav2_core/route_exceptions.hpp"
#include "nav2_route/interfaces/graph_file_saver.hpp"
#include "nav2_route/plugins/graph_file_loaders/geojson_graph_file_loader.hpp"

#ifndef NAV2_ROUTE__PLUGINS__GRAPH_FILE_SAVERS__GEOJSON_GRAPH_FILE_SAVER_HPP_
#define NAV2_ROUTE__PLUGINS__GRAPH_FILE_SAVERS__GEOJSON_GRAPH_FILE_SAVER_HPP_

namespace nav2_route
{

/**
* @class nav2_route::GeoJsonGraphFileSaver
* @brief A GraphFileSaver plugin to save a geojson graph representation
*/
class GeoJsonGraphFileSaver : public GraphFileSaver
{
public:
using Json = nlohmann::json;

/**
* @brief Constructor
*/
GeoJsonGraphFileSaver() = default;

/**
* @brief Destructor
*/
~GeoJsonGraphFileSaver() = default;

/**
* @brief Configure, but do not store the node
* @param parent pointer to user's node
*/
void configure(
const rclcpp_lifecycle::LifecycleNode::SharedPtr node) override;

/**
* @brief Saves the graph to a geojson file
* @param graph The graph to save to the geojson file
* @param filepath The path to save the graph to
* @return True if successful
*/
bool saveGraphToFile(
Graph & graph,
std::string filepath) override;

protected:
/**
* @brief Add nodes into the graph
* @param[out] graph The graph that will contain the new nodes
* @param[in] json_features Json array to add the nodes to
*/
void loadNodesFromGraph(Graph & graph, std::vector<Json> & json_features);

/**
* @brief Add edges into the graph
* @param[out] graph The graph that will contain the new edges
* @param[in] json_edges Json array to add the edges to
*/
void loadEdgesFromGraph(Graph & graph, std::vector<Json> & json_edges);

/**
* @brief Convert graph metadata to Json
* @param metadata Metadata from a node or edge in the graph
* @param json_metadata Json entry to store metadata in
*/
void convertMetaDataToJson(const Metadata & metadata, Json & json_metadata);

/**
* @brief Convert graph operation to Json
* @param Operations Operations information from the graph
* @param json_operations Json entry to store operation data in
*/
void convertOperationsToJson(const Operations & operations, Json & json_operations);

rclcpp::Logger logger_{rclcpp::get_logger("GeoJsonGraphFileSaver")};
};
} // namespace nav2_route

#endif // NAV2_ROUTE__PLUGINS__GRAPH_FILE_SAVERS__GEOJSON_GRAPH_FILE_SAVER_HPP_
2 changes: 2 additions & 0 deletions nav2_route/include/nav2_route/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ typedef Node * NodePtr;
typedef std::vector<Node> NodeVector;
typedef NodeVector Graph;
typedef std::unordered_map<unsigned int, unsigned int> GraphToIDMap;
typedef std::unordered_map<unsigned int, std::vector<unsigned int>> GraphToIncomingEdgesMap;
typedef std::vector<NodePtr> NodePtrVector;
typedef std::pair<float, NodePtr> NodeElement;
typedef std::pair<unsigned int, unsigned int> NodeExtents;

Expand Down
4 changes: 4 additions & 0 deletions nav2_route/include/nav2_route/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <limits>
#include <string>
#include <vector>
#include "std_msgs/msg/color_rgba.hpp"
Expand Down Expand Up @@ -89,6 +90,9 @@

unsigned int marker_idx = 1;
for (unsigned int i = 0; i != graph.size(); i++) {
if (graph[i].nodeid == std::numeric_limits<int>::max()) {
continue; // Skip "deleted" nodes

Check warning on line 94 in nav2_route/include/nav2_route/utils.hpp

View check run for this annotation

Codecov / codecov/patch

nav2_route/include/nav2_route/utils.hpp#L94

Added line #L94 was not covered by tests
}
curr_marker.ns = "route_graph";
curr_marker.id = marker_idx++;
curr_marker.type = visualization_msgs::msg::Marker::SPHERE;
Expand Down
5 changes: 5 additions & 0 deletions nav2_route/plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
<description>Parse the geojson graph file into the graph data type</description>
</class>
</library>
<library path="graph_file_savers">
<class type="nav2_route::GeoJsonGraphFileSaver" base_class_type="nav2_route::GraphFileSaver">
<description>Save a route graph to a geojson graph file</description>
</class>
</library>

<library path="route_operations">
<class type="nav2_route::CollisionMonitor" base_class_type="nav2_route::RouteOperation">
Expand Down
Loading
Loading