8 #include <rclcpp/rclcpp.hpp>
9 #include <px4_msgs/msg/arming_check_reply.hpp>
10 #include <px4_msgs/msg/arming_check_request.hpp>
11 #include <px4_ros2/common/requirement_flags.hpp>
27 : _arming_check_reply(arming_check_reply) {}
29 template<
typename ... Args>
30 void armingCheckFailureExt(
32 events::Log log_level,
const char * message, Args... args)
34 const uint16_t navigation_mode_groups{};
35 const uint8_t health_component_index{};
37 _arming_check_reply.can_arm_and_run =
false;
40 event_id, log_level, message, navigation_mode_groups,
41 health_component_index, args ...))
43 printf(
"Error: too many events\n");
47 void setHealth(uint8_t health_component_index,
bool is_present,
bool warning,
bool error);
50 template<
typename ... Args>
55 px4_msgs::msg::ArmingCheckReply & _arming_check_reply;
59 template<
typename ... Args>
60 bool HealthAndArmingCheckReporter::addEvent(
62 const char * message, Args... args)
64 if (_arming_check_reply.num_events >= _arming_check_reply.events.size()) {
68 events::EventType & e = _arming_check_reply.events[_arming_check_reply.num_events];
70 (
static_cast<uint8_t
>(log_levels.internal) << 4) |
static_cast<uint8_t
>(log_levels.external);
73 events::util::sizeofArguments(args ...) <=
sizeof(e.arguments),
74 "Too many arguments");
75 events::util::fillEventArguments(
static_cast<uint8_t *
>(e.arguments.data()), args ...);
76 ++_arming_check_reply.num_events;
81 inline void HealthAndArmingCheckReporter::setHealth(
82 uint8_t health_component_index,
bool is_present,
bool warning,
85 _arming_check_reply.health_component_index = health_component_index;
86 _arming_check_reply.health_component_is_present = is_present;
87 _arming_check_reply.health_component_warning = warning;
88 _arming_check_reply.health_component_error = error;
98 rclcpp::Node & node, CheckCallback check_callback,
99 const std::string & topic_namespace_prefix =
"");
111 _mode_requirements = mode_requirements;
117 friend class ModeBase;
118 friend class ModeExecutorBase;
119 void overrideRegistration(
const std::shared_ptr<Registration> & registration);
121 void watchdogTimerUpdate();
123 rclcpp::Node & _node;
124 std::shared_ptr<Registration> _registration;
125 CheckCallback _check_callback;
126 bool _check_triggered{
true};
128 rclcpp::Subscription<px4_msgs::msg::ArmingCheckRequest>::SharedPtr _arming_check_request_sub;
129 rclcpp::Publisher<px4_msgs::msg::ArmingCheckReply>::SharedPtr _arming_check_reply_pub;
131 RequirementFlags _mode_requirements{};
132 rclcpp::TimerBase::SharedPtr _watchdog_timer;
133 bool _shutdown_on_timeout{
true};
Definition: health_and_arming_checks.hpp:24
Definition: health_and_arming_checks.hpp:93
bool doRegister(const std::string &name)
Requirement flags used by modes.
Definition: requirement_flags.hpp:17
Definition: events.hpp:51