بنقرة واحدة
ros2-bag-utility
ROS2 bag recording and analysis utilities with Clean Architecture (Python & C++)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
ROS2 bag recording and analysis utilities 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 Bag Utility |
| description | ROS2 bag recording and analysis utilities with Clean Architecture (Python & C++) |
This skill provides guides for programmatic data recording (rosbag2) and replay mechanism adhering to Clean Architecture.
Defines the interface for recording and playback control.
# domain/interfaces/data_recorder.py
class IDataRecorder(ABC):
@abstractmethod
def start_recording(self, config: RecordingConfig) -> bool:
pass
@abstractmethod
def stop_recording(self) -> None:
pass
See previous Python example using rosbag2_py.
Using rosbag2_cpp library.
// infrastructure/ros2/bag/bag_recorder.hpp
#pragma once
#include <rclcpp/rclcpp.hpp>
#include <rosbag2_cpp/writer.hpp>
#include <rosbag2_storage/storage_options.hpp>
namespace infrastructure::ros2::bag {
class BagRecorder {
public:
explicit BagRecorder(rclcpp::Node::SharedPtr node) : node_(node) {}
bool start_recording(const std::string& bag_name, const std::vector<std::string>& topics) {
try {
writer_ = std::make_unique<rosbag2_cpp::Writer>();
rosbag2_storage::StorageOptions storage_options;
storage_options.uri = bag_name;
storage_options.storage_id = "sqlite3";
rosbag2_cpp::ConverterOptions converter_options;
converter_options.input_serialization_format = "cdr";
converter_options.output_serialization_format = "cdr";
writer_->open(storage_options, converter_options);
// Subscribe to topics and write
for (const auto& topic : topics) {
// Determine topic type dynamically or use GenericSubscribe (Humble+)
create_recorder_subscription(topic);
}
is_recording_ = true;
return true;
} catch (const std::exception& e) {
RCLCPP_ERROR(node_->get_logger(), "Failed to open bag: %s", e.what());
return false;
}
}
void stop_recording() {
writer_.reset(); // Closes the bag
subs_.clear();
is_recording_ = false;
}
template<typename T>
void write_message(const std::string& topic, const T& msg) {
if (is_recording_ && writer_) {
auto timestamp = node_->get_clock()->now();
writer_->write(msg, topic, timestamp);
}
}
private:
rclcpp::Node::SharedPtr node_;
std::unique_ptr<rosbag2_cpp::Writer> writer_;
std::vector<rclcpp::SubscriptionBase::SharedPtr> subs_;
bool is_recording_ = false;
void create_recorder_subscription(const std::string& topic) {
// Implementation for generic subscription...
}
};
} // namespace
// infrastructure/ros2/bag/bag_reader.hpp
#include <rosbag2_cpp/reader.hpp>
class BagReader {
public:
explicit BagReader(const std::string& bag_path) {
reader_ = std::make_unique<rosbag2_cpp::Reader>();
reader_->open(bag_path);
}
void read_all() {
while (reader_->has_next()) {
auto bag_message = reader_->read_next();
// Deserialization logic...
}
}
private:
std::unique_ptr<rosbag2_cpp::Reader> reader_;
};
sqlite3 is default, mcap is recommended for performance.cdr.