SMACC2
Loading...
Searching...
No Matches
cp_failsafe_flags.cpp
Go to the documentation of this file.
1// Copyright 2025 Robosoft Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
17namespace cl_px4_mr
18{
20
22
24{
25 subscriber_ = getNode()->create_subscription<px4_msgs::msg::FailsafeFlags>(
26 "/fmu/out/failsafe_flags", rclcpp::SensorDataQoS(),
27 std::bind(&CpFailsafeFlags::onFailsafeMessage, this, std::placeholders::_1));
28 RCLCPP_INFO(getLogger(), "CpFailsafeFlags: subscribed to /fmu/out/failsafe_flags");
29}
30
31void CpFailsafeFlags::onFailsafeMessage(const px4_msgs::msg::FailsafeFlags::SharedPtr msg)
32{
33 std::lock_guard<std::mutex> lock(mutex_);
34 hasMessage_ = true;
35 attitudeInvalid_ = msg->attitude_invalid;
36 localAltitudeInvalid_ = msg->local_altitude_invalid;
37 localPositionInvalid_ = msg->local_position_invalid;
38}
39
41{
42 std::lock_guard<std::mutex> lock(mutex_);
43 return hasMessage_;
44}
45
47{
48 std::lock_guard<std::mutex> lock(mutex_);
49 return attitudeInvalid_;
50}
51
53{
54 std::lock_guard<std::mutex> lock(mutex_);
56}
57
59{
60 std::lock_guard<std::mutex> lock(mutex_);
62}
63
65{
66 std::lock_guard<std::mutex> lock(mutex_);
68}
69} // namespace cl_px4_mr
void onFailsafeMessage(const px4_msgs::msg::FailsafeFlags::SharedPtr msg)
rclcpp::Subscription< px4_msgs::msg::FailsafeFlags >::SharedPtr subscriber_
rclcpp::Logger getLogger() const
rclcpp::Node::SharedPtr getNode()