if __name__ == '__main__': def traj(uav, orig, dest): origin = up.Waypoint(orig[0], orig[1], orig[2], orig[3]) target = up.Waypoint(dest[0], dest[1], dest[2], dest[3]) samples = uav.path_sampling(origin, target, 1) x = [wp.x for wp in samples] y = [wp.y for wp in samples] z = [wp.z for wp in samples] return x, y, z uav_speed = 18. # m/s uav_max_turn_rate = 32. * np.pi / 180 uav_max_pitch_angle = 6. / 180. * np.pi uav = up.UAV(uav_speed, uav_max_turn_rate, uav_max_pitch_angle) ran = random.Random() # Random trajectories fig = plt.figure() ax = fig.add_subplot(111, projection='3d') def random_wp_pair(n=np.inf): for i in range(n): yield ((ran.randrange(-200, 200), ran.randrange(-200, 200), ran.randrange(-200, 200), ran.random() * 2 * np.pi), (ran.randrange(-200, 200), ran.randrange(-200, 200), ran.randrange(-200, 200), ran.random() * 2 * np.pi)) for wp_pair in random_wp_pair(50):
import json import matplotlib matplotlib.use('Agg') # set backend so that an X display is not required import numpy as np import unittest import fire_rs.planning.benchmark import fire_rs.uav_planning as up from fire_rs.geodata.display import GeoDataDisplay from fire_rs.geodata.geo_data import GeoData, TimedPoint from fire_rs.planning.benchmark import plot_plan, TrajectoryDisplayExtension # X8 UAS from Porto University uav = up.UAV(18., 32. * np.pi / 180, 0.1) class TestUAV(unittest.TestCase): def setUp(self): self.wp1 = up.Waypoint(0, 0, 0, 0) self.wp2 = up.Waypoint(4, 0, 0, 0) self.test_area = [[480060.0, 490060.0], [6210074.0, 6220074.0]] def test_waypoint(self): wp1 = up.Waypoint(4, 3, 2, 1) self.assertEqual(wp1.x, 4) self.assertEqual(wp1.y, 3) self.assertEqual(wp1.z, 2) self.assertEqual(wp1.dir, 1)
samples = uav.path_sampling_airframe(origin, target, wind, 1) x = [wp.x for wp in samples] y = [wp.y for wp in samples] return x, y if __name__ == '__main__': matplotlib.rcParams['font.family'] = 'sans-serif' matplotlib.rcParams['text.usetex'] = True uav_speed = 10. # m/s uav_max_turn_rate = 32. * np.pi / 180 uav_max_pitch_angle = 6. / 180. * np.pi wind = up.WindVector(0, -3) no_wind = up.WindVector(0, 0) a_uav = up.UAV("x8-06", uav_speed, uav_max_turn_rate, uav_max_pitch_angle) wp_s, wp_e = up.Waypoint(0, 0, 0, 0), up.Waypoint(100, 0, 0, 0) seg = up.Segment(wp_s, wp_e) tr_time = a_uav.travel_time(seg, wind) print(tr_time) print(a_uav.travel_time(wp_s, wp_e, wind)) fig = plt.figure() # Low altitude ax = fig.add_subplot(111, aspect='equal') # ax.set_xlim((-10, 70)) # ax.set_ylim((-20, 80)) ax.set_axis_off() #Hide axes
def as_cpp(self): return up.UAV(self.name, self.max_air_speed, self.max_angular_velocity, self.max_pitch_angle)