32 RCLCPP_INFO(
getLogger(),
"CbConnectMicroRosAgent: launching micro_ros_agent...");
38 getLogger(),
"CbConnectMicroRosAgent: waiting for node '%s' (timeout %.1fs)",
41 auto startTime = std::chrono::steady_clock::now();
47 auto elapsed = std::chrono::steady_clock::now() - startTime;
48 double elapsedSec = std::chrono::duration<double>(elapsed).count();
53 targetNodeName.c_str());
60 auto nodeNames =
getNode()->get_node_names();
62 for (
const auto & n : nodeNames)
64 ss <<
" - " << n << std::endl;
66 if (n == targetNodeName)
73 getLogger(),
"[" <<
getName() <<
"] listing nodes (" << nodeNames.size() <<
")" << std::endl
81 RCLCPP_WARN(
getLogger(),
"CbConnectMicroRosAgent: shutdown requested before node found");
87 getLogger(),
"CbConnectMicroRosAgent: node '%s' detected - starting failsafe health check",
88 targetNodeName.c_str());
97 "/fmu/out/failsafe_flags", rclcpp::SensorDataQoS(),
98 [
this](
const px4_msgs::msg::FailsafeFlags::SharedPtr msg)
104 !msg->attitude_invalid && !msg->local_altitude_invalid && !msg->local_position_invalid);
107 rclcpp::Rate healthRate(2.0);
110 auto elapsed = std::chrono::steady_clock::now() - startTime;
111 double elapsedSec = std::chrono::duration<double>(elapsed).count();
116 "CbConnectMicroRosAgent: timeout (%.1fs) waiting for health check. "
117 "attitude_invalid=%d, local_altitude_invalid=%d, local_position_invalid=%d",
126 "CbConnectMicroRosAgent: health check: attitude_invalid=%d, "
127 "local_altitude_invalid=%d, local_position_invalid=%d",
135 RCLCPP_INFO(
getLogger(),
"CbConnectMicroRosAgent: health check passed - posting success");
141 getLogger(),
"CbConnectMicroRosAgent: shutdown requested before health check passed");