string operations inside roslauch file
I have an argument defined inside the launch file as shown below-
<arg name="velocity" default="/mx230/motion/vel"/>
I want to define another argument, which is basically the string inside the first two forward slashes. For the example above, it should be similar to following-
<arg name="name" default="mx230"/>
I am wondering if there is an automatic way to find out this string. I can use the following python code inside my node but I feel that this simple operation could be possible inside launch file-
# get the name as the first word between two leftmost slash characters
def get_sensor_name(topic):
import re
all_slash = [m.start() for m in re.finditer('/', topic)]
name = topic[all_slash[0] + 1 : all_slash[1]]
return name
How to define arg name from arg velocity inside launch file?