PX4 ROS 2 Interface Library
Library to interface with PX4 from a companion computer using ROS 2
goto.hpp
1 /****************************************************************************
2  * Copyright (c) 2023 PX4 Development Team.
3  * SPDX-License-Identifier: BSD-3-Clause
4  ****************************************************************************/
5 
6 #pragma once
7 
8 #include <px4_msgs/msg/goto_setpoint.hpp>
9 #include <Eigen/Eigen>
10 #include <optional>
11 
12 #include <px4_ros2/common/setpoint_base.hpp>
13 #include <px4_ros2/utils/geodesic.hpp>
14 
15 namespace px4_ros2
16 {
25 {
26 public:
27  explicit GotoSetpointType(Context & context);
28 
29  ~GotoSetpointType() override = default;
30 
31  Configuration getConfiguration() override;
32 
44  void update(
45  const Eigen::Vector3f & position,
46  const std::optional<float> & heading = {},
47  const std::optional<float> & max_horizontal_speed = {},
48  const std::optional<float> & max_vertical_speed = {},
49  const std::optional<float> & max_heading_rate = {}
50  );
51 
52  float desiredUpdateRateHz() override {return 30.f;}
53 
54 private:
55  rclcpp::Node & _node;
56  rclcpp::Publisher<px4_msgs::msg::GotoSetpoint>::SharedPtr
57  _goto_setpoint_pub;
58 };
59 
64 {
65 public:
66  explicit GotoGlobalSetpointType(Context & context);
67 
68  ~GotoGlobalSetpointType() = default;
69 
81  void update(
82  const Eigen::Vector3d & global_position,
83  const std::optional<float> & heading = {},
84  const std::optional<float> & max_horizontal_speed = {},
85  const std::optional<float> & max_vertical_speed = {},
86  const std::optional<float> & max_heading_rate = {}
87  );
88 
89 private:
90  rclcpp::Node & _node;
91  std::unique_ptr<MapProjection> _map_projection;
92  std::shared_ptr<GotoSetpointType> _goto_setpoint;
93 };
94 
96 } /* namespace px4_ros2 */
Definition: context.hpp:20
Setpoint type for smooth global position and heading control.
Definition: goto.hpp:64
void update(const Eigen::Vector3d &global_position, const std::optional< float > &heading={}, const std::optional< float > &max_horizontal_speed={}, const std::optional< float > &max_vertical_speed={}, const std::optional< float > &max_heading_rate={})
Go-to global setpoint update.
Setpoint type for smooth position and heading control.
Definition: goto.hpp:25
void update(const Eigen::Vector3f &position, const std::optional< float > &heading={}, const std::optional< float > &max_horizontal_speed={}, const std::optional< float > &max_vertical_speed={}, const std::optional< float > &max_heading_rate={})
Go-to setpoint update.
Definition: setpoint_base.hpp:20
Definition: setpoint_base.hpp:25