11 Provides functionality to parse a ROS bag which holds 12 an actionlib feedback message. 15 rospack = rospkg.RosPack()
16 self.
_dir = rospack.get_path(pkg) +
"/" + rel_path
22 Get all data from bags in the directory. 24 @param elements attributes to extract from each bag (list) 25 @returns list of bag data dictionaries. 28 for num
in range(len(glob.glob(self.
_dir +
"/" + self.
_prefix +
"*.bag"))):
37 Get all messages in the bag in the format msg.feedback.elements[i], plus the respective time. 39 @param elements elements to extract from each bag (list) 40 @param bag a rosbag.Bag instance. 41 @returns A dictionary with the data mapping {elements[i]: value} 46 for element
in elements:
49 for topic, msg, time
in bag.read_messages():
50 data[
't'].append(time.to_sec())
52 for element
in elements:
53 msg_element = getattr(msg, element)
56 raise RuntimeError(
"Got unsupported msg type " + msg_element._type)
57 data[element].append(list_data)
60 data[key] = np.asarray(data[key])
67 Convert the given message to a list. 69 if type(msg)
is float
or type(msg)
is int:
71 if msg._type ==
'geometry_msgs/WrenchStamped':
73 elif msg._type ==
'geometry_msgs/Wrench':
75 elif msg._type ==
'geometry_msgs/PoseStamped':
77 elif msg._type ==
'geometry_msgs/Pose':
85 Convert a wrench message to a list 87 w = [msg.force.x, msg.force.y, msg.force.y,
88 msg.torque.x, msg.torque.y, msg.torque.z]
93 Convert a pose message to list 95 p = [msg.position.x, msg.position.y, msg.position.z,
96 msg.orientation.x, msg.orientation.y, msg.orientation.z, msg.orientation.w]