How to subscribe to another node's published topic?
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:
<launch>
<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>
<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)"
output="screen">
<!-- 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" />
</node>
<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" />
</group>
</launch>
Terminal output:
started roslaunch server http://Tricia:33555/
SUMMARY
========
PARAMETERS
* /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
NODES
/
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]
ROS_MASTER_URI=http://localhost:11311
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 configuration_file_resolver.cc:41] 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 configuration_file_resolver.cc:41] 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 configuration_file_resolver.cc:41] 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 ...
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 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 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 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.