26: timeoutSec_(timeoutSec), rate_(5)
34 RCLCPP_INFO(
getLogger(),
"CbConnectMicroRosAgent: launching micro_ros_agent...");
40 getLogger(),
"CbConnectMicroRosAgent: waiting for node '%s' (timeout %.1fs)",
43 auto startTime = std::chrono::steady_clock::now();
49 auto elapsed = std::chrono::steady_clock::now() - startTime;
50 double elapsedSec = std::chrono::duration<double>(elapsed).count();
55 targetNodeName.c_str());
62 auto nodeNames =
getNode()->get_node_names();
64 for (
const auto & n : nodeNames)
66 ss <<
" - " << n <<
"\n";
68 if (n == targetNodeName)
75 getLogger(),
"[" <<
getName() <<
"] listing nodes (" << nodeNames.size() <<
")\n"
83 RCLCPP_WARN(
getLogger(),
"CbConnectMicroRosAgent: shutdown requested before node found");
89 getLogger(),
"CbConnectMicroRosAgent: node '%s' detected - starting failsafe health check",
90 targetNodeName.c_str());
96 RCLCPP_ERROR(
getLogger(),
"CbConnectMicroRosAgent: no CpFailsafeFlags component on the client");
105 auto controlReady = [
this]()
112 rclcpp::Rate healthRate(2.0);
115 auto elapsed = std::chrono::steady_clock::now() - startTime;
116 double elapsedSec = std::chrono::duration<double>(elapsed).count();
121 "CbConnectMicroRosAgent: timeout (%.1fs) waiting for health check. "
122 "attitude_invalid=%d, local_altitude_invalid=%d, local_position_invalid=%d, "
123 "heading_good_for_control=%d, velocity_valid=%d",
133 "CbConnectMicroRosAgent: health check: attitude_invalid=%d, "
134 "local_altitude_invalid=%d, local_position_invalid=%d, heading_good_for_control=%d, "
144 RCLCPP_INFO(
getLogger(),
"CbConnectMicroRosAgent: health check passed - posting success");
150 getLogger(),
"CbConnectMicroRosAgent: shutdown requested before health check passed");
CbConnectMicroRosAgent(double timeoutSec=30.0)
CpMicroRosAgent * microRosAgent_
CpFailsafeFlags * failsafeFlags_
CpVehicleLocalPosition * localPosition_
bool isLocalPositionInvalid() const
bool isLocalAltitudeInvalid() const
bool isAttitudeInvalid() const
std::string getNodeName() const
bool isVelocityValid() const
bool isHeadingGoodForControl() const
std::string getName() const
virtual rclcpp::Logger getLogger() const
virtual rclcpp::Node::SharedPtr getNode() const
bool isShutdownRequested()
onEntry is executed in a new thread. However the current state cannot be left until the onEntry threa...