PX4 ROS 2 Interface Library
Library to interface with PX4 from a companion computer using ROS 2
direct_actuators.hpp
1 /****************************************************************************
2  * Copyright (c) 2023 PX4 Development Team.
3  * SPDX-License-Identifier: BSD-3-Clause
4  ****************************************************************************/
5 
6 #pragma once
7 
8 #include <Eigen/Core>
9 #include <px4_msgs/msg/actuator_motors.hpp>
10 #include <px4_msgs/msg/actuator_servos.hpp>
11 #include <px4_ros2/common/setpoint_base.hpp>
12 
13 namespace px4_ros2 {
22  public:
23  explicit DirectActuatorsSetpointType(Context& context);
24 
25  static constexpr int kMaxNumMotors = px4_msgs::msg::ActuatorMotors::NUM_CONTROLS;
26  static constexpr int kMaxNumServos = px4_msgs::msg::ActuatorServos::NUM_CONTROLS;
27 
28  ~DirectActuatorsSetpointType() override = default;
29 
30  Configuration getConfiguration() override;
31  float desiredUpdateRateHz() override { return 200.f; }
32 
38  void updateServos(const Eigen::Matrix<float, kMaxNumServos, 1>& servo_commands);
39 
46  void updateMotors(const Eigen::Matrix<float, kMaxNumMotors, 1>& motor_commands);
47 
48  private:
49  rclcpp::Node& _node;
50  rclcpp::Publisher<px4_msgs::msg::ActuatorMotors>::SharedPtr _actuator_motors_pub;
51  rclcpp::Publisher<px4_msgs::msg::ActuatorServos>::SharedPtr _actuator_servos_pub;
52 };
53 
55 } /* namespace px4_ros2 */
Definition: context.hpp:18
Setpoint type for direct actuator control (servos and/or motors)
Definition: direct_actuators.hpp:21
void updateMotors(const Eigen::Matrix< float, kMaxNumMotors, 1 > &motor_commands)
void updateServos(const Eigen::Matrix< float, kMaxNumServos, 1 > &servo_commands)
Definition: setpoint_base.hpp:19
Definition: setpoint_base.hpp:23