launch different nodes based on user choice
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