iralabdisco / ira_laser_tools

All laser type assemblers and manipulators.
BSD 3-Clause "New" or "Revised" License
197 stars 209 forks source link

Unable to roslaunch laserscan_multi_merger when launch file is run in a different package #31

Open yungchuenng opened 3 years ago

yungchuenng commented 3 years ago

Hi!

I am running the ira_laser_tools on a ROS Kinetic system. In my workspace, I have a package i.e. "test_robot", in which a launch file that starts up my ROS system would include a launch file that calls the ira_laser_tools laserscan_multi_merger (in the same directory) which has the code as follows:

<launch>
    <node pkg="ira_laser_tools" name="laserscan_multi_merger" type="laserscan_multi_merger" output="screen">
        <param name="destination_frame" value="/base_link"/>
        <param name="cloud_destination_topic" value="/merged_cloud"/>
        <param name="scan_destination_topic" value="/scan"/>
        <param name="laserscan_topics" value ="/scan1 /scan2" />
        <param name="angle_min" value="-3.14"/>
        <param name="angle_max" value="3.14"/>
        <param name="angle_increment" value="0.0043"/>
        <param name="scan_time" value="0.0333333"/>
        <param name="range_min" value="0.10"/>
        <param name="range_max" value="50.0"/>
    </node>
</launch>

In this situation, even though the laserscan_multi_merger node (in the same workspace) seems to have launched without any error thrown, this node does not seem to be working correctly as when I tried to get the output,

rostopic echo /scan

It gets stuck and nothing happens at all (my inputs /scan1 and /scan2 are working correctly).

However, when I

roslaunch ira_laser_tools laserscan_multi_merger.launch

after I roslaunch my ROS system (still including the launch file to run the ira_laser_tools node in the "test_robot" launch file), the laserscan_multi_merger node from previously gets killed, and the new laserscan_multi_merger node works fine and I am able to get /scan data.

The reason for including the launch file that calls the ira_laser_tools laserscan_multi_merger in my own launch file is so that I can run all nodes at once from just one main launch file.

Hence, the issue is that when trying to launch the laserscan_multi_merger node from another package other than from ira_laser_tools, the laserscan_multi_merger node does not seem to work correctly.

Would deeply appreciate anyone's assistance in this matter! Thank you in advance!!!

pietrocolombo commented 3 years ago

I think the problem is that when starting the multi_merger the topics / scan1 and / scan2 are not published yet so you should see in the terminal "Not subscribed to any topic." this line

because the search for available topics is done only at startup

yungchuenng commented 3 years ago

Thank you for your prompt response! Will get back to you regarding this when I return to working on my project in a few days! I will try to workaround it and update here again.

yungchuenng commented 3 years ago

Hi!

I actually did not notice the "Not subscribed to any topic" line, but there was a ROS warning message:

Transformer::setExtrapolationLimit is deprecated and does not do anything

So it seemed the code did managed to continue running after. Regardless, I managed to solve the issue by adding the following lines in the source code of laserscan_multi_merger.cpp before the function "laserscan_topic_parser()" is run in LaserscanMerger::LaserscanMerger():

boost::shared_ptr<sensor_msgs::LaserScan const> messsage;
message = ros::topic::waitForMessage<sensor_msgs::LaserScan>(last_laser_topic, node_, ros::Duration(100));

However, there was another issue that I encountered.

After I catkin_make the ira_laser_tools in a workspace i.e. "workspace_1", running my roslaunch file in workspace_2 that includes "laserscan_multi_merger.launch" will always find the ira_laser_tools package from workspace_1 instead of from workspace_2, in which I have also catkin_make ira_laser_tools, even though I have sourced the setup.bash of workspace_2.

May I kindly ask if there is a way to go about this? That is even if I have the ira_laser_tools in different workspace, I want the ira_laser_tools in the local workspace to run.

Much thanks!