7 """Converts between Mission and yaml files."""
11 """Converts a Mission object to a yaml file.
16 Full pathname for the output yaml file
19 The mission to be saved as a yaml file
22 mission_yaml = {
'mission': mission.toYaml()}
23 with open(filename,
'w')
as file:
24 yaml.dump(mission_yaml, file)
28 """Creates a Mission object from a yaml file.
33 Full pathname of the yaml file to be read
38 The created Mission object on success; None on any error
42 with open(filename,
'r')
as file:
44 mission_yaml = yaml.safe_load(file)
45 if 'mission' not in mission_yaml:
46 rospy.logerr(
"yamlFileToMission: missing 'mission' field")
48 return Mission.fromYaml(mission_yaml[
'mission'])
49 except yaml.YAMLError
as e:
50 rospy.logerr(
"Error while reading file: %s" % e)