12 #include <rclcpp/rclcpp.hpp>
13 #include <px4_msgs/msg/vehicle_control_mode.hpp>
14 #include "context.hpp"
19 class SetpointBase :
public std::enable_shared_from_this<SetpointBase>
22 using ShouldActivateCB = std::function<void ()>;
26 void fillControlMode(px4_msgs::msg::VehicleControlMode & control_mode)
28 control_mode.flag_control_rates_enabled = rates_enabled;
29 control_mode.flag_control_attitude_enabled = attitude_enabled;
30 control_mode.flag_control_acceleration_enabled = acceleration_enabled;
31 control_mode.flag_control_velocity_enabled = velocity_enabled;
32 control_mode.flag_control_position_enabled = position_enabled;
33 control_mode.flag_control_altitude_enabled = altitude_enabled;
34 control_mode.flag_control_allocation_enabled = control_allocation_enabled;
35 control_mode.flag_control_climb_rate_enabled = climb_rate_enabled;
38 bool control_allocation_enabled{
true};
39 bool rates_enabled{
true};
40 bool attitude_enabled{
true};
41 bool altitude_enabled{
true};
42 bool acceleration_enabled{
true};
43 bool velocity_enabled{
true};
44 bool position_enabled{
true};
46 bool climb_rate_enabled{
false};
51 context.addSetpointType(
this);
56 std::shared_ptr<SetpointBase> getSharedPtr()
59 return shared_from_this();
60 }
catch (
const std::bad_weak_ptr & exception) {
61 throw std::runtime_error(
"Setpoint must be instantiated with std::make_shared<>");
66 virtual Configuration getConfiguration() = 0;
68 virtual float desiredUpdateRateHz() {
return 50.f;}
71 void setShouldActivateCallback(
const ShouldActivateCB & should_activate_cb)
73 _should_activate_cb = should_activate_cb;
75 void setActive(
bool active) {_active = active;}
80 if (!_active && _should_activate_cb) {
81 _should_activate_cb();
86 ShouldActivateCB _should_activate_cb;
Definition: context.hpp:20
Definition: setpoint_base.hpp:20
Definition: setpoint_base.hpp:25