本文へ移動
cccskills
無料GitHub で公開

add-ros-publisher

Adds a new topic to CARLA's native ROS 2 interface — a publisher (BasePublisher + PublisherImpl, topic suffix, QoS, registration in ROS2::GetOrCreateSensor, a ProcessDataFrom* entry point and its call site in the UE4 plugin) or a subscriber that lets ROS drive an actor. Also covers adding a middleware (RMW) behind IPublisherMiddleware. Use when the user asks to "publish X to ROS from CARLA", "add a ROS topic/publisher/subscriber", "make the obstacle/lane-invasion sensor publish", "add odometry to ROS", or "add another RMW".

インストール方法を見る

含まれるファイル(5)

  • SKILL.md11.4 KB
  • references/layers.md6.7 KB
  • scripts/check_env.sh3.3 KB
  • scripts/env.sh2.2 KB
  • scripts/verify.sh1.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Add a ROS 2 publisher or subscriber

Paths. scripts/… and references/… below are relative to the directory holding this SKILL.md. Your working directory is the user's project, not that directory, so prefix them with its absolute path or the command is not found.

A topic exists only when four things line up: a message type, a publisher object, a registration so something creates it, and a call site that feeds it data. Miss the last one and everything compiles while the topic never appears.

UE4 sensor/actor  --ProcessDataFrom*-->  ROS2 (dispatch, ROS2.cpp)
                                          |  GetOrCreateSensor / RegisterVehicle
                                          v
                            Carla<X>Publisher  (topic suffix + QoS)
                                          v
                            PublisherImpl<Traits>  -> MiddlewareFactory
                                          v
                     FastDDS | CycloneDDS | Zenoh middleware

Message types are [[add-ros-message-type]]; this skill is everything below the type.

On CARLA 0.10.0 (the UE5 line: 5.5 and 5.8)

The publisher layer was refactored on 0.10.0, so the file you copy from differs. The right-hand column is UE 5.8; UE 5.5 has the same BasicPublisher refactor but no middleware/ directory, so its QoS type is the pre-QosProfile.h one and it has none of the Autoware rows ([[check-ue5-limitations]]):

0.9.x0.10.0
base class to inheritCarlaPublisherBasicPublisher (and BasicSubscriber / BasicListener)
QoS typePublisherQos.hQosProfile.h
middlewareIPublisherMiddleware implssame, plus ActiveMiddleware.{h,cpp}
map publisherCarlaMapPublisherremoved — do not model a new publisher on it
DVS cameraCarlaDVSPublisherCarlaDVSCameraPublisher
Autoware—AutowareGNSSPublisher, AutowareVehicleStatusPublisher, AutowareControlSubscriber, AutowareSteeringCompensation.h

0.10.0 also factors the per-sensor maths out of the publishers into reusable headers you should use rather than re-derive: CameraIntrinsics, ImuMath, DvsEventEncoding, OpticalFlowEncoding, PointCloudFieldsLayout, RadarPolarToCartesian, TransformQuaternion, and AckermannControlConversion on the subscriber side. A new listeners/ directory holds BasicListener.

The registration point, the ProcessDataFrom* entry points and the UE plugin call sites work the same way on both.

Instructions

Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh), clear FAILs
- [ ] Step 2: Confirm the message type exists in types/msg (else add-ros-message-type)
- [ ] Step 3: Write publishers/Carla<X>Publisher.h (+ .cpp for the Write logic)
- [ ] Step 4: Register it — GetOrCreateSensor case, or RegisterVehicle/Actor
- [ ] Step 5: Add the ProcessDataFrom<X> entry point in ROS2.h/.cpp
- [ ] Step 6: Call it from the UE4 side, inside `#if defined(WITH_ROS2)`
- [ ] Step 7: bash scripts/verify.sh, then rebuild the plugin (build-carla-ue4 ROS2=1)
- [ ] Step 8: Prove the topic — visualize-ros-rviz topics / hz

Step 3: the publisher

Copy the shape of the simplest existing one (CarlaGNSSPublisher): derive from BasePublisher, hold a PublisherImpl<Traits>, Init the topic in the constructor, implement Write(...) and Publish().

class CarlaFooPublisher : public BasePublisher {
  public:
    struct FooMsgTraits { using msg_type = msg::Foo; };   // the only type binding

    CarlaFooPublisher(std::string base_topic_name, std::string frame_id):
      BasePublisher(base_topic_name, frame_id),
      _impl(std::make_shared<PublisherImpl<FooMsgTraits>>()) {
        // Suffix decides the topic; NO suffix means "publish on the base name",
        // which is what IMU/GNSS/collision do. Pass PublisherQos::SensorData()
        // for high-rate streams so a slow subscriber cannot stall the sim.
        if (!_impl->Init(GetBaseTopicName() + "/foo", PublisherQos::SensorData())) {
          log_warning("CarlaFooPublisher: Init failed for topic: ", GetBaseTopicName(), "/foo");
        }
    }
    bool Publish() { return _impl->Publish(); }
    bool Write(int32_t seconds, uint32_t nanoseconds, /* payload */);
  private:
    std::shared_ptr<PublisherImpl<FooMsgTraits>> _impl;
};

Header in publishers/, Write body in the matching .cpp if it is more than a few lines. No CMake edit is needed — LibCarla/cmake/ros2/CMakeLists.txt globs publishers/*.cpp, subscribers/*.cpp, types/*.cpp, middleware/*/*.cpp. A brand-new subdirectory does need a glob entry.

Init failure is a warning, not an error: a typo'd topic leaves a live publisher object that publishes nowhere. Watch for that line in the server log.

Steps 4-6: wire it up

ForRegister inFeed from
a sensora case ESensors::<X>: in ROS2::GetOrCreateSensorProcessDataFrom<X> called in that sensor's UE4 class
a vehicle/actor streamROS2::RegisterVehicle / RegisterActorthe actor's tick or an RPC path
a subscriber (ROS drives CARLA)RegisterVehicle's subscriber listProcessMessages(callback) → ActorROS2Handler

The dispatch function is the seam: it takes the raw CARLA data, casts the base publisher to the concrete type, Writes, Publishes, and (for sensors) also updates the TF publisher. Copy ProcessDataFromGNSS — it is the shortest complete example.

On the UE4 side the call must sit inside #if defined(WITH_ROS2) and be guarded by ROS2->IsEnabled(); the transform passed is relative to the attach parent when there is one:

#if defined(WITH_ROS2)
auto ROS2 = carla::ros2::ROS2::GetInstance();
if (ROS2->IsEnabled()) {
  AActor* ParentActor = GetAttachParentActor();
  auto Transform = ParentActor ? GetActorTransform().GetRelativeTransform(ParentActor->GetActorTransform())
                               : GetActorTransform();
  ROS2->ProcessDataFromFoo(Stream.GetSensorType(), Transform, Data, this);
}
#endif

Steps 7-8: verify

bash scripts/verify.sh                          # LibCarla + its tests, with --ros2
ROS2=1 bash ../../ue4/build-carla-ue4/scripts/06_build_editor.sh   # the plugin call site
# then, against a running ROS 2 server:
bash ../visualize-ros-rviz/scripts/ros_view.sh topics
bash ../visualize-ros-rviz/scripts/ros_view.sh hz /carla/<actor>/foo

verify.sh proves it compiles and the middleware layer still passes its tests. Only hz/echo proves the topic. A publisher can build, register, and still be silent: the most common reasons are the sensor not being enabled for ROS ([[create-sensor]] --ros), a UE4 call site that never runs, and a sensor whose Tick is skipped because nothing listens.

Sensors with no publisher yet

ROS2::GetOrCreateSensor deliberately returns nullptr for these, so they are the natural targets — and each already has a ProcessDataFrom* or needs one:

SensorNote
other.lane_invasionCarlaLineInvasion message type already exists
other.obstacleProcessDataFromObstacleDetection exists in ROS2.h
other.rssno message type yet
world observerhigh volume; think before publishing

Adding a middleware (RMW)

Same layer, one level down: implement IPublisherMiddleware / ISubscriberMiddleware, add the include + case in MiddlewareFactory, a Middleware enum value and its MiddlewareFromString mapping, and a CARLA_ROS2_MIDDLEWARE_<NAME> compile definition in LibCarla/cmake/ros2/CMakeLists.txt (all three are defined at once, so IsMiddlewareAvailable answers correctly at run time). Extend test_ros2_middleware.cpp. Per-RMW quirks — Zenoh's router and wire format, CycloneDDS's sertype, FastDDS's shared participant — are in references/layers.md.

Examples

Example 1: publish the obstacle sensor

User says: "make the obstacle detection sensor publish to ROS"

CarlaLineInvasion/a suitable type exists → write CarlaObstaclePublisher → replace the nullptr case for ESensors::ObstacleDetectionSensor → fill in ProcessDataFromObstacleDetection (declared already) → the call site in ObstacleDetectionSensor.cpp already exists → verify → hz.

Example 2: let ROS steer via a new command topic

User says: "add a ROS topic to set the ego's target speed"

Type first ([[add-ros-message-type]]) → subscriber modelled on AckermannControlSubscriber → register it in RegisterVehicle → extend ROS2CallbackData and ActorROS2Handler to apply it → verify → ros2 topic pub.

Example 3: a fourth RMW

User says: "add support for another DDS implementation"

Follow "Adding a middleware": interface pair, factory case, enum + string, CMake definition, test. No publisher changes at all — that is the point of the layer.

Troubleshooting

Problem: it all compiles but the topic never appears Cause: usually the call site, not the publisher — the #if defined(WITH_ROS2) block is missing, unreachable, or the plugin was rebuilt without ROS2=1. Solution: confirm Ros2 ON in Config/OptionalModules.ini, rebuild step 06 with ROS2=1, then check the sensor is enable_for_ros-ed.

Problem: PublisherImpl: Failed to create middleware publisher Cause: MiddlewareFactory has no case for the active middleware, or the RMW is not compiled in. Solution: check IsMiddlewareAvailable and the CARLA_ROS2_MIDDLEWARE_* definitions in LibCarla/cmake/ros2/CMakeLists.txt.

Problem: Init failed for topic: … in the server log, everything else fine Cause: an invalid topic name (empty ros_name, double slash) — Init only warns. Solution: fix the name; remember unnamed actors become actor<id>.

Problem: subscriber never receives, publisher works Cause: QoS mismatch (the peer is reliable+transient_local against a volatile publisher), or the topic string differs by a suffix. Solution: visualize-ros-rviz info <topic> shows endpoint counts and QoS on both sides.

Problem: a new .cpp is not compiled Cause: it is in a new subdirectory; the CMake glob lists directories explicitly. Solution: add the glob line in LibCarla/cmake/ros2/CMakeLists.txt.

Outputs

Edited sources in the checkout, a green check.LibCarla, and — after the plugin rebuild — a new topic visible from ROS 2.

Layer-by-layer detail (publisher/subscriber contracts, QoS profiles, dispatch, the middleware interfaces and their quirks) in references/layers.md.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Adds a new ROS 2 message type to CARLA's native ROS 2 interface — the hand-written POD struct under LibCarla/source/carla/ros2/types/msg, its Fast-CDR serialize/deserialize pair, the RIHS01 type hash computed in Docker, the CdrTopicInfo registration and the type-hash test. Use when the user asks to "add a ROS message type", "support sensor_msgs/X in CARLA", "add a carla_msgs type", "why is my type hash warning appearing", or needs a message CARLA does not publish yet. There is no IDL codegen — every step is manual.

日本語の概要は準備中です。原文の説明を表示しています。

carla-simulator/carla-agentic-tools42026年9月12日 更新

Reads and summarises ScenarioRunner output — the criteria pass/fail tables from --output/--file, the machine-readable --json and --junit result files, and the criteria JSON written alongside a --record recording — and runs the metrics module (metrics_manager.py) to compute custom measurements over a recorded run offline, without the simulator. Use when the user asks "did the scenario pass", "why did it fail", "summarise these results", "compare these runs", or wants distance/speed/lane metrics from a recording.

日本語の概要は準備中です。原文の説明を表示しています。

carla-simulator/carla-agentic-tools42026年9月12日 更新

Gets actor and level 3D bounding boxes and projects them into a camera image as 2D boxes — the dataset-annotation workflow. Lists box geometry, draws 3D boxes in the world via debug, or captures one camera frame and writes an annotated PNG plus a JSON of 2D boxes for matching actors. Use when the user asks to "get bounding boxes", "draw boxes around the cars", "project boxes onto the camera", or "generate a detection dataset / annotations".

日本語の概要は準備中です。原文の説明を表示しています。

carla-simulator/carla-agentic-tools42026年9月12日 更新

Builds CARLA (branch ue4-dev, Unreal Engine 4.26) from source on Linux end-to-end — UE4 fork, the Carla server (editor C++ modules), the LibCarla Python client wheel, and content — then verifies them against a from-source server. Optionally builds the native ROS 2 interface in (ROS2=1 → --ros2, Fast-DDS/CycloneDDS/Zenoh), which is compile-time only and cannot be enabled later. Use when the user asks to "build CARLA from source", "compile CARLA ue4-dev", "set up CARLA on Ubuntu (incl. 24.04)", "build CARLA with ROS2 support", or "produce a CARLA server + client wheel". Cooking a distributable Dist/ package is a separate skill (package-carla-ue4); running the build is run-carla-server.

日本語の概要は準備中です。原文の説明を表示しています。

carla-simulator/carla-agentic-tools42026年9月12日 更新

Builds CARLA on Unreal Engine 5.8 from the ue58-dev branch using its CMake build system — configure a preset, then build the carla-unreal / carla-unreal-editor / carla-python-api-install / launch targets — with ROS 2, DLSS, RSS and cook-scope options, and the engine-side build of the CarlaUnreal UE 5.8 fork. There is no Makefile and no Util/BuildTools in this tree, so every UE4 `make` recipe is invalid here. Use when the user asks to "build CARLA UE5", "build ue58-dev", "compile CARLA with cmake", "rebuild the Python API", or hits a CMake configure or target failure.

日本語の概要は準備中です。原文の説明を表示しています。

carla-simulator/carla-agentic-tools42026年9月12日 更新

Create, migrate, improve, or debug detailed vehicle assets for CARLA using Blender and Unreal, including reference-based geometry, materials, wheels, physics, lights, and runtime validation. Use for vehicle asset authoring rather than ordinary traffic spawning or map decoration.

日本語の概要は準備中です。原文の説明を表示しています。

carla-simulator/carla-agentic-tools42026年9月12日 更新

carla-simulator のスキルをすべて見る

このスキルの問題を報告する