Convert python launch arg to normal python variable
Is there a way to pass an argument to a python launch file and convert it to a normal in-built python type to use within the python launch file?
E.g. ros2 launch my_launch_file.launch.py temp_arg:="some string"
and then
# my_launch_file.launch.py
str_arg = LaunchConfiguration("temp_arg")
print(type(str_arg)) # <class 'launch.substitutions.launch_configuration.LaunchConfiguration'>
# Instead, I would like the value of str_arg to be of type <class 'str'>
# NOTE: the code below doesn't work due to the type of str_arg
if (str_arg == "config1"):
# some logic here
else:
# some other logic here
The reason being that I want to use the str_arg
var to do some other logic in the launch file