Ask Your Question

How to subscribe to another node's published topic?

asked 2020-09-08 07:41:37 -0600

aliakbar gravatar image

updated 2020-09-08 07:44:38 -0600

I'm trying to subscribe to imu_complementary_filter's published topic in another node, and I get the following error in my Terminal's output:

[ WARN] [...] Expected resolved topic "/imu/data" not found in bag file(s).
[ WARN] [...] Available topics in bag file(s) are /os1_cloud_node/imu,/os1_cloud_node/points,/os1_node/imu_packets,/os1_node/lidar_packets,/rosout,/tf_static

My sensor's internal IMU topic is named /os1_cloud_node/imu but I want to filter this first, which output's another topic named /imu/data and feed that to the cartographer_offline_node, what changes do I need to make in my launch file in order to achieve this?

Launch file:

  <arg name="bag_filenames"/>
  <arg name="rviz" default="true"/>
  <param name="/use_sim_time" value="true" />
  <param name="robot_description" textfile="$(find cartographer_ros)/urdf/os1_sensor.urdf" />

     <!-- IMU Complimentary Filter -->
  <node name="imu_complementary_filter" pkg="imu_complementary_filter" type="complementary_filter_node">
    <remap from="imu/data_raw" to="/os1_cloud_node/imu" />
    <param name="fixed_frame" value="odom"/> 
    <param name="publish_tf" value="false"/> 
    <param name="publish_debug_topics" value="false"/> 

  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />

  <node name="cartographer_offline_node" pkg="cartographer_ros"
      type="cartographer_offline_node" args="
          -configuration_directory $(find cartographer_ros)/configuration_files
          -configuration_basenames car_3d.lua
          -urdf_filenames $(find cartographer_ros)/urdf/os1_sensor.urdf
          -bag_filenames $(arg bag_filenames)"

    <!-- Remap for OS1 -->
    <remap from="scan" to="/scan_sim" />
    <!-- OS1 LiDAR output -->
    <remap from="points2" to="/os1_cloud_node/points" />
    <!-- IMU Comp filter output -->
    <remap from="imu" to="/imu/data" />
    <!-- OS1 IMU output -->
    <!-- <remap from="imu" to="/os1_cloud_node/imu" />  -->
    <!-- EKF filter output  -->
    <remap from="odom" to="/odometry/filtered" />     

    <group if="$(arg rviz)">
    <!-- Load RViz -->
    <node name="rviz_map" pkg="rviz" type="rviz" args="-d $(find cartographer_ros)/configuration_files/demo_car_3d.rviz" />

    <node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
        type="cartographer_occupancy_grid_node" args="-resolution 0.05" />


Terminal output:

started roslaunch server http://Tricia:33555/


 * /imu_complementary_filter/fixed_frame: odom
 * /imu_complementary_filter/publish_debug_topics: False
 * /imu_complementary_filter/publish_tf: False
 * /robot_description: <?xml version="1....
 * /rosdistro: melodic
 * /rosversion: 1.14.9
 * /use_sim_time: True

    cartographer_occupancy_grid_node (cartographer_ros/cartographer_occupancy_grid_node)
    cartographer_offline_node (cartographer_ros/cartographer_offline_node)
    imu_complementary_filter (imu_complementary_filter/complementary_filter_node)
    robot_state_publisher (robot_state_publisher/robot_state_publisher)
    rviz_map (rviz/rviz)

auto-starting new master
process[master]: started with pid [3736]

setting /run_id to b7ad0dac-f1cb-11ea-baa9-fcaa14494eff
process[rosout-1]: started with pid [3747]
started core service [/rosout]
process[imu_complementary_filter-2]: started with pid [3753]
process[robot_state_publisher-3]: started with pid [3755]
process[cartographer_offline_node-4]: started with pid [3761]
process[rviz_map-5]: started with pid [3768]
process[cartographer_occupancy_grid_node-6]: started with pid [3769]
[ INFO] [1599566786.134345409]: I0908 16:36:26.000000  3761] Found '/home/user/catkin_ws/install_isolated/share/cartographer_ros/configuration_files/car_3d.lua' for 'car_3d.lua'.
[ INFO] [1599566786.136205314]: I0908 16:36:26.000000  3761] Found '/home/user/catkin_ws/install_isolated/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'.
[ INFO] [1599566786.136315607]: I0908 16:36:26.000000  3761] Found '/home/user/catkin_ws/install_isolated/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'.
[ INFO] [1599566786.136425277]: I0908 16:36:26.000000  3761 configuration_file_resolver ...
edit retag flag offensive close merge delete



Well, your running cartographer offline on a bag file which doesn't have the topic you want. This node is not listening to any topics outside of the bagfile.

Either run cartographer online, which would require you to manually play the bagfile. Then, cartographer would subscribe to any topics as is usually done.

You could also filter the imu data and rewrite the bagfile by either the rosbag api or playing and recording a new rosbag with the new data.

mgruhler gravatar image mgruhler  ( 2020-09-08 08:09:42 -0600 )edit

@mgruhler Thank you for your reply. I see, I think the second method would be a better solution, would appreciate it if you could provide me with step by step instructions as an answer, and would definitely select it as the accepted answer. I know some Python. Thank you.

aliakbar gravatar image aliakbar  ( 2020-09-08 17:16:07 -0600 )edit

@aliakbar I disagree. I think the better way would be actually to run the node online. Then again, there are some points for the offline approach.

mgruhler gravatar image mgruhler  ( 2020-09-09 01:42:09 -0600 )edit

@mgruhler The reason I wanted to rewrite the bag file is that, after the cartographer is done I want to run the "cartographer_assets_writer" to generate a point cloud, and this is an offline-only node that takes a pbstream (generated by the cartographer) and the bag file as input. I'm not sure if cartographer_assets_writer also takes IMU measurements into account, if it does then we're back to square one.

aliakbar gravatar image aliakbar  ( 2020-09-09 03:07:53 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-09-09 01:47:18 -0600

mgruhler gravatar image

The easiest way is to record a new bagfile with all topics while playing the old one. This way you can use the filter node.

Another approach is to manually filter the data in e.g. python and use the rosbag API to read and write the bagfile.

edit flag offensive delete link more


Thanks for your suggestions, I decided to go with the "online" approach but I'm facing other issues along the way, and I created another question here I'd appreciate if you could take a look. Thank you.

aliakbar gravatar image aliakbar  ( 2020-09-10 11:52:52 -0600 )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


Asked: 2020-09-08 07:41:37 -0600

Seen: 139 times

Last updated: Sep 09 '20