33 RCLCPP_INFO(
getLogger(),
"CbConnectMicroRosAgent: launching micro_ros_agent...");
39 getLogger(),
"CbConnectMicroRosAgent: waiting for node '%s' (timeout %.1fs)",
42 auto startTime = std::chrono::steady_clock::now();
48 auto elapsed = std::chrono::steady_clock::now() - startTime;
49 double elapsedSec = std::chrono::duration<double>(elapsed).count();
54 targetNodeName.c_str());
61 auto nodeNames =
getNode()->get_node_names();
63 for (
const auto & n : nodeNames)
65 ss <<
" - " << n << std::endl;
67 if (n == targetNodeName)
74 getLogger(),
"[" <<
getName() <<
"] listing nodes (" << nodeNames.size() <<
")" << std::endl
82 RCLCPP_WARN(
getLogger(),
"CbConnectMicroRosAgent: shutdown requested before node found");
88 getLogger(),
"CbConnectMicroRosAgent: node '%s' detected - starting failsafe health check",
89 targetNodeName.c_str());
98 "/fmu/out/failsafe_flags", rclcpp::SensorDataQoS(),
99 [
this](
const px4_msgs::msg::FailsafeFlags::SharedPtr msg)
105 !msg->attitude_invalid && !msg->local_altitude_invalid && !msg->local_position_invalid);
112 auto controlReady = [
this]()
119 rclcpp::Rate healthRate(2.0);
122 auto elapsed = std::chrono::steady_clock::now() - startTime;
123 double elapsedSec = std::chrono::duration<double>(elapsed).count();
128 "CbConnectMicroRosAgent: timeout (%.1fs) waiting for health check. "
129 "attitude_invalid=%d, local_altitude_invalid=%d, local_position_invalid=%d, "
130 "heading_good_for_control=%d, velocity_valid=%d",
139 "CbConnectMicroRosAgent: health check: attitude_invalid=%d, "
140 "local_altitude_invalid=%d, local_position_invalid=%d, heading_good_for_control=%d, "
149 RCLCPP_INFO(
getLogger(),
"CbConnectMicroRosAgent: health check passed - posting success");
155 getLogger(),
"CbConnectMicroRosAgent: shutdown requested before health check passed");