17 from typing
import Text, Dict
22 Parsing argument using sys module
27 Parse arguments for multi-robot's pose
30 `ros2 launch nav2_bringup bringup_multirobot_launch.py
31 robots:="robot1={x: 1.0, y: 1.0, yaw: 0.0};
32 robot2={x: 1.0, y: 1.0, z: 1.0, roll: 0.0, pitch: 1.5707, yaw: 1.5707}"`
34 `target_argument` shall be 'robots'.
35 Then, this will parse a string value for `robots` argument.
37 Each robot name which is corresponding to namespace and pose of it will be separted by `;`.
38 The pose consists of x, y and yaw with YAML format.
40 :param: target argument name to parse
44 def __parse_argument(self, target_argument: Text) -> Text:
46 get value of target argument
51 if arg.startswith(target_argument +
":="):
52 return arg.replace(target_argument +
":=",
"")
57 get value of target argument
60 parsed_args = list()
if len(args) == 0
else args.split(
';')
62 for arg
in parsed_args:
63 key_val = arg.strip().split(
'=')
66 key = key_val[0].strip()
67 val = key_val[1].strip()
68 robot_pose = yaml.safe_load(val)
69 if 'x' not in robot_pose:
71 if 'y' not in robot_pose:
73 if 'z' not in robot_pose:
75 if 'roll' not in robot_pose:
76 robot_pose[
'roll'] = 0.0
77 if 'pitch' not in robot_pose:
78 robot_pose[
'pitch'] = 0.0
79 if 'yaw' not in robot_pose:
80 robot_pose[
'yaw'] = 0.0
81 multirobots[key] = robot_pose
def __init__(self, Text target_argument)
Text __parse_argument(self, Text target_argument)