Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Add Ros Message Type

ASecurity

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 ...

14,461 stars
0 votes
0 copies
0 views
Added 10/6/2026
ai-agentspythongoc++bashnodedocker

Security Analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned 10/6/2026

$npx -y skills add carla-simulator/carla --skill add-ros-message-type --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Add Ros Message Type?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Add Ros Message Type
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/carla-simulator-add-ros-message-type-carla/badge)](https://www.skillsdirectory.com/skills/carla-simulator-add-ros-message-type-carla)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: add-ros-message-type
description: 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.
license: MIT
compatibility: A CARLA checkout whose LibCarla/source/carla/ros2 exists (native ROS 2 branch), Docker running (only for the RIHS01 hash — no local ROS 2 needed), and the toolchain to build LibCarla with --ros2. Editing only; nothing is published or run.
metadata:
  group: ros2
  prerequisites: scripts/check_env.sh
  reference: references/cdr.md
---

# Add a ROS 2 message type

> **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.

CARLA serialises hand-written C++ PODs straight into CDR buffers with Fast-CDR.
**There is no IDL compiler in the build**, so a new type is a five-file manual
change. Skipping any one of them fails in a different way — silently on the wire,
loudly at build, or only on a peer's Jazzy console.

Upstream reference: `Docs/ros2/adding_message_types.md` in the checkout. This
skill adds the preflight, the wrapped hash computation, and the verify loop.

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

The hand-written-POD approach, the Fast-CDR serialize/deserialize pair, the
RIHS01 type hash and the registration step are the same on 0.10.0 — there is
still no IDL codegen.

What differs is the neighbourhood: types live beside a larger set on 0.10.0
(Autoware messages among them), and QoS moved from `PublisherQos.h` to
`QosProfile.h`. If your new type is for a publisher, read [[add-ros-publisher]]
first for the `BasicPublisher` refactor — a type added for a
`CarlaPublisher`-shaped class will not compile there.

## Instructions

```
Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh), clear FAILs
- [ ] Step 2: Get the .msg definition (standard type, or write a carla_msgs one)
- [ ] Step 3: POD struct in types/msg/<Type>.h
- [ ] Step 4: serialize_cdr/deserialize_cdr pair in types/CdrSerialization.h
- [ ] Step 5: RIHS01 hash (bash scripts/type_hash.sh <pkg>/msg/<Type>)
- [ ] Step 6: CdrTopicInfo<> specialization (type_name, type_hash, max_serialized_size)
- [ ] Step 7: CHECK_HASH + hashes entry in test/server/test_type_hash.cpp
- [ ] Step 8: bash scripts/verify.sh   (build + type-hash tests)
```

The five files, in dependency order:

| File | What goes in |
|---|---|
| `types/msg/<Type>.h` | the POD struct, `namespace carla::ros2::msg` |
| `types/CdrSerialization.h` | include + `serialize_cdr`/`deserialize_cdr` overloads |
| `types/CdrTopicInfo.h` | include + `CdrTopicInfo<msg::Type>` specialization |
| `test/server/test_type_hash.cpp` | `CHECK_HASH(Type)` + an entry in `hashes` |
| *(new carla_msgs only)* your `.msg` | the canonical definition the hash is computed from |

### Step 1: Check prerequisites

```bash
bash scripts/check_env.sh
```

### Steps 3-4: struct and serialization

Rules that matter (full patterns and the sequence/string cases in
[`references/cdr.md`](references/cdr.md)):

- Struct lives in `namespace carla::ros2::msg`; includes only `<array>`,
  `<vector>`, `<string>`, `<cstdint>` and sibling `msg/*.h` — **no DDS or
  Fast-CDR headers**.
- Every primitive gets `= 0` / `= 0.0`; fixed arrays are `std::array<T,N>`,
  sequences `std::vector<T>`, nested messages by value.
- Field **order and count must mirror the `.msg` exactly** — CDR is positional,
  so a wrong order produces garbage on the wire with no error anywhere.
- Add the overload pair **after** the overloads of the types it depends on
  (`CdrSerialization.h` is ordered least-to-most dependent, no forward decls).
- Nested `msg::` types call their own overload; `std::string` and `std::array`
  go through `cdr <<`; `std::vector<uint8_t>` is length-prefixed automatically;
  a `std::vector` of structs needs the `uint32_t` length written by hand and
  checked against `kMaxCdrSequenceElements` on read.

### Step 5: the RIHS01 hash

```bash
# standard type — the .msg is pulled out of osrf/ros:jazzy-desktop for you
bash scripts/type_hash.sh sensor_msgs/msg/Imu

# new carla_msgs type — pass your own definition
bash scripts/type_hash.sh carla_msgs/msg/CarlaSpeedometer ./CarlaSpeedometer.msg
```

Prints one `RIHS01_<64 hex>` line (and the definition it hashed, to stderr, so you
can eyeball it against your struct). It refuses to print anything that is not in
that exact format, because a malformed hash pasted into the source only shows up
as a peer-side warning.

> **`Util/ros2/compute_type_hash.sh` is broken as shipped** (verified 2026-08 on
> `ue4-dev` with `osrf/ros:jazzy-desktop`) — four independent faults, so Step 4 of
> the upstream doc cannot work:
>
> 1. the in-container script runs `set -u` then sources `setup.bash`, which
>    dereferences `AMENT_TRACE_SETUP_FILES` → `unbound variable`;
> 2. `--log-base` is passed **after** `--cmake-args`, which swallows it, so CMake
>    gets it → `Unknown argument --log-base`, 0 packages built;
> 3. `docker run` has no `--user`, so its temp workspace becomes root-owned and its
>    own cleanup `rm` fails, making the exit code meaningless;
> 4. it extracts the hash with `jq`, which that image does not have → the
>    misleading `'<type>' not found in <json>`.
>
> `type_hash.sh` runs upstream first and, on failure, retries with a patched
> **temp copy** (plus a mounted python `jq` shim). Your checkout is never modified,
> and the hash still comes from `rosidl`'s own type-description output. With that
> in place `sensor_msgs/msg/Imu` reproduces the value pinned in `CdrTopicInfo.h`
> exactly — which is also the best available self-test of this whole procedure.
> The proper fix is four one-liners upstream.

The hash is what ROS 2 Iron+ compares in the `USER_DATA` QoS during discovery.
Get it wrong or omit it and peers log
`Failed to parse type hash for topic 'rt/...'` — the connection still forms, so
this is easy to miss. Return `nullptr` **only** for a type with no canonical
`.msg`.

### Steps 6-7: registration and test

`type_name()` is the DDS mangled name `<package>::msg::dds_::<TypeName>_` —
trailing underscore included; a mismatch means peers never match the endpoint.
`max_serialized_size()` is a preallocation hint in bytes excluding the 4-byte
encapsulation header (sizing table in the reference). Then add both test entries
— they are what catch a malformed or duplicated hash.

### Step 8: verify

```bash
bash scripts/verify.sh              # make LibCarla ARGS="--ros2" + make check.LibCarla
BUILD_ONLY=1 bash scripts/verify.sh # compile-only fast loop
```

Green tests prove the hash is **well-formed and unique** — not that the wire
format is right. For that, publish the type and read it from a real ROS 2 node
([[visualize-ros-rviz]] `echo`): a field-order bug shows up there and nowhere
else.

## Examples

**Example 1: support an existing ROS type CARLA lacks**

User says: "make CARLA publish `nav_msgs/Odometry` for the ego"

`Odometry.h` already exists in `types/msg/` — check first. If a type is missing,
this skill adds it; then [[add-ros-publisher]] does the publishing side. Adding a
type alone changes no topic.

**Example 2: a new carla_msgs type**

User says: "add a CarlaSpeedometer message with the ego speed"

Write `CarlaSpeedometer.msg` (`std_msgs/Header header` + `float32 speed`) →
POD → overloads → `type_hash.sh carla_msgs/msg/CarlaSpeedometer ./…msg` →
`CdrTopicInfo` (`carla_msgs::msg::dds_::CarlaSpeedometer_`) → tests → verify.

**Example 3: the type-hash warning**

User says: "peers log `Failed to parse type hash` for one of my topics"

That type's `type_hash()` returns `nullptr` or a malformed string. Recompute with
`type_hash.sh` and paste it in; re-run `verify.sh`.

## Troubleshooting

**Problem: `compute_type_hash.sh` fails inside Docker on `colcon build`**
Cause: the `.msg` depends on a package not present in the `jazzy` image.
Solution: add the dependency to the workspace, or use a newer image
(`ROS_IMAGE=osrf/ros:<tag>-desktop bash scripts/type_hash.sh …`).

**Problem: the type builds and publishes, but subscribers get garbage**
Cause: field order/type mismatch between the POD and the `.msg` — CDR is
positional and carries no field names.
Solution: diff the struct against the `.msg` line by line; the reference has a
side-by-side example.

**Problem: `make check.LibCarla` fails on a duplicate hash**
Cause: the same `RIHS01_…` string registered for two types (copy-paste).
Solution: recompute per type; the uniqueness test exists for exactly this.

**Problem: build fails with a Fast-CDR error in the new overload**
Cause: an overload placed before the types it depends on, or a nested type
serialised with `cdr <<` instead of `serialize_cdr`.
Solution: move it below its dependencies; nested `msg::` types always recurse.

## Outputs

Edited sources in the checkout (five files) and a green `check.LibCarla`. No
topic changes on their own — publishing the new type is [[add-ros-publisher]].

Wire-format detail (CDR encoding, the sizing table, sequence rules, hash
semantics) in [`references/cdr.md`](references/cdr.md).

Attribution

carla-simulatorcarla-simulator
View sourceSee grades on GitHubMore from carla-simulator →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698461 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →