Skip to content

fix(ros2_parser): strip namespace suffix instead of a fixed 5 chars#117

Open
Alvvalencia wants to merge 1 commit intoPlotJuggler:mainfrom
Alvvalencia:fix/namespace-suffix-strip
Open

fix(ros2_parser): strip namespace suffix instead of a fixed 5 chars#117
Alvvalencia wants to merge 1 commit intoPlotJuggler:mainfrom
Alvvalencia:fix/namespace-suffix-strip

Conversation

@Alvvalencia
Copy link
Copy Markdown

Fixes #1060.

CreateSchema() stripped a hard-coded 5 chars to remove "::msg" from a
message's C++ namespace. That works for ::msg and (by coincidence) ::srv,
but mangles action-generated messages whose namespace ends in ::action
(8 chars): e.g. docking::action became docking::a, and downstream lookups
failed with "package not found".

Replace the fixed strip with a suffix check over the three generator
namespaces (::msg, ::srv, ::action), each stripped by its actual length.
Action feedback topics now subscribe cleanly; services unchanged.

`CreateSchema()` used a hard-coded `substr(0, size - 5)` to strip
"::msg" from a message's C++ namespace to recover the package name.
That works for normal messages (`sensor_msgs::msg`) and happens to
work for services (`::srv` is also 5 chars), but it silently mangles
action-generated messages whose namespace ends in `::action` (8 chars).

For a topic like `<pkg>/action/<Action>_FeedbackMessage` the namespace
is `<pkg>::action`. Stripping exactly 5 chars from e.g.
`docking::action` (15 chars) leaves `docking::a` — exactly the
truncated package name reported in #1060. Downstream lookups then
fail with "package not found".

Replace the hard-coded strip with a suffix check over the three known
generator namespaces (`::msg`, `::srv`, `::action`). Each is stripped
by its actual length, so action feedback topics subscribe cleanly and
services stay unchanged.

Closes #1060.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants