بنقرة واحدة
ros2-diagnostics
ROS2 Diagnostics and Health Monitoring with Clean Architecture (Python & C++)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
ROS2 Diagnostics and Health Monitoring with Clean Architecture (Python & C++)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Author a new asset for this .claude/ template — a rule, skill, slash command, or sub-agent — following the project's conventions and wiring it into the CLAUDE.md / README.md indexes. Trigger when the user wants to add or extend a command, skill, agent, or rule (make the template itself extensible).
Bootstrap a complete ROS 2 colcon workspace from scratch — directory layout, .gitignore, top-level README, this .claude/ config, an interfaces package and a first Clean Architecture package, and a bringup package. Trigger when the user asks to create a new workspace / start a new ROS 2 project from zero.
Scaffold a Behavior Tree leaf node — plain BehaviorTree.CPP (SyncActionNode / StatefulActionNode / ConditionNode) or a BehaviorTree.ROS2 wrapper (RosActionNode / RosServiceNode / RosTopicPubNode / RosTopicSubNode) — with ports, factory/plugin registration, and XML v4 usage. Trigger when the user asks to write a behavior-tree node (not Nav 2-specific).
Scaffold a ros2_control hardware component (SystemInterface / ActuatorInterface / SensorInterface) and its bringup — the plugin (on_init/on_configure/on_activate, RT-safe read()/write()), URDF <ros2_control> wiring, controllers.yaml + launch, pluginlib export. Trigger when the user asks to integrate hardware or bring up a robot under ros2_control.
Scaffold or extend a ros2_control controller or broadcaster (ControllerInterface / ChainableControllerInterface) — base-class choice, command/state interface configuration, lifecycle, real-time-safe update(), generate_parameter_library, pluginlib export, tests. Trigger when the user asks to write a ros2_control controller or broadcaster.
Bridge a VDA 5050 v3.0.0 fleet-control interface (MQTT/JSON) onto Nav 2 under Clean Architecture — domain entities, MQTT/Nav 2 adapters behind ports, order→NavigateThroughPoses mapping, state aggregation, action handlers. Trigger when the user asks to build or extend a VDA 5050 connector / fleet bridge.
| name | ROS2 Diagnostics |
| description | ROS2 Diagnostics and Health Monitoring with Clean Architecture (Python & C++) |
This skill demonstrates how to integrate standard ROS2 diagnostics tools for health monitoring within a Clean Architecture.
# domain/entities/health.py
class HealthLevel(Enum):
OK = 0
WARN = 1
ERROR = 2
STALE = 3
@dataclass
class ComponentHealth:
name: str
level: HealthLevel
message: str
values: dict
See previous Python example using diagnostic_updater.
Using diagnostic_updater package in C++.
// infrastructure/ros2/diagnostics/diagnostics_manager.hpp
#pragma once
#include <rclcpp/rclcpp.hpp>
#include <diagnostic_updater/diagnostic_updater.hpp>
#include "domain/interfaces/diagnostics_port.hpp"
namespace infrastructure::ros2::diagnostics {
class DiagnosticsManager {
public:
explicit DiagnosticsManager(rclcpp::Node::SharedPtr node)
: node_(node), updater_(node) {
updater_.setHardwareID(node->get_name());
}
void register_monitor(const std::string& name,
std::function<void(diagnostic_updater::DiagnosticStatusWrapper&)> callback) {
updater_.add(name, callback);
}
// Example callback wrapper for domain entities
void check_component(diagnostic_updater::DiagnosticStatusWrapper& stat) {
// Retrieve health from domain service
// auto health = domain_service_->get_health();
// stat.summary(health.level, health.message);
// stat.add("temp", health.value);
}
private:
rclcpp::Node::SharedPtr node_;
diagnostic_updater::Updater updater_;
};
} // namespace
// infrastructure/ros2/diagnostics/frequency_monitor.hpp
#include <diagnostic_updater/publisher.hpp> // For TopicDiagnostic
class FrequencyMonitor {
public:
FrequencyMonitor(diagnostic_updater::Updater& updater,
const std::string& topic_name,
double min_freq, double max_freq) {
diagnostic_updater::FrequencyStatusParam freq_param(&min_freq, &max_freq, 0.1, 10);
monitor_ = std::make_unique<diagnostic_updater::HeaderlessTopicDiagnostic>(
topic_name, updater, freq_param);
}
void tick() {
monitor_->tick();
}
private:
std::unique_ptr<diagnostic_updater::HeaderlessTopicDiagnostic> monitor_;
};
// application/services/motor_controller.cpp
void MotorController::check_temp(diagnostic_updater::DiagnosticStatusWrapper& stat) {
double temp = read_temp();
if (temp > 80.0) {
stat.summary(diagnostic_msgs::msg::DiagnosticStatus::ERROR, "Overheating");
} else {
stat.summary(diagnostic_msgs::msg::DiagnosticStatus::OK, "Normal");
}
stat.add("temp", temp);
}
TopicDiagnostic to monitor publication rates.