ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to add conditional expression to Ros Launch files?

asked 2021-09-06 05:40:10 -0500

SuleKayiran gravatar image

updated 2021-09-06 05:47:01 -0500

Hello, I don't know how to ask but I'll try. I want to add condition to my launch file. For example, I want to reduce the lidar angle from 180 degrees to 150 degrees when the destination is reached after the path is planned. How can I do that? Thank you for your help

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2021-09-06 05:51:33 -0500

Ranjit Kathiriya gravatar image

Have a look at this #12756

when the destination is reached after the path is planned.

<arg name="path_planned" default="true"/>

Condition True

<group if="$(arg path_planned)">
  <!-- stuff that will only be evaluated if path_planned is true -->
</group>

Condition False

<group unless="$(arg path_planned)">
<!-- stuff that will only be evaluated if path_planned is false -->
</group>

Now, path_planned = true when the destination is not reached and else it is false when the destination is reached.

edit flag offensive delete link more

Comments

Thanks for your help. I will try your suggestion. Also, I have another question. After reducing it to 150 degrees, I will need to increase the angle I reduced to 150 degrees to 180 degrees before my robot can move autonomously while planning the path again. Can I apply your suggestion for 180 degrees and write it in the startup file again? @Ranjit Kathiriya

SuleKayiran gravatar image SuleKayiran  ( 2021-09-06 06:01:01 -0500 )edit

I am sorry! I couldn't get your question.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-06 06:08:00 -0500 )edit

I'm sorry for the late reply. It started to make more sense to deal with cpp files in my question, I applied your suggestions, they helped, but I realized that I needed to do something different, I realized that what I really wanted was not to deal with the launch file. Thank you for your help. @Ranjit Kathiriya

SuleKayiran gravatar image SuleKayiran  ( 2021-10-05 03:11:28 -0500 )edit
2

answered 2021-09-06 19:26:51 -0500

Mike Scheutzow gravatar image

You should know that you are trying to use roslaunch in a way that is unusual. Typically ros nodes do not start and stop very much. Rather, the idea is that roslaunch starts all the important nodes at the beginning, and then the nodes wait quietly for work to do. I'm not saying your approach will not work, but you should expect slow performance if you dynamically execute roslaunch. A typical ros node does not start up very quickly - it might take a second or two; conversely a node that is waiting for work can react in 10 or 20 milliseconds.

I would implement the kind of change you want in an always-running ros node that monitors topics for activity it cares about.

edit flag offensive delete link more

Comments

Thanks. This idea sounds smarter. I'll try to resolve it with nodes.

SuleKayiran gravatar image SuleKayiran  ( 2021-09-07 06:38:36 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-09-06 05:40:10 -0500

Seen: 1,573 times

Last updated: Sep 06 '21