-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Backport RouteTool RViz plugin to Jazzy (#5663) #5727
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
736f53e
Backport RouteTool RViz plugin to Jazzy (#5663)
Prathmesh2931 3454c82
fix Linting: added newline at end of file
Prathmesh2931 bdb4acc
Fix linting: remove blank line at end of Python file
Prathmesh2931 a420813
Fix uncrustify formatting for route_tool files
Prathmesh2931 6710e1b
Updated nav2_route/CMakeLists.txt to original Jazzy
Prathmesh2931 86ce73e
Fix RouteTool backport to jazzy
Prathmesh2931 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
nav2_rviz_plugins/include/nav2_rviz_plugins/route_tool.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| // 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_RVIZ_PLUGINS__ROUTE_TOOL_HPP_ | ||
| #define NAV2_RVIZ_PLUGINS__ROUTE_TOOL_HPP_ | ||
|
|
||
| #include <ui_route_tool.h> | ||
| #include <limits> | ||
| #include <memory> | ||
| #include <string> | ||
| #include <vector> | ||
| #include "geometry_msgs/msg/point_stamped.hpp" | ||
| #include "nav_msgs/msg/occupancy_grid.hpp" | ||
| #include "nav2_route/graph_loader.hpp" | ||
| #include "nav2_route/graph_saver.hpp" | ||
| #include "nav2_route/types.hpp" | ||
| #include "nav2_route/utils.hpp" | ||
| #include "rclcpp/rclcpp.hpp" | ||
| #include "nav2_util/lifecycle_node.hpp" | ||
| #include "rviz_common/panel.hpp" | ||
| #include "std_msgs/msg/int16.hpp" | ||
| #include "std_msgs/msg/string.hpp" | ||
|
|
||
|
|
||
| namespace nav2_rviz_plugins | ||
| { | ||
| /** | ||
| * Here we declare our new subclass of rviz::Panel. Every panel which | ||
| * can be added via the Panels/Add_New_Panel menu is a subclass of | ||
| * rviz::Panel. | ||
| */ | ||
|
|
||
| class RouteTool : public rviz_common::Panel | ||
| { | ||
| /** | ||
| * This class uses Qt slots and is a subclass of QObject, so it needs | ||
| * the Q_OBJECT macro. | ||
| */ | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| /** | ||
| * QWidget subclass constructors usually take a parent widget | ||
| * parameter (which usually defaults to 0). At the same time, | ||
| * pluginlib::ClassLoader creates instances by calling the default | ||
| * constructor (with no arguments). Taking the parameter and giving | ||
| * a default of 0 let's the default constructor work and also let's | ||
| * someone using the class for something else to pass in a parent | ||
| * widget as they normally would with Qt. | ||
| */ | ||
| explicit RouteTool(QWidget * parent = nullptr); | ||
|
|
||
| void onInitialize() override; | ||
|
|
||
| /** | ||
| * Now we declare overrides of rviz_common::Panel functions for saving and | ||
| * loading data from the config file. Here the data is the topic name. | ||
| */ | ||
| virtual void save(rviz_common::Config config) const; | ||
| virtual void load(const rviz_common::Config & config); | ||
|
|
||
|
|
||
| /** | ||
| * Here we declare some internal slots. | ||
| */ | ||
|
|
||
| private Q_SLOTS: | ||
| void on_load_button_clicked(void); | ||
|
|
||
| void on_save_button_clicked(void); | ||
|
|
||
| void on_create_button_clicked(void); | ||
|
|
||
| void on_confirm_button_clicked(void); | ||
|
|
||
| void on_delete_button_clicked(void); | ||
|
|
||
| void on_add_node_button_toggled(void); | ||
|
|
||
| void on_edit_node_button_toggled(void); | ||
|
|
||
| /** | ||
| * Finally, we close up with protected member variables | ||
| */ | ||
|
|
||
| protected: | ||
| // UI pointer | ||
| std::unique_ptr<Ui::route_tool> ui_; | ||
|
|
||
| private: | ||
| void update_route_graph(void); | ||
| nav2_util::LifecycleNode::SharedPtr node_; | ||
| std::shared_ptr<nav2_route::GraphLoader> graph_loader_; | ||
| std::shared_ptr<nav2_route::GraphSaver> graph_saver_; | ||
| std::shared_ptr<tf2_ros::Buffer> tf_; | ||
| nav2_route::Graph graph_; | ||
| nav2_route::GraphToIDMap graph_to_id_map_; | ||
| nav2_route::GraphToIDMap edge_to_node_map_; | ||
| nav2_route::GraphToIncomingEdgesMap graph_to_incoming_edges_map_; | ||
|
|
||
| rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr | ||
| graph_vis_publisher_; | ||
| rclcpp::Subscription<geometry_msgs::msg::PointStamped>::SharedPtr | ||
| clicked_point_subscription_; | ||
|
|
||
| unsigned int next_node_id_ = 0; | ||
| }; | ||
| } // namespace nav2_rviz_plugins | ||
| #endif // NAV2_RVIZ_PLUGINS__ROUTE_TOOL_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Copyright (c) 2025 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. | ||
|
|
||
| import os | ||
|
|
||
| from ament_index_python.packages import get_package_share_directory | ||
| from launch import LaunchDescription | ||
| from launch.actions import DeclareLaunchArgument | ||
| from launch.substitutions import LaunchConfiguration | ||
| import launch_ros.actions | ||
|
|
||
|
|
||
| def generate_launch_description() -> LaunchDescription: | ||
|
|
||
| # Nodes launching commands | ||
| map_file = LaunchConfiguration('yaml_filename') | ||
|
|
||
| declare_map_file_cmd = DeclareLaunchArgument( | ||
| 'yaml_filename', | ||
| default_value='', | ||
| description='Full path to an occupancy grid map yaml file', | ||
| ) | ||
|
|
||
| start_route_tool_cmd = launch_ros.actions.Node( | ||
| package='rviz2', | ||
| executable='rviz2', | ||
| output='screen', | ||
| arguments=[ | ||
| '-d' | ||
| + os.path.join( | ||
| get_package_share_directory('nav2_rviz_plugins'), | ||
| 'rviz', | ||
| 'route_tool.rviz', | ||
| ) | ||
| ], | ||
| ) | ||
|
|
||
| start_map_server = launch_ros.actions.Node( | ||
| package='nav2_map_server', | ||
| executable='map_server', | ||
| output='screen', | ||
| parameters=[{'yaml_filename': map_file}], | ||
| ) | ||
|
|
||
| start_lifecycle_manager_cmd = launch_ros.actions.Node( | ||
| package='nav2_lifecycle_manager', | ||
| executable='lifecycle_manager', | ||
| name='lifecycle_manager', | ||
| output='screen', | ||
| parameters=[ | ||
| {'use_sim_time': False}, | ||
| {'autostart': True}, | ||
| {'node_names': ['map_server']}, | ||
| ], | ||
| ) | ||
|
|
||
| return LaunchDescription( | ||
| [ | ||
| declare_map_file_cmd, | ||
| start_route_tool_cmd, | ||
| start_map_server, | ||
| start_lifecycle_manager_cmd, | ||
| ] | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.