Ask Your Question
0

ros1_bridge fails to generate service when custom message from the same package is used

asked 2019-12-31 14:31:12 -0500

mr.chippy gravatar image

updated 2020-01-02 21:22:42 -0500

I am trying to compile the ros1_bridge package with several custom interface packages. It works fine for messages and services, but as soon as I try it on a service that includes a custom message defined in the same interface package it won't convert the service. I have recreated the issue with this workspace structure and source:

├── ros1_bridge_ws
│   └── src
│       └── ros1_bridge
│           │
│          ...
├── ros1_ws
│   └── src
│       └── ros1_test
│           ├── CMakeLists.txt
│           ├── msg
│           │   ├── CustomMessage.msg
│           │   └── CustomMessage2.msg
│           ├── package.xml
│           └── srv
│               └── Test.srv
└── ros2_ws
    └── src
        └── ros2_test
            ├── CMakeLists.txt
            ├── include
            │   └── ros2_test
            ├── msg
            │   ├── CustomMessage.msg
            │   └── CustomMessage2.msg
            ├── package.xml
            ├── ros1_mapping_rules.yaml
            ├── src
            └── srv
                └── Test.srv

CustomMessage.msg

string text
uint8 value

CustomMessage2.msg

string text
uint8 value
CustomMessage custom_message

Test.srv

uint8 test1
CustomMessage test3
---
uint16 test2

ros1_mapping_rules.yaml

-
  ros1_package_name: 'ros1_test'
  ros2_package_name: 'ros2_test'

ROS1 CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(ros1_test)

find_package(catkin REQUIRED COMPONENTS
  message_generation
  std_msgs
)

add_message_files(
  FILES
  CustomMessage.msg
  CustomMessage2.msg
)

add_service_files(
  FILES
  Test.srv
)


generate_messages(
  DEPENDENCIES
  std_msgs
)

catkin_package(
)


include_directories(
  ${catkin_INCLUDE_DIRS}
)

ROS2 CMakeList.txt

cmake_minimum_required(VERSION 3.5)
project(ros2_test)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(std_msgs REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

rosidl_generate_interfaces(ros2_test
  "msg/CustomMessage.msg"
  "msg/CustomMessage2.msg"
  "srv/Test.srv"
  DEPENDENCIES std_msgs builtin_interfaces
)

install(
  FILES ros1_mapping_rules.yaml
  DESTINATION share/${PROJECT_NAME}
)

ament_package()

Output from "ros2 run ros1_bridge dynamic_bridge --print-pairs"

Supported ROS 2 <=> ROS 1 message type conversion pairs:
  - 'actionlib_msgs/msg/GoalID' (ROS 2) <=> 'actionlib_msgs/GoalID' (ROS 1)
  - 'actionlib_msgs/msg/GoalStatus' (ROS 2) <=> 'actionlib_msgs/GoalStatus' (ROS 1)
  - 'actionlib_msgs/msg/GoalStatusArray' (ROS 2) <=> 'actionlib_msgs/GoalStatusArray' (ROS 1)
  - 'builtin_interfaces/msg/Duration' (ROS 2) <=> 'std_msgs/Duration' (ROS 1)
  - 'builtin_interfaces/msg/Time' (ROS 2) <=> 'std_msgs/Time' (ROS 1)
  - 'diagnostic_msgs/msg/DiagnosticArray' (ROS 2) <=> 'diagnostic_msgs/DiagnosticArray' (ROS 1)
  - 'diagnostic_msgs/msg/DiagnosticStatus' (ROS 2) <=> 'diagnostic_msgs/DiagnosticStatus' (ROS 1)
  - 'diagnostic_msgs/msg/KeyValue' (ROS 2) <=> 'diagnostic_msgs/KeyValue' (ROS 1)
  - 'gazebo_msgs/msg/ContactState' (ROS 2) <=> 'gazebo_msgs/ContactState' (ROS 1)
  - 'gazebo_msgs/msg/ContactsState' (ROS 2) <=> 'gazebo_msgs/ContactsState' (ROS 1)
  - 'gazebo_msgs/msg/LinkState' (ROS 2) <=> 'gazebo_msgs/LinkState' (ROS 1)
  - 'gazebo_msgs/msg/LinkStates' (ROS 2) <=> 'gazebo_msgs/LinkStates' (ROS 1)
  - 'gazebo_msgs/msg/ModelState' (ROS 2) <=> 'gazebo_msgs/ModelState' (ROS 1)
  - 'gazebo_msgs/msg/ModelStates' (ROS 2) <=> 'gazebo_msgs/ModelStates' (ROS 1)
  - 'gazebo_msgs/msg/ODEJointProperties' (ROS 2) <=> 'gazebo_msgs/ODEJointProperties' (ROS 1)
  - 'gazebo_msgs/msg/ODEPhysics' (ROS 2) <=> 'gazebo_msgs/ODEPhysics' (ROS 1)
  - 'gazebo_msgs/msg/WorldState' (ROS 2) <=> 'gazebo_msgs/WorldState' (ROS 1)
  - 'geometry_msgs/msg/Accel' (ROS 2) <=> 'geometry_msgs/Accel' (ROS 1)
  - 'geometry_msgs/msg/AccelStamped' (ROS 2) <=> 'geometry_msgs/AccelStamped' (ROS 1)
  - 'geometry_msgs/msg/AccelWithCovariance' (ROS 2) <=> 'geometry_msgs/AccelWithCovariance' (ROS 1)
  - 'geometry_msgs/msg/AccelWithCovarianceStamped' (ROS 2) <=> 'geometry_msgs/AccelWithCovarianceStamped' (ROS 1)
  - 'geometry_msgs/msg/Inertia' (ROS 2) <=> 'geometry_msgs/Inertia' (ROS 1 ...
(more)
edit retag flag offensive close merge delete

Comments

Please consider sharing your ready-to-be-build code if you want others to give it a try. What does the dynamic_bridge output with the option --print-pairs?

Dirk Thomas gravatar image Dirk Thomas  ( 2020-01-02 16:42:41 -0500 )edit

Thanks for the reply. I have edited the post to contain the output of --print-pairs, but I should have been more clear, when I say that the Test service doesn't show up I was talking about the output of --print-pairs. As soon as I remove the reference to the custom message from the service, the service is converted properly. I have also attached the source that I am using in this example.

mr.chippy gravatar image mr.chippy  ( 2020-01-02 21:23:02 -0500 )edit
1

Your source snippets are not complete (e.g. no package manifests). I am willing to clone and build the packages but no creating all these files by copy-n-pasting their content and imagining the missing pieces.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-01-02 21:46:16 -0500 )edit

Please see the edited message, I updated it to include a zip folder of the ready to be built code as I have been testing it. Here is the link again for convenience https://drive.google.com/open?id=1K1V...

mr.chippy gravatar image mr.chippy  ( 2020-01-03 15:24:46 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-01-10 16:09:55 -0500

Dirk Thomas gravatar image

When a service contains fields which are only mappable due to a custom rule in mapping file (as in your case) the service was being skipped by the ros1_bridge. This is certainly a bug which should be resolved by ros2/ros1_bridge#234.

edit flag offensive delete link more

Comments

This does not seem to be solved yet. I built the bridge with different names for the ros1 and ros2 packages and created the corresponding yaml file with mappings. All custom messages can be generated but only the services which use a custom msg are not.

Is it neccesary to have the same names for packages in ros1 and 2? If yes, this is still a bug.

readme on ros1_bridge also says "A custom field mapping is currently not supported for services."

Andreas Z gravatar image Andreas Z  ( 2021-09-22 12:44:52 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-12-31 14:31:12 -0500

Seen: 300 times

Last updated: Jan 10 '20