بنقرة واحدة
ros2-testing
ROS2 test strategies and patterns with Clean Architecture (Python & C++)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
ROS2 test strategies and patterns 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 Testing |
| description | ROS2 test strategies and patterns with Clean Architecture (Python & C++) |
This skill provides test strategies for ROS2 applications adhering to Clean Architecture principles, covering Unit, Integration, and E2E tests in both Python and C++.
/\
/ \ E2E Tests (Launch Tests / System Tests)
/----\
/ \ Integration Tests (Node / Component Tests)
/--------\
/ \ Unit Tests (Domain / Application Logic)
/--------------\
tests/
├── unit/
│ ├── domain/
│ └── application/
├── integration/
│ └── ros2/
└── e2e/
└── launch_tests/
See the previous version for Python Unit Test examples. They remain valid as domain logic is pure Python.
# tests/integration/ros2/nodes/test_sensor_node.py
import pytest
import rclpy
from rclpy.node import Node
from std_msgs.msg import Float64
@pytest.fixture(scope='module')
def ros_context():
rclpy.init()
yield
rclpy.shutdown()
@pytest.fixture
def test_node(ros_context):
node = Node('test_helper')
yield node
node.destroy_node()
def test_sensor_integration(test_node):
# Verify node behavior by subscribing/publishing
pass
// tests/unit/domain/use_cases/test_robot_controller.cpp
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "domain/use_cases/robot_controller.hpp"
#include "domain/entities/robot_state.hpp"
using namespace domain;
using ::testing::Return;
class MockRobotRepository : public repositories::IRobotRepository {
public:
MOCK_METHOD(entities::RobotState, get_state, (), (override));
MOCK_METHOD(void, set_mode, (entities::RobotMode), (override));
};
TEST(RobotControllerTest, StartFromIdle) {
auto mock_repo = std::make_shared<MockRobotRepository>();
use_cases::RobotControllerUseCase use_case(mock_repo);
EXPECT_CALL(*mock_repo, get_state())
.WillOnce(Return(entities::RobotState{entities::RobotMode::IDLE}));
EXPECT_CALL(*mock_repo, set_mode(entities::RobotMode::ACTIVE));
auto result = use_case.start();
EXPECT_TRUE(result.success);
}
// tests/integration/ros2/test_sensor_node.cpp
#include <gtest/gtest.h>
#include <rclcpp/rclcpp.hpp>
#include "infrastructure/ros2/nodes/sensor_node.hpp"
class SensorNodeTest : public ::testing::Test {
protected:
void SetUp() override {
rclcpp::init(0, nullptr);
node_ = std::make_shared<infrastructure::ros2::nodes::SensorNode>();
}
void TearDown() override {
rclcpp::shutdown();
}
std::shared_ptr<infrastructure::ros2::nodes::SensorNode> node_;
};
TEST_F(SensorNodeTest, Initialization) {
EXPECT_STREQ(node_->get_name(), "sensor_node");
}
You can run GTest executables from launch files to perform system-level tests.
# tests/e2e/launch_tests/system_test.launch.py
from launch import LaunchDescription
from launch_ros.actions import Node
from launch_testing.actions import ReadyToTest
def generate_launch_description():
# Launch system under test
app_node = Node(package='my_robot', executable='main_node')
# Launch GTest runner
test_runner = Node(
package='my_robot',
executable='system_integration_test',
output='screen'
)
return LaunchDescription([
app_node,
test_runner,
ReadyToTest()
])
unittest.mock for Python and gmock for C++.pytest.fixture and GTest SetUp/TearDown to manage ROS2 context (rclpy.init/shutdown).rclcpp::spin_some or wait_for_future to handle async operations.