eProsima/Integration-Service

Seg Fault using ROS1-ROS2 bridge with BatteryState or PoseWithCovarianceStamped message type

Opened this issue · 1 comments

I'm experiencing a seg fault with using the integration service for a ROS1-ROS2 bridge. I am experiencing issues with bridging a BatteryState or PoseWithCovarianceStamped message from ROS1 to ROS2.

Ubuntu 20.04 Server
ROS 1 noetic
ROS 2 foxy
Integration Service commit: bed72ea
ROS1-SH commit: 0fd48809b31935c1891bd52e342e617efa401e09
ROS2-SH commit: 60b8e38bae7d994e50e663fd6276b5217b44cd06

battery.yaml

systems:
  ros1: {type: ros1}
  ros2: {type: ros2}

routes:
  ros1_to_ros2: { from: ros1, to: ros2 }
  ros2_to_ros1: { from: ros2, to: ros1 }

topics
  battery_status: { type: "sensor_msgs/BatteryState", route: ros1_to_ros2 }

Publishing of battery topic:

rostopic pub /battery_status sensor_msgs/BatteryState "header:
  seq: 0
  stamp: {secs: 0, nsecs: 0}
  frame_id: ''
voltage: 0.0
temperature: 0.0
current: 0.0
charge: 0.0
capacity: 0.0
design_capacity: 0.0
percentage: 0.0
power_supply_status: 0
power_supply_health: 0
power_supply_technology: 0
present: false
cell_voltage: [0]
cell_temperature: [0]
location: ''
serial_number: ''" 
publishing and latching message. Press ctrl-C to terminate

Running the integration service produces this error when publishing a default battery state message.

integration-service battery.yaml 
[ERROR] [1649126163.852714690]: [registerPublisher] Failed to contact master at [localhost:11311].  Retrying...
[ INFO] [1649126167.733397803]: Connected to master at [localhost:11311]
[Integration Service][INFO] [is::sh::ROS1] Created node '/is_ros1_node__1649126163847650554'
[Integration Service][INFO] [is::sh::ROS2] Created node '/is_ros2_node_1804289383' with Domain ID: 18446744073709551615
[Integration Service][INFO] [is::sh::ROS2] Configured!
[Integration Service][INFO] [is::sh::ROS2] Creating entity using the default QoS.
[Integration Service][INFO] [is::sh::ROS2] Created publisher for topic 'battery_status' with type 'sensor_msgs/BatteryState' on node '/is_ros2_node_1804289383'
[Integration Service][INFO] [is::core::Config] [ros2 SystemHandle] Produced a publisher for the topic 'battery_status', with message type 'sensor_msgs/BatteryState'.
[Integration Service][INFO] [is::sh::ROS1] Created subscription for topic 'battery_status' with type 'sensor_msgs/BatteryState' on node '/is_ros1_node__1649126163847650554'
[Integration Service][INFO] [is::core::Config] [ros1 SystemHandle] Subscribed to topic 'battery_status', with message type 'sensor_msgs/BatteryState'.
[Integration Service][INFO] [is::sh::ROS1] Receiving message from ROS 1 for topic 'battery_status'
[XTYPES]: /home/user/is_ws/install/xtypes/include/xtypes/DynamicData.hpp:973 - Assertion failed with message: Expected type 'bool' but 'uint8_t' received while setting value.

Aborted (core dumped)

The same goes for pose with covariance stamped but with a different error:

systems:
  ros1: {type: ros1}
  ros2: {type: ros2}

routes:
  ros1_to_ros2: { from: ros1, to: ros2 }
  ros2_to_ros1: { from: ros2, to: ros1 }

topics:
  posecov: {type: geometry_msgs/PoseWithCovarianceStamped, route: ros1_to_ros2}
rostopic pub /posecov geometry_msgs/PoseWithCovarianceStamped "header:
  seq: 0
  stamp:
    secs: 0
    nsecs: 0
  frame_id: ''
pose:
  pose:
    position: {x: 0.0, y: 0.0, z: 0.0}
    orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0]" 
publishing and latching message. Press ctrl-C to terminate
integration-service posecov.yaml 
[Integration Service][INFO] [is::sh::ROS1] Created node '/is_ros1_node__1649128437485939372'
[Integration Service][INFO] [is::sh::ROS2] Created node '/is_ros2_node_1804289383' with Domain ID: 18446744073709551615
[Integration Service][INFO] [is::sh::ROS2] Configured!
[Integration Service][INFO] [is::sh::ROS2] Creating entity using the default QoS.
[Integration Service][INFO] [is::sh::ROS2] Created publisher for topic 'posecov' with type 'geometry_msgs/PoseWithCovarianceStamped' on node '/is_ros2_node_1804289383'
[Integration Service][INFO] [is::core::Config] [ros2 SystemHandle] Produced a publisher for the topic 'posecov', with message type 'geometry_msgs/PoseWithCovarianceStamped'.
[Integration Service][INFO] [is::sh::ROS1] Created subscription for topic 'posecov' with type 'geometry_msgs/PoseWithCovarianceStamped' on node '/is_ros1_node__1649128437485939372'
[Integration Service][INFO] [is::core::Config] [ros1 SystemHandle] Subscribed to topic 'posecov', with message type 'geometry_msgs/PoseWithCovarianceStamped'.
[Integration Service][INFO] [is::sh::ROS1] Receiving message from ROS 1 for topic 'posecov'
[XTYPES]: /home/momentum/is_ws/install/xtypes/include/xtypes/DynamicData.hpp:177 - Assertion failed with message: operator [0] is out of bounds.

Aborted (core dumped)

I encountered the same issue when trying to prototype a bridge from ROS1 Melodic to FastDDS for can_msgs/Frame type.

I got similar assertion failures / core dumps as @limjizhengshawn .

After digging a bit deeper, it seems to me that the autogenrated mix file code is broken for two cases:

  • ROS1 messages with bool fields
  • ROS1 messages with array or sequence fields

The first assertion failure: Expected type 'bool' but 'uint8_t' received while setting value. comes from the fact that the mapping defined in the .hpp.em file here https://github.com/eProsima/ROS1-SH/blob/main/utils/ros1-mix-generator/resources/convert__msg.hpp.em maps bool -> bool but ROS1 messages such as BatteryState define the bool fields as uint8_t, see for example ros/melodic/include/sensor_msgs/BatteryState.h where the present fields is defined as

   typedef uint8_t _present_type;
  _present_type present;

Changing the maaping in convert__msg.hpp.em to bool -> uint8_t fixes the first assertion failure.

I haven't figured out the second assertion failure yet, but I expect it must be that array fields are no properly initialized for arrays.

Any update/advice from the maintainers / developers ?