00001
00002
00003 from __future__ import division
00004
00005 import roslib
00006 roslib.load_manifest('rotors_evaluation')
00007
00008 from rosbag_tools import analyze_bag, helpers
00009
00010
00011 __author__ = "Fadri Furrer, Michael Burri, Markus Achtelik"
00012 __copyright__ = ("Copyright 2015, Fadri Furrer & Michael Burri & "
00013 "Markus Achtelik, ASL, ETH Zurich, Switzerland")
00014 __credits__ = ["Fadri Furrer", "Michael Burri", "Markus Achtelik"]
00015 __license__ = "ASL 2.0"
00016 __version__ = "0.1"
00017 __maintainer__ = "Fadri Furrer"
00018 __email__ = "fadri.furrer@mavt.ethz.ch"
00019 __status__ = "Development"
00020
00021
00022 def main():
00023 [ab, plot, begin_time, total_end_time, rms_calc_time, settling_radius,
00024 min_settled_time, first_waypoint_evaluation_delay] = helpers.initialize()
00025
00026 position_error_max = 0.2
00027 angular_velocity_error_max = 0.2
00028
00029
00030 waypoints = ab.waypoint[0]
00031 bag_time_start = ab.bag_time_start.to_sec()
00032 bag_time_end = ab.bag_time_end.to_sec()
00033
00034 settling_time = None
00035 print("\n")
00036 [begin_time, end_time] = helpers.get_evaluation_period(
00037 waypoints, 0, bag_time_start, bag_time_end, total_end_time)
00038 print("[Waypoint %d]: [%.3f, %.3f, %.3f, %.3f] at time %.3f s" % (
00039 0, waypoints.x[0], waypoints.y[0], waypoints.z[0],
00040 waypoints.yaw[0], begin_time))
00041
00042 set_point_pos = analyze_bag.create_set_point(
00043 waypoints.x[0], waypoints.y[0], waypoints.z[0])
00044 set_point_pqr = analyze_bag.create_set_point(0, 0, 0)
00045
00046 begin_time += first_waypoint_evaluation_delay
00047 print("Setting the evaluation start time %f s after the "
00048 "waypoint was published."
00049 % first_waypoint_evaluation_delay)
00050
00051 rms_evaluation_start_time = begin_time
00052 rms_evaluation_end_time = min(begin_time + rms_calc_time, end_time)
00053
00054 rms_positions = ab.pos[0].slice(rms_evaluation_start_time,
00055 rms_evaluation_end_time)
00056 pos_rms_error = helpers.get_rms_position_error(
00057 rms_positions, set_point_pos, 0, print_output=False)
00058
00059
00060 angular_velocities = ab.pqr[0].slice(rms_evaluation_start_time,
00061 rms_evaluation_end_time)
00062 pqr_rms_error = helpers.get_rms_angular_velocity_error(
00063 angular_velocities, set_point_pqr, 0, print_output=False)
00064
00065
00066 if plot and len(ab.pose_topics) > 0:
00067 x_range = [begin_time - 2, rms_evaluation_end_time + 2]
00068
00069 helpers.plot_positions(
00070 ab, begin_time, rms_evaluation_end_time, settling_time,
00071 settling_radius, set_point_pos, x_range, str(0))
00072 helpers.plot_angular_velocities(
00073 ab, begin_time, rms_evaluation_end_time, settling_time,
00074 x_range, str(0))
00075
00076 start_collision_time = (waypoints.bag_time[0].to_sec() +
00077 first_waypoint_evaluation_delay)
00078 if (helpers.no_collisions_occured(ab, start_collision_time,
00079 rms_evaluation_end_time)):
00080 print("\n")
00081 helpers.print_scoring(pos_rms_error, position_error_max,
00082 "position RMS error", "m", [0.0, 1.5, 3.5, 5.0])
00083 helpers.print_scoring(pqr_rms_error, angular_velocity_error_max,
00084 "angular velocity RMS error", "rad/s",
00085 [0.0, 1.0, 2.0, 3.0])
00086
00087
00088 if __name__ == "__main__":
00089 main()