16 from typing
import Dict, Text
22 """Parsing argument using sys module."""
26 Parse arguments for multi-robot's pose.
29 `ros2 launch nav2_bringup bringup_multirobot_launch.py
30 robots:="robot1={x: 1.0, y: 1.0, yaw: 0.0};
31 robot2={x: 1.0, y: 1.0, z: 1.0, roll: 0.0, pitch: 1.5707, yaw: 1.5707}"`
33 `target_argument` shall be 'robots'.
34 Then, this will parse a string value for `robots` argument.
36 Each robot name which is corresponding to namespace and pose of it will be separted by `;`.
37 The pose consists of x, y and yaw with YAML format.
39 :param: target argument name to parse
43 def __parse_argument(self, target_argument: Text) -> Text:
44 """Get value of target argument."""
48 if arg.startswith(target_argument +
':='):
49 return arg.replace(target_argument +
':=',
'')
53 """Get value of target argument."""
55 parsed_args = []
if len(args) == 0
else args.split(
';')
57 for arg
in parsed_args:
58 key_val = arg.strip().split(
'=')
61 key = key_val[0].strip()
62 val = key_val[1].strip()
63 robot_pose = yaml.safe_load(val)
64 if 'x' not in robot_pose:
66 if 'y' not in robot_pose:
68 if 'z' not in robot_pose:
70 if 'roll' not in robot_pose:
71 robot_pose[
'roll'] = 0.0
72 if 'pitch' not in robot_pose:
73 robot_pose[
'pitch'] = 0.0
74 if 'yaw' not in robot_pose:
75 robot_pose[
'yaw'] = 0.0
76 multirobots[key] = robot_pose
def __init__(self, Text target_argument)
Text __parse_argument(self, Text target_argument)