Ask Your Question
1

launch different nodes based on user choice

asked 2021-03-26 03:23:50 -0500

LR1997 gravatar image

Hi everyone, I am trying to develop a simple program that ask the user if they want to start an "A Condition" or a "B Condition".

Based on the user choice, I would like to start different nodes. For example if A Condition is selected, then I would like to start A1, A2,A3 nodes and if B is selected I would like to start A1 (with a different config file) and other nodes B1,B2.

To achieve this, I tried to make a single launch file and divide it into groups, so that if <group if=A> nodes A1, A2, A3 are launched, and if <group if="B">, nodes A1, B1,B2 are launched. The problem that I have met is that I am able to do that only with <arg A = true> or <arg B = true> in the launch file, however this require the user to go into the launch file and manually set A and B to true or false based on what they want to do.

My idea was to take the user out of the loop as much as possible and do everything automatically. Therefore I wanted to write a simple C++ program that ask the user if they would like to use A or B. If A is selected then the program write on a config file : A: true, B:false (or if B is selected A:false B:true) and then start the .launch file directly from the C++ file. In the launch file I wanted to add a rosparam that reads the parameter from this config file:

<rosparam command="load" file="$(find package)/configfile.yaml" />

and then test if the conditions in the groups are met and start the correct group. (Something like <group if=(rosparameter A is true)> or <group if=(rosparameter B is true)> . However I am not able to achieve what I want and I am not able to use the imported rosparam as conditions in the group tags.

Moreover one of the nodes that I have is a GUI, and must display different informations based on the user input. So I would also like to have in the code a check to the rosparam and display different information based on the value of the rosparam. Something like (if A = true, display this... else if (B = true), display something else...

What I would like to ask you is at first is whether this approach is doable or too brittle/complex etc... but also if there are other ways in which I could solve my problem. Thanks in advance

LR

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-03-26 16:08:16 -0500

130s gravatar image

updated 2021-03-27 09:11:40 -0500

My understanding is that you're thinking to use a value taken from ROS Parameter server in order to configure the roslaunch. AFAIK that usecase is not a supported by the core toolset. Similar to #q297109 you might need to add a step before your roslaunch starts.

If the options for the switch based on the user's input can be grouped together by using group element, you can pass an arg when your program execute roslaunch.

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: 2021-03-26 03:10:16 -0500

Seen: 166 times

Last updated: Mar 27 '21