disturbance_eval.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # This is needed such that int / int gives a float instead of an int
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     disturbance_time = 40  # [s]
00027     settling_time_max = 10.0  # [s]
00028     position_error_max = 0.2  # [m]
00029     angular_velocity_error_max = 0.2  # [rad/s]
00030 
00031     # Get the begin and end times, and the set point from the waypoints.
00032     waypoints = ab.waypoint[0]
00033     bag_time_start = ab.bag_time_start.to_sec()
00034     bag_time_end = ab.bag_time_end.to_sec()
00035 
00036     print("\n")
00037     [begin_time, end_time] = helpers.get_evaluation_period(
00038         waypoints, 0, bag_time_start, bag_time_end, total_end_time)
00039     print("[Waypoint %d]: [%.3f, %.3f, %.3f, %.3f] at time %.3f s" % (
00040         0, waypoints.x[0], waypoints.y[0], waypoints.z[0],
00041         waypoints.yaw[0], begin_time))
00042 
00043     set_point_pos = analyze_bag.create_set_point(
00044         waypoints.x[0], waypoints.y[0], waypoints.z[0])
00045     set_point_pqr = analyze_bag.create_set_point(0, 0, 0)
00046 
00047     # TODO(ff): Automatically extract the disturbance time from a topic.
00048     begin_time = disturbance_time
00049 
00050     # Get all positions for the evaluation period.
00051     positions = ab.pos[0].slice(begin_time, end_time)
00052 
00053     # Get the time at which the MAV stayed for at least
00054     # min_settled_time seconds within a ball of settling_radius meters
00055     # around set_point_pos.
00056     settling_time = helpers.get_settling_time(
00057         positions, set_point_pos, settling_radius, min_settled_time, 0, False)
00058 
00059     rms_evaluation_start_time = begin_time
00060     rms_evaluation_end_time = min(begin_time + rms_calc_time, end_time)
00061     if settling_time is not None and settling_time < settling_time_max:
00062         rms_evaluation_start_time = begin_time + settling_time
00063         rms_evaluation_end_time = min(begin_time + settling_time +
00064                                       rms_calc_time, end_time)
00065         # Get the position RMS errors
00066         rms_positions = ab.pos[0].slice(
00067             rms_evaluation_start_time, rms_evaluation_end_time)
00068         pos_rms_error = helpers.get_rms_position_error(
00069             rms_positions, set_point_pos, 0, False)
00070 
00071         # Get the angular velocity RMS errors
00072         angular_velocities = ab.pqr[0].slice(
00073             rms_evaluation_start_time, rms_evaluation_end_time)
00074         pqr_rms_error = helpers.get_rms_angular_velocity_error(
00075             angular_velocities, set_point_pqr, 0, False)
00076 
00077     else:
00078         print("System didn't settle in %f seconds." % settling_time_max)
00079 
00080     # Plot pose msg content if there are any pose topics.
00081     if plot and len(ab.pose_topics) > 0:
00082         x_range = [begin_time - 2, rms_evaluation_end_time + 2]
00083         # ab.plot_3d_trajectories()
00084         helpers.plot_positions(
00085             ab, begin_time, rms_evaluation_end_time, settling_time,
00086             settling_radius, set_point_pos, x_range, str(0))
00087         helpers.plot_angular_velocities(
00088             ab, begin_time, rms_evaluation_end_time, settling_time,
00089             x_range, str(0))
00090 
00091     start_collision_time = (waypoints.bag_time[0].to_sec() +
00092                             first_waypoint_evaluation_delay)
00093     if (settling_time is not None and settling_time < settling_time_max and
00094         helpers.no_collisions_occured(ab, start_collision_time,
00095                                       rms_evaluation_end_time)):
00096         print("\n")
00097         helpers.print_scoring(settling_time, settling_time_max,
00098                               "settling time", "s", [0.0, 1.5, 3.5, 5.0])
00099         helpers.print_scoring(pos_rms_error, position_error_max,
00100                               "position RMS error", "m", [0.0, 1.5, 3.5, 5.0])
00101         helpers.print_scoring(pqr_rms_error, angular_velocity_error_max,
00102                               "angular velocity RMS error", "rad/s",
00103                               [0.0, 1.0, 2.0, 3.0])
00104 
00105 
00106 if __name__ == "__main__":
00107     main()


rotors_evaluation
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Thu Apr 18 2019 02:43:40