Skip to content

mrpt-msgs causing generate-ros-messages to fail #1388

@techtasie

Description

@techtasie

Description

  • Library Version: 1.8.1
  • ROS Version: Humble
  • Platform / OS: Ubuntu 22.04

Steps To Reproduce

sudo apt install ros-humble-mrpt-msgs
npx generate-ros-messages

Expected Behavior
Build succeeds

Actual Behavior

❯ npx generate-ros-messages
Start generation of ROS2 JavaScript messages...
See details https://github.com/RobotWebTools/rclnodejs?tab=readme-ov-file#idl-message-generation for generating from .idl files
Caught error: TypeError: Cannot read properties of null (reading '1')

This is caused by packages.js matching the subfolder. MRPT puts messages into a subfolder containing a hyphen.

❯ ls /opt/ros/humble/share/mrpt_msgs/
cmake        local_setup.bash  local_setup.sh   msg         msg-ros2     package.xml
environment  local_setup.dsv   local_setup.zsh  msg-common  package.dsv  srv

A possible fix would be this patch:

diff --git a/rosidl_gen/packages.js b/rosidl_gen/packages.js
index 02dc9c6..138c65f 100644
--- a/rosidl_gen/packages.js
+++ b/rosidl_gen/packages.js
@@ -33,7 +33,7 @@ function getPackageName(filePath, amentExecuted) {
   }

   if (amentExecuted) {
-    return filePath.match(/\w+\/share\/(\w+)\//)[1];
+    return filePath.match(/[^/]+\/share\/([^/]+)\//)[1];
   }

   let folders = path.parse(filePath).dir.split('/');
@@ -52,7 +52,7 @@ function getSubFolder(filePath, amentExecuted) {
   }

   if (amentExecuted) {
-    return filePath.match(/\w+\/share\/\w+\/(\w+)\//)[1];
+    return filePath.match(/[^/]+\/share\/[^/]+\/([^/]+)\//)[1];
   }
   // If the |amentExecuted| equals to false, the file's extension will be assigned as
   // the name of sub folder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions