-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
navigation: adds global navigation interface implementation, adds glo…
…bal interface usage node
- Loading branch information
1 parent
33332b9
commit 43399d9
Showing
8 changed files
with
211 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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,34 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(example_global_navigation_cpp) | ||
|
||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 17) | ||
endif() | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter) | ||
endif() | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
find_package(eigen3_cmake_module REQUIRED) | ||
find_package(Eigen3 REQUIRED) | ||
find_package(ament_cmake REQUIRED) | ||
find_package(rclcpp REQUIRED) | ||
find_package(px4_ros2_cpp REQUIRED) | ||
|
||
include_directories(include ${Eigen3_INCLUDE_DIRS}) | ||
add_executable(example_global_navigation_cpp | ||
src/main.cpp) | ||
ament_target_dependencies(example_global_navigation_cpp Eigen3 px4_ros2_cpp rclcpp) | ||
|
||
install(TARGETS | ||
example_global_navigation_cpp | ||
DESTINATION lib/${PROJECT_NAME}) | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_package() |
56 changes: 56 additions & 0 deletions
56
examples/cpp/navigation/global_navigation/include/global_navigation.hpp
This file contains 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,56 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2023 PX4 Development Team. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
****************************************************************************/ | ||
#pragma once | ||
|
||
|
||
#include <rclcpp/rclcpp.hpp> | ||
#include <px4_ros2/navigation/experimental/global_navigation_interface.hpp> | ||
|
||
#include <Eigen/Core> | ||
|
||
using namespace std::chrono_literals; // NOLINT | ||
|
||
class ExampleGlobalNavigationNode : public rclcpp::Node | ||
{ | ||
public: | ||
ExampleGlobalNavigationNode() | ||
: Node("example_global_navigation_node") | ||
{ | ||
// Enable debug output | ||
auto ret = | ||
rcutils_logging_set_logger_level(get_logger().get_name(), RCUTILS_LOG_SEVERITY_DEBUG); | ||
|
||
if (ret != RCUTILS_RET_OK) { | ||
RCLCPP_ERROR(get_logger(), "Error setting severity: %s", rcutils_get_error_string().str); | ||
rcutils_reset_error(); | ||
} | ||
|
||
// Instantiate global navigation interface | ||
_global_navigation_interface = std::make_shared<px4_ros2::GlobalNavigationInterface>(*this); | ||
|
||
_timer = | ||
create_wall_timer(1s, std::bind(&ExampleGlobalNavigationNode::updateAuxGlobalPosition, this)); | ||
|
||
RCLCPP_INFO(get_logger(), "example_global_navigation_node running!"); | ||
} | ||
|
||
void updateAuxGlobalPosition() | ||
{ | ||
px4_ros2::GlobalPositionEstimate global_position_estimate {}; | ||
|
||
global_position_estimate.timestamp_sample = this->now().nanoseconds() * 1e-3; | ||
|
||
global_position_estimate.position_lat_lon = Eigen::Vector2f {12.34321, 23.45432}; | ||
global_position_estimate.position_variance = 0.4f; | ||
|
||
global_position_estimate.altitude_agl = 12.4f; | ||
|
||
_global_navigation_interface->update(global_position_estimate); | ||
} | ||
|
||
private: | ||
std::shared_ptr<px4_ros2::GlobalNavigationInterface> _global_navigation_interface; | ||
rclcpp::TimerBase::SharedPtr _timer; | ||
}; |
This file contains 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,26 @@ | ||
<?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>example_global_navigation_cpp</name> | ||
<version>0.0.1</version> | ||
<description>Example navigation: global navigation</description> | ||
<maintainer email="[email protected]">Beat Kueng</maintainer> | ||
<license>BSD-3-Clause</license> | ||
|
||
<buildtool_depend>eigen3_cmake_module</buildtool_depend> | ||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<buildtool_export_depend>eigen3_cmake_module</buildtool_export_depend> | ||
|
||
<build_depend>eigen</build_depend> | ||
<build_depend>rclcpp</build_depend> | ||
<build_export_depend>eigen</build_export_depend> | ||
|
||
<depend>px4_ros2_cpp</depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>ament_lint_common</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
This file contains 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,17 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2023 PX4 Development Team. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
****************************************************************************/ | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
|
||
#include <global_navigation.hpp> | ||
|
||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
rclcpp::init(argc, argv); | ||
rclcpp::spin(std::make_shared<ExampleGlobalNavigationNode>()); | ||
rclcpp::shutdown(); | ||
return 0; | ||
} |
This file contains 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 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 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 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