roslaunch: add further condition in launch-prefix
To bind a node to a specific I'm using the approach mentioned here.
As I want to use the launch file on different hardware, I need to check whether the number of cpu cores allows this setting. In other words, assign a fixed CPU only if this cpu is available on actual hardware. In bash, I tried something like this, which seems to work
if (("$(nproc)" > 4));then taskset -c 5;fi;
When I try to add this to launch-prefix I get an error:
<node pkg = "my_pkg" name = "myname" type = "mytype" launch-prefix ="if ((""$(nproc)"" > 4));then taskset -c 5;fi;"/>
Error:
Invalid roslaunch XML syntax: not well-formed (invalid token): line 14, column 119 The traceback for the exception was written to the log file
Other ideas I had were using the output of nproc as an argument, but I didn't manage to do so.