def _plan_generator(self, new_ac): yield from wait_for_mode_2 if self.waypoints: yield from move_waypoints( prepare_new_waypoint_locations(new_ac.flight_plan_waypoints, self.waypoints)) # 3: WaypointLocation(lat=43.4659053, long=1.2700005, alt=300), # 4: WaypointLocation(lat=43.4654170, long=1.2799074, alt=300), yield from takeoff_and_launch yield items.WaitForState(state_name_or_id='Standby') prep_list = [] if 'circle' in self.prep_mode: prep_list.append(items.WaitForCircles(n_circles=1)) if 'climb' in self.prep_mode: prep_list.append(items.WaitClimb(tolerance=5)) yield items.WaitAll(*prep_list) yield from self.load_plan(new_ac) yield items.JumpToBlock('Land Right AF-TD') yield items.WaitForState('land') yield items.WaitForSeconds(length=5) yield items.WaitClimb(tolerance=2) yield items.JumpToBlock('final') yield items.WaitForState('flare') yield items.WaitAny( items.WaitClimb(tolerance=1), items.WaitForSpeed(target_speed=0), items.WaitForSeconds(length=60), ) yield items.StopTest()
def get_items(self, **kwargs): plan = list() i = kwargs.pop('i') permutation = kwargs.pop('permutation', 0) new_wp_locs = { 3: WaypointLocation(lat=43.4659053, long=1.27, alt=300.0), 4: WaypointLocation(lat=43.465417, long=1.2799074, alt=300.0), } if new_wp_locs: plan += generation_helper.move_waypoints(new_wp_locs) plan_blocks = [ lambda: [ # 0 items.JumpToBlock('Figure 8 around wp 1'), items.WaitForState('Figure 8 around wp 1'), items.WaitForSeconds(84), ], lambda: [ # 1 items.JumpToBlock('Oval 1-2'), items.WaitForState('Oval 1-2'), items.WaitForSeconds(75), ], lambda: [ # 2 items.JumpToBlock('MOB'), items.WaitForState('MOB'), items.WaitForSeconds(62), ], lambda: [ # 3 items.JumpToBlock('Survey S1-S2'), items.WaitForState('Survey S1-S2'), items.WaitForSeconds(76), ], lambda: [ # 4 items.JumpToBlock('Path 1,2,S1,S2,STDBY'), items.WaitForState('Path 1,2,S1,S2,STDBY'), items.WaitForSeconds(61), ], ][int(i)]() permutation = int(permutation) block_size = 3 max_permutations = 1 for n in range(len(plan_blocks) // block_size, 0, -1): max_permutations *= n if permutation >= max_permutations: raise ValueError( f'Max number of permutations for this scenario is {max_permutations}' ) if permutation > 0: blocks = [] for i in range(0, len(plan_blocks), block_size): blocks.append(plan_blocks[i:i + block_size]) for i, perm in enumerate(itertools.permutations(blocks)): if i == permutation: plan_blocks = list(itertools.chain(*perm)) break else: raise ValueError('Invalid permutation') plan += plan_blocks return plan
def get_items(self, **kwargs): if self.ac.name == 'Microjet': plan = [ items.JumpToBlock('Survey S1-S2'), items.WaitForCircles(n_circles=2), ] elif self.ac.name == 'Bixler': plan = [ items.JumpToBlock('Fly in Square'), items.WaitForSeconds(length=15) ] else: plan = [] plan.append(items.StopTest()) return plan