-
Notifications
You must be signed in to change notification settings - Fork 478
Add GPSBroadcaster #1554
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
christophfroehlich
merged 5 commits into
ros-controls:master
from
Wiktor-99:gps_broadcaster
Apr 5, 2025
Merged
Add GPSBroadcaster #1554
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
37df4a3
Add initial version of the GPSBroadcaster
Wiktor-99 d21ae07
Review fixes
Wiktor-99 2f109ae
Update the cmake and user doc
Wiktor-99 ba43e47
Move cmake ros2 control to build deps
Wiktor-99 4863d59
Merge branch 'master' into gps_broadcaster
christophfroehlich 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
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,99 @@ | ||
| cmake_minimum_required(VERSION 3.16) | ||
| project(gps_sensor_broadcaster LANGUAGES CXX) | ||
|
|
||
| find_package(ros2_control_cmake REQUIRED) | ||
| set_compiler_options() | ||
| export_windows_symbols() | ||
|
|
||
| # using this instead of visibility macros | ||
| # S1 from https://github.com/ros-controls/ros2_controllers/issues/1053 | ||
| set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
|
|
||
| set(THIS_PACKAGE_INCLUDE_DEPENDS | ||
| controller_interface | ||
| generate_parameter_library | ||
| hardware_interface | ||
| pluginlib | ||
| rclcpp | ||
| rclcpp_lifecycle | ||
| realtime_tools | ||
| sensor_msgs | ||
| ) | ||
|
|
||
| find_package(ament_cmake REQUIRED) | ||
| foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS}) | ||
| find_package(${Dependency} REQUIRED) | ||
| endforeach() | ||
|
|
||
|
|
||
| generate_parameter_library(gps_sensor_broadcaster_parameters | ||
| src/gps_sensor_broadcaster_parameters.yaml | ||
| ) | ||
|
|
||
| add_library(gps_sensor_broadcaster SHARED | ||
| src/gps_sensor_broadcaster.cpp | ||
| ) | ||
|
|
||
| target_compile_features(gps_sensor_broadcaster PUBLIC cxx_std_17) | ||
| target_include_directories(gps_sensor_broadcaster PUBLIC | ||
| $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:include/gps_sensor_broadcaster> | ||
| ) | ||
|
|
||
| target_link_libraries(gps_sensor_broadcaster PUBLIC gps_sensor_broadcaster_parameters) | ||
| ament_target_dependencies(gps_sensor_broadcaster PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS}) | ||
|
|
||
| pluginlib_export_plugin_description_file( | ||
| controller_interface gps_sensor_broadcaster.xml) | ||
|
|
||
| if(BUILD_TESTING) | ||
| find_package(ament_cmake_gmock REQUIRED) | ||
| find_package(controller_manager REQUIRED) | ||
| find_package(hardware_interface REQUIRED) | ||
| find_package(ros2_control_test_assets REQUIRED) | ||
|
|
||
| add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test") | ||
| ament_add_gmock(test_load_gps_sensor_broadcaster | ||
| test/test_load_gps_sensor_broadcaster.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/test/gps_sensor_broadcaster_params.yaml) | ||
| target_include_directories(test_load_gps_sensor_broadcaster PRIVATE include) | ||
| target_link_libraries(test_load_gps_sensor_broadcaster | ||
| gps_sensor_broadcaster | ||
| ) | ||
| ament_target_dependencies(test_load_gps_sensor_broadcaster | ||
| controller_manager | ||
| hardware_interface | ||
| ros2_control_test_assets | ||
| ) | ||
|
|
||
| ament_add_gmock(test_gps_sensor_broadcaster | ||
| test/test_gps_sensor_broadcaster.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/test/gps_sensor_broadcaster_params.yaml) | ||
| target_include_directories(test_gps_sensor_broadcaster PRIVATE include) | ||
| target_link_libraries(test_gps_sensor_broadcaster | ||
| gps_sensor_broadcaster | ||
| ) | ||
| ament_target_dependencies(test_gps_sensor_broadcaster | ||
| hardware_interface | ||
| ros2_control_test_assets | ||
| ) | ||
| endif() | ||
|
|
||
| install( | ||
| DIRECTORY include/ | ||
| DESTINATION include/gps_sensor_broadcaster | ||
| ) | ||
| install( | ||
| TARGETS | ||
| gps_sensor_broadcaster | ||
| gps_sensor_broadcaster_parameters | ||
| EXPORT export_gps_sensor_broadcaster | ||
| RUNTIME DESTINATION bin | ||
| ARCHIVE DESTINATION lib | ||
| LIBRARY DESTINATION lib | ||
| INCLUDES DESTINATION include | ||
| ) | ||
|
|
||
| ament_export_targets(export_gps_sensor_broadcaster HAS_LIBRARY_TARGET) | ||
| ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS}) | ||
| ament_package() |
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,8 @@ | ||
| gps_sensor_broadcaster | ||
| ========================================== | ||
|
|
||
| Controller to publish readings of GPS sensors. | ||
|
|
||
| Pluginlib-Library: gps_sensor_broadcaster | ||
|
|
||
| Plugin: gps_sensor_broadcaster/GPSSensorBroadcaster (controller_interface::ControllerInterface) |
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,27 @@ | ||
| :github_url: https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/gps_sensor_broadcaster/doc/userdoc.rst | ||
|
|
||
| .. _gps_sensor_broadcaster_userdoc: | ||
|
|
||
| GPS Sensor Broadcaster | ||
| -------------------------------- | ||
| Broadcaster of messages from GPS sensor. | ||
| The published message type is ``sensor_msgs/msg/NavSatFix``. | ||
|
|
||
| The controller is a wrapper around ``GPSSensor`` semantic component (see ``controller_interface`` package). | ||
|
|
||
| Parameters | ||
| ^^^^^^^^^^^ | ||
| This controller uses the `generate_parameter_library <https://github.com/PickNikRobotics/generate_parameter_library>`_ to handle its parameters. The parameter `definition file located in the src folder <https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/gps_sensor_broadcaster/src/gps_sensor_broadcaster_params.yaml>`_ contains descriptions for all the parameters used by the controller. | ||
|
|
||
| List of parameters | ||
| ========================= | ||
| .. generate_parameter_library_details:: ../src/gps_sensor_broadcaster_parameters.yaml | ||
|
|
||
|
|
||
| An example parameter file | ||
| ========================= | ||
|
|
||
| An example parameter file for this controller can be found in `the test directory <https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/gps_sensor_broadcaster/test/gps_sensor_broadcaster_params.yaml>`_: | ||
|
|
||
| .. literalinclude:: ../test/gps_sensor_broadcaster_params.yaml | ||
| :language: yaml |
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,8 @@ | ||
| <library path="gps_sensor_broadcaster"> | ||
| <class name="gps_sensor_broadcaster/GPSSensorBroadcaster" | ||
| type="gps_sensor_broadcaster::GPSSensorBroadcaster" base_class_type="controller_interface::ControllerInterface"> | ||
| <description> | ||
| This controller publishes the readings of an GPS sensor as sensor_msgs/NavSatFix message. | ||
| </description> | ||
| </class> | ||
| </library> |
69 changes: 69 additions & 0 deletions
69
gps_sensor_broadcaster/include/gps_sensor_broadcaster/gps_sensor_broadcaster.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,69 @@ | ||
| // Copyright 2025 ros2_control development team | ||
| // | ||
| // 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. | ||
|
|
||
| /* | ||
| * Authors: Wiktor Bajor, Jakub Delicat | ||
| */ | ||
|
|
||
| #ifndef GPS_SENSOR_BROADCASTER__GPS_SENSOR_BROADCASTER_HPP_ | ||
| #define GPS_SENSOR_BROADCASTER__GPS_SENSOR_BROADCASTER_HPP_ | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
| #include <variant> | ||
| #include <vector> | ||
|
|
||
| #include "controller_interface/controller_interface.hpp" | ||
| #include "gps_sensor_broadcaster/gps_sensor_broadcaster_parameters.hpp" | ||
| #include "rclcpp_lifecycle/state.hpp" | ||
| #include "realtime_tools/realtime_publisher.hpp" | ||
| #include "semantic_components/gps_sensor.hpp" | ||
| #include "sensor_msgs/msg/nav_sat_fix.hpp" | ||
|
|
||
| namespace gps_sensor_broadcaster | ||
| { | ||
| using callback_return_type = | ||
| rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; | ||
| class GPSSensorBroadcaster : public controller_interface::ControllerInterface | ||
| { | ||
| public: | ||
| controller_interface::InterfaceConfiguration command_interface_configuration() const override; | ||
| controller_interface::InterfaceConfiguration state_interface_configuration() const override; | ||
| callback_return_type on_init() override; | ||
| callback_return_type on_configure(const rclcpp_lifecycle::State & previous_state) override; | ||
| callback_return_type on_activate(const rclcpp_lifecycle::State & previous_state) override; | ||
| callback_return_type on_deactivate(const rclcpp_lifecycle::State & previous_state) override; | ||
| controller_interface::return_type update(const rclcpp::Time &, const rclcpp::Duration &) override; | ||
|
|
||
| protected: | ||
| using GPSSensorOption = semantic_components::GPSSensorOption; | ||
| using GPSSensorVariant = std::variant< | ||
| std::monostate, semantic_components::GPSSensor<GPSSensorOption::WithCovariance>, | ||
| semantic_components::GPSSensor<GPSSensorOption::WithoutCovariance>>; | ||
| using StatePublisher = realtime_tools::RealtimePublisher<sensor_msgs::msg::NavSatFix>; | ||
|
|
||
| void setup_covariance(); | ||
| callback_return_type setup_publisher(); | ||
|
|
||
| GPSSensorVariant gps_sensor_; | ||
| rclcpp::Publisher<sensor_msgs::msg::NavSatFix>::SharedPtr sensor_state_publisher_; | ||
| std::unique_ptr<StatePublisher> realtime_publisher_; | ||
| std::shared_ptr<gps_sensor_broadcaster::ParamListener> param_listener_{}; | ||
| gps_sensor_broadcaster::Params params_; | ||
| std::vector<std::string> state_names_; | ||
| }; | ||
|
|
||
| } // namespace gps_sensor_broadcaster | ||
|
|
||
| #endif // GPS_SENSOR_BROADCASTER__GPS_SENSOR_BROADCASTER_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,38 @@ | ||
| <?xml version="1.0"?> | ||
| <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
| <package format="3"> | ||
| <name>gps_sensor_broadcaster</name> | ||
| <version>4.20.0</version> | ||
| <description>Controller to publish readings of GPS sensors.</description> | ||
| <license>Apache License 2.0</license> | ||
|
|
||
| <maintainer email="bence.magyar.robotics@gmail.com">Bence Magyar</maintainer> | ||
| <maintainer email="denis@stoglrobotics.de">Denis Štogl</maintainer> | ||
| <maintainer email="christoph.froehlich@ait.ac.at">Christoph Froehlich</maintainer> | ||
| <maintainer email="sai.kishor@pal-robotics.com">Sai Kishor Kothakota</maintainer> | ||
|
|
||
| <author email="wiktorbajor1@gmail.com">Wiktor Bajor</author> | ||
| <author email="delicat.kuba@gmail.com">Jakub Delicat</author> | ||
|
|
||
| <buildtool_depend>ament_cmake</buildtool_depend> | ||
| <build_depend>ros2_control_cmake</build_depend> | ||
|
|
||
| <depend>controller_interface</depend> | ||
| <depend>generate_parameter_library</depend> | ||
| <depend>hardware_interface</depend> | ||
| <depend>pluginlib</depend> | ||
| <depend>rclcpp</depend> | ||
| <depend>rclcpp_lifecycle</depend> | ||
| <depend>realtime_tools</depend> | ||
| <depend>sensor_msgs</depend> | ||
|
|
||
| <test_depend>ament_cmake_gmock</test_depend> | ||
| <test_depend>ament_lint_auto</test_depend> | ||
| <test_depend>ament_lint_common</test_depend> | ||
| <test_depend>controller_manager</test_depend> | ||
| <test_depend>ros2_control_test_assets</test_depend> | ||
|
|
||
| <export> | ||
| <build_type>ament_cmake</build_type> | ||
| </export> | ||
| </package> |
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.