def Drone_land(signal_recieved, frame): drone(Landing()).wait() time.sleep(10) drone(Emergency()).wait() print("Simulation Exited") sys.exit(0)
def Drone_Actn(xa, drone): print(colored(('Your Message: ', xa), "blue")) X_Ref = [] X_Home = [1, 2.5, 0.75, 0, 0, 0, 0, 0, 3*pi/2] if xa==1: if (drone.get_state(FlyingStateChanged)["state"] is not FlyingStateChanged_State.hovering): print(colored(('Initating Drone Take off !'), "green")) drone(TakeOff(_no_expect=True) & FlyingStateChanged(state="hovering", _policy="wait", _timeout=5) ).wait() # drone.start_piloting() else: print(colored(('Drone has already taken off !'), "green")) if xa == 2: X_Ref = X_Home X_Ref[0] = 1 X_Ref[2] = 0.75 elif xa==3: X_Ref = [0, 0, 1.5, 0, 0, 0, 0, 0, 0] elif xa==4: X_Ref = X_Home elif xa==5: X_Ref = [1.2, -2.5, 1.3, 0, 0, 0, 0, 0, 0] elif xa==6: X_Ref = [1, 0, 1.5, 0, 0, 0, 0, 0, pi] elif xa==7: X_Ref = X_Home elif xa==8: X_Ref = X_Home elif xa==9: X_Ref = X_Home elif xa==10: drone(moveBy(0, 0, 0, -5*pi/180) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() elif xa==11: print(colored(('Starting to Land !'), "green")) drone.stop_piloting() drone(Landing()).wait() time.sleep(5) drone(Emergency()).wait() print(colored(('Drone Landed !'), "green")) else: print('Currently Not programmed') return X_Ref
def on_grab_button_event(self, event, scheduler): self.print_event(event) # button: 0 = RTL, 1 = takeoff/land, 2 = back left, 3 = back right # axis_button: 4 = max CCW yaw, 5 = max CW yaw, 6 = max trottle, 7 = min trottle # 8 = min roll, 9 = max roll, 10 = min pitch, 11 = max pitch # 12 = max camera down, 13 = max camera up, 14 = min zoom, 15 = max zoom if event.args["event"] == button_event.press: if event.args["button"] == 0: # RTL self.anafi.drone(Emergency()).wait() rospy.logfatal("Emergency!!!") return if event.args["button"] == 2: # left back button self.anafi.switch_manual() return if event.args["button"] == 3: # right back button self.anafi.switch_offboard() self.msg_rpyt = SkyControllerCommand() return
def emergency_callback(self, msg): self.drone(Emergency()).wait( ) # https://developer.parrot.com/docs/olympe/arsdkng_ardrone3_piloting.html#olympe.messages.ardrone3.Piloting.Emergency rospy.logfatal("Emergency!!!")
def Drone_Actns_2(xa, drone): X_Ref = [] X_Home = [0.8, 2.0, 1.2, 0, 0, 0, 0, 0, 3*pi/2] X_End = [0.8,-2.0, 1.2, 0, 0, 0, 0, 0, 3*pi/2] DX = X_End[1] - X_Home[1] Tp = 78.0 Vy = DX/Tp if xa==1: if (drone.get_state(FlyingStateChanged)["state"] is not FlyingStateChanged_State.hovering): print(colored(('Initating Drone Take off !'), "green")) drone(TakeOff(_no_expect=True) & FlyingStateChanged(state="hovering", _policy="wait", _timeout=5) ).wait() # drone.start_piloting() else: print(colored(('Drone has already taken off !'), "green")) elif xa == 2: X_Ref = X_Home elif xa==3: print(colored(('Holding Position!'), "green")) X_Ref = [0, 0, 1.5, 0, 0, 0, 0, 0, 0] elif xa==4: X_Ref = X_Home elif xa==5: print(colored(('Starting to Land !'), "green")) drone.stop_piloting() drone(Landing()).wait() time.sleep(5) drone(Emergency()).wait() print(colored(('Drone Landed !'), "green")) elif xa==6: print(colored(('Starting to Land !'), "green")) drone.stop_piloting() drone(Landing()).wait() time.sleep(5) drone(Emergency()).wait() print(colored(('Drone Landed !'), "green")) drone.disconnection() sys.exit(0) else: print(colored(('Your Message: ', xa), "blue")) print(colored(('Currently not programmed!'), "red")) return X_Ref, Tp, Vy, X_End