6 from datetime
import datetime
9 from hmi_msgs.msg
import QueryActionGoal, QueryActionResult
35 rospy.loginfo(
"Starting HMI recording")
58 "request": msg.__str__(),
59 "result": RESULT.__str__()
62 if RESULT.status.status == 3:
63 json_filename =
"%s/%s.json" % (STORAGE_FOLDER, now.strftime(
"%Y-%m-%d-%H-%M-%d-%f"))
64 with open(json_filename,
'w')
as outfile:
65 json.dump(data, outfile)
67 rospy.loginfo(
"Writing HMI log to %s" % json_filename)
71 global RECORDING, RESULT
73 rospy.loginfo(
"End callback")
77 if __name__ ==
'__main__':
78 rospy.init_node(
"hmi_logger")
80 start_sub = rospy.Subscriber(
"goal", QueryActionGoal, start)
81 end_sub = rospy.Subscriber(
"result", QueryActionResult, end)
82 rospy.loginfo(
"Start topic: %s", start_sub.name)
83 rospy.loginfo(
"End topic: %s", end_sub.name)
84 STORAGE_FOLDER = rospy.get_param(
'~storage_folder', os.path.expanduser(
'/tmp/hmi'))
86 if not os.path.exists(STORAGE_FOLDER):
87 os.makedirs(STORAGE_FOLDER)