Ask Your Question
0

How to run certain launch files within nodes?

asked 2017-07-11 03:28:10 -0500

snuzero gravatar image

I am working on an autonomous which requires different modes in which the robot will be running at. One such mode is a SLAM mode, but I feel that running SLAM for the whole time that the robot is running would be extremely inefficient. Is it possible to run SLAM only when a certain condition is met? Would this condition go in the .launch file or in some node? (for example, when a certain distance is travelled by the robot).

I am writing in python.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-06 10:50:10 -0500

Tyrone Nowell gravatar image

updated 2018-02-06 11:07:12 -0500

Hi snuzero,

I hope you have found a solution by now but I thought I would post an answer if case anyone else comes looking.

Adding the following to your launch file should do the trick.

<launch>
    <group if="$(arg foo)">
        <include file="$(find pkg)/launch/launch_name.launch"/>
    </group>

    <!-- The stuff you want to run in all cases -->
</launch>

In the included launch file, add your SLAM nodes.

Wiki on the include tag: http://wiki.ros.org/roslaunch/XML/inc...

If you want to start nodes dynamically, I would recommend launching them anyway but add a dynamic parameter to them which will only activate them when set. I.e. set up the node to periodically check for the given parameter, when set, do something but keep checking. This should allow you, or another node, to activate it using the rosparam server.

edit flag offensive delete link more

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: 2017-07-11 03:28:10 -0500

Seen: 435 times

Last updated: Feb 06 '18