def onPositionChanged(self, event, scheduler): casey_coords = findOffset(event.args["latitude"],event.args["longitude"],-1,0) donatello_coords = findOffset(event.args["latitude"],event.args["longitude"],1,0) casey(moveTo(casey_coords[0], casey_coords[1], 0.86, MoveTo_Orientation_mode.TO_TARGET, 0.0)) donatello(moveTo(donatello_coords[0], donatello_coords[1], 0.86, MoveTo_Orientation_mode.TO_TARGET, 0.0)) print( "latitude = {latitude} longitude = {longitude} altitude = {altitude}".format( **event.args ) )
def onPositionChanged(self, event, scheduler): lat = event.args["latitude"] lon = event.args["longitude"] c_poi = (lat, lon) poi = (21.371518, -157.71161) print('\n ------->') print('\n ------->') print('\n ------->') meters = haversine(poi, c_poi, unit='m') print(meters) print(meters < 2) print('\n ------->') print('\n ------->') print('\n ------->') two_lat = event.args["latitude"] two_lon = event.args["longitude"] if meters < 8: casey(moveToChanged(status="CANCELED") >> moveTo(21.370950, -157.709998, 10, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") ) donatello(moveToChanged(status="CANCELED") >> moveTo(21.370950, -157.709998, 20, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") ) leonardo(moveToChanged(status="CANCELED") >> moveTo(21.370950, -157.709998, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") ) two_lat = 21.370950 two_lon = -157.709998 casey_coords = findOffset(two_lat,two_lon,-5,0) donatello_coords = findOffset(two_lat,two_lon,5,0) leonardo_coords = findOffset(two_lat,two_lon,0,5) michelangelo_coords = findOffset(event.args["latitude"],event.args["longitude"],0,-10) raphael_coords = findOffset(event.args["latitude"],event.args["longitude"],10,10) splinter_coords = findOffset(event.args["latitude"],event.args["longitude"],-10,-10) casey(moveTo(casey_coords[0], casey_coords[1], 10, MoveTo_Orientation_mode.TO_TARGET, 0.0)) donatello(moveTo(donatello_coords[0], donatello_coords[1], 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) leonardo(moveTo(leonardo_coords[0], leonardo_coords[1], 20, MoveTo_Orientation_mode.TO_TARGET, 0.0)) michelangelo(moveTo(michelangelo_coords[0], michelangelo_coords[1], 25, MoveTo_Orientation_mode.TO_TARGET, 0.0)) raphael(moveTo(raphael_coords[0], raphael_coords[1], 30, MoveTo_Orientation_mode.TO_TARGET, 0.0)) splinter(moveTo(splinter_coords[0], splinter_coords[1], 35, MoveTo_Orientation_mode.TO_TARGET, 0.0)) print( "latitude = {latitude} longitude = {longitude} altitude = {altitude}".format( **event.args ) )
def move(index, coords): print(route[index + 1][0]) april( moveTo(route[index + 1][0], route[index + 1][1], 1, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() casey( moveTo(route[index][0], route[index][1], 0.8, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success()
def onPositionChanged(self, event, scheduler): casey_coords = findOffset(event.args["latitude"],event.args["longitude"],-50,0) donatello_coords = findOffset(event.args["latitude"],event.args["longitude"],50,0) leonardo_coords = findOffset(event.args["latitude"],event.args["longitude"],0,50) michelangelo_coords = findOffset(event.args["latitude"],event.args["longitude"],0,-50) casey(moveTo(casey_coords[0], casey_coords[1], 10, MoveTo_Orientation_mode.TO_TARGET, 0.0)) donatello(moveTo(donatello_coords[0], donatello_coords[1], 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) leonardo(moveTo(leonardo_coords[0], leonardo_coords[1], 20, MoveTo_Orientation_mode.TO_TARGET, 0.0)) michelangelo(moveTo(michelangelo_coords[0], michelangelo_coords[1], 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) print( "latitude = {latitude} longitude = {longitude} altitude = {altitude}".format( **event.args ) )
def onPositionChanged(self, event, scheduler): casey(moveTo(event.args["latitude"], event.args["longitude"], 0.86, MoveTo_Orientation_mode.TO_TARGET, 0.0)) print( "latitude = {latitude} longitude = {longitude} altitude = {altitude}".format( **event.args ) )
def changealtitude(drone, alt): lat = drone.get_state(PositionChanged)["latitude"] lon = drone.get_state(PositionChanged)["longitude"] drone(moveTo(lon,lat,alt,0,0) >> FlyingStateChanged(state="hovering", _timeout=5)).wait() getgpsposition(drone)
def moveto(drone, latitude, longitude, altitude, orientation_mode, heading): drone(moveTo( latitude, longitude, altitude, orientation_mode, heading )).wait()
def move(index, coords): april( moveTo(route[index + 6][0], route[index + 6][1], 0.7, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=1)).wait().success() casey( moveTo(route[index][0], route[index][1], 1, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=2)).wait().success() donatello( moveTo(route[index + 6][0], route[index + 6][1], 0.7, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=3)).wait().success() leonardo( moveTo(route[index][0], route[index][1], 1, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=4)).wait().success() michelangelo( moveTo(route[index + 6][0], route[index + 6][1], 0.7, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() raphael( moveTo(route[index][0], route[index][1], 1, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() splinter( moveTo(route[index + 6][0], route[index + 6][1], 0.7, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success()
def moveSwarm(poi): casey( moveTo(poi["latitude"], poi["longitude"], 0.9, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() donatello( moveTo(poi["latitude"], poi["longitude"], 0.8, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() leonardo( moveTo(poi["latitude"], poi["longitude"], 1.1, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() michelangelo( moveTo(poi["latitude"], poi["longitude"], 0.7, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() raphael( moveTo(poi["latitude"], poi["longitude"], 1.2, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() splinter( moveTo(poi["latitude"], poi["longitude"], 0.6, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success()
def goToEntrance(): print("Going to entrance") ##Go up drone( moveBy(0, 0, -5, 0) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() ##Go to entrance drone( moveTo(latitude=entranceLatitude, longitude=entranceLongitude, altitude=5, orientation_mode=0, heading=0) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() drone( moveTo(latitude=entranceLatitude, longitude=entranceLongitude, altitude=entranceAltitude, orientation_mode=0, heading=0) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() return
def goToHome(): print("Going to HOME") drone( moveBy(0, 0, -5, 0) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() drone( moveTo(latitude=homeLatitude, longitude=homeLongitude, altitude=homeAltitude, orientation_mode=0, heading=0) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() return
def goHome(self): print('ET going home...', end='', flush=True) # Start navigating home self.bebop( moveTo(self.drone_location['latitude'], self.drone_location['longitude'], self.drone_location['altitude'], 1, 0.0) >> FlyingStateChanged(state='hovering', _timeout=5) >> moveToChanged( latitude=self.drone_location['latitude'], longitude=self.drone_location['longitude'], altitude=self.drone_location['altitude'], orientation_mode=MoveTo_Orientation_mode.TO_TARGET, status='DONE', _policy='wait') >> FlyingStateChanged(state='hovering', _timeout=5)).wait() print('Done!')
def newCenterLocation(self, lat, lon): # print('Flying state:', self.getFlyingState()) if self.getFlyingState() != 'landed': self.bebop( moveTo(lat, lon, self.drone_location['altitude'], MoveTo_Orientation_mode.TO_TARGET, 0.0) >> FlyingStateChanged( state='hovering', _timeout=5) >> moveToChanged( latitude=lat, longitude=lon, altitude=self.drone_location['altitude'], orientation_mode=MoveTo_Orientation_mode.TO_TARGET, status='DONE', _policy='wait') >> FlyingStateChanged(state='hovering', _timeout=5))
def AutomaticGoTo(self,coordinates): """Déplacement automatique""" if isinstance(coordinates, dict): coordinates = DroneCommandParams(**coordinates) if not self._manual_unit : if not self._on_test: self._drone( moveTo(coordinates.latitude,coordinates.longitude,self._drone_coordinates.altitude, MoveTo_Orientation_mode.TO_TARGET ) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() else : self.my_log.info("Mode simulation: informations reçues {} ".format(coordinates.to_string())) time.sleep(1) self._brain_client.emit('on_command_success', {"name":self.my_name, "command":"AutomaticGoTo"}) else : self.my_log.info("Mode Manuel : Commande ignorée")
def moveToCoords(self): self.bebop(FlyingStateChanged(state='hovering', _timeout=5)) print(self.bebop.get_state(moveToChanged)) # -25.766915, 28.251963 - Francois pool lat = -25.766915 lon = 28.251963 # alt = self.drone_location['altitude'] alt = 4 print('Moving to coords...', end='', flush=True) self.bebop( moveTo(lat, lon, alt, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> FlyingStateChanged(state='hovering', _timeout=5) >> moveToChanged( latitude=lat, longitude=lon, altitude=alt, orientation_mode=MoveTo_Orientation_mode.TO_TARGET, status='DONE', _policy='wait') >> FlyingStateChanged(state='hovering', _timeout=5)) print('Done!')
def flyTo(self, longitude, latitude, altitude=-1): drone_location = self.drone.get_state(GpsLocationChanged) if (altitude == -1): altitude = drone_location["altitude"] if (longitude == 0.0 and latitude == 0.0): longitude = drone_location["longitude"] latitude = drone_location["latitude"] if (self.drone.get_state(FlyingStateChanged)['state'] != FlyingStateChanged_State.landed): self.drone( moveTo(latitude, longitude, altitude, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> FlyingStateChanged( state="hovering", _timeout=self.timeout) >> moveToChanged( latitude=latitude, longitude=longitude, altitude=2, orientation_mode=MoveTo_Orientation_mode.TO_TARGET, status='DONE', _policy='wait') >> FlyingStateChanged( state="hovering", _timeout=self.timeout)).wait() return True else: return False
| FlyingStateChanged(state="flying", _policy="check") | (GPSFixStateChanged(fixed=1, _timeout=10, _policy="check_wait") >> (TakeOff(_no_expect=True) & FlyingStateChanged( state="hovering", _timeout=10, _policy="check_wait")))).wait() # Get the home position drone_location = drone.get_state(GpsLocationChanged) # Move 10m drone( moveBy(10, 0, 0, math.pi) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() # Go back home drone( moveTo(drone_location["latitude"], drone_location["longitude"], drone_location["altitude"], MoveTo_Orientation_mode.TO_TARGET, 0.0) >> FlyingStateChanged(state="hovering", _timeout=5) >> moveToChanged( latitude=drone_location["latitude"], longitude=drone_location["longitude"], altitude=drone_location["altitude"], orientation_mode=MoveTo_Orientation_mode.TO_TARGET, status='DONE', _policy='wait') >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() # Landing drone(Landing() >> FlyingStateChanged(state="landed", _timeout=5)).wait() drone.disconnection()
every_event_listener.subscribe() drone.connect() casey.connect() donatello.connect() every_event_listener.unsubscribe() # You can also subscribe/unsubscribe automatically using a with statement with FlightListener(drone) as flight_listener: for i in range(2): assert drone( FlyingStateChanged(state="hovering") | (TakeOff() & FlyingStateChanged(state="hovering"))).wait().success() assert drone( FlyingStateChanged(state="hovering", _timeout=5) >> moveTo( 21.371518652227294, -157.71239, 15, MoveTo_Orientation_mode .TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo( 21.371518652227294, -157.7116182859902, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo( 21.3708, -157.7116182859902, 15, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo( 21.370081347772704, -157.7116182859902, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo( 21.370081347772704, -157.71239, 15, MoveTo_Orientation_mode .TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo( 21.370081347772704, -157.7131617140098, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo( 21.3708, -157.7131617140098, 15, MoveTo_Orientation_mode.
from olympe.messages.ardrone3.PilotingState import FlyingStateChanged, moveToChanged from olympe.messages.camera import start_recording, stop_recording from olympe.messages import gimbal from olympe.enums.ardrone3.Piloting import MoveTo_Orientation_mode DRONE_IP = "10.202.0.1" casey = olympe.Drone("10.202.1.1") drone = olympe.Drone(DRONE_IP) # if __name__ == "__main__": # with olympe.Drone(DRONE_IP) as drone: drone.connect() casey.connect() # Start a flying action asynchronously drone(TakeOff() >> FlyingStateChanged(state="hovering", _timeout=5) >> moveTo( 21.37313, -157.7123, 15, MoveTo_Orientation_mode.NONE, 0.0) >> moveToChanged(status="DONE") >> moveTo( 21.37313, -157.7098, 15, MoveTo_Orientation_mode.NONE, 0.0) >> moveToChanged(status="DONE") >> Landing()) casey(TakeOff() >> FlyingStateChanged(state="hovering", _timeout=5) >> moveTo( 21.3708, -157.709881, 15, MoveTo_Orientation_mode.NONE, 0.0) >> moveToChanged(status="DONE") >> moveTo( 21.368464, -157.71239, 15, MoveTo_Orientation_mode.NONE, 0.0) >> moveToChanged(status="DONE") >> Landing()).wait().success() # t:21.3708,lng:-157.709881 - east # at:21.368464380261287,lng:-157.71239 - south # Wait for the end of the flying action # if not flyingAction.wait().success():
from olympe.enums.ardrone3.Piloting import MoveTo_Orientation_mode april_ip = "10.202.0.1" casey_ip = "10.202.1.1" donatello_ip = "10.202.2.1" leonardo_ip = "10.202.3.1" michelangelo_ip = "10.202.4.1" raphael_ip = "10.202.5.1" splinter_ip = "10.202.6.1" april = olympe.Drone(april_ip) casey = olympe.Drone(casey_ip) donatello = olympe.Drone(donatello_ip) leonardo = olympe.Drone(leonardo_ip) michelangelo = olympe.Drone(michelangelo_ip) raphael = olympe.Drone(raphael_ip) splinter = olympe.Drone(splinter_ip) # Take-off # drone(TakeOff()).wait() april(TakeOff() >> casey(TakeOff()) >> donatello(TakeOff())).wait().success() for coords in route: april( moveTo(coords[0], coords[1], 1, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> casey( moveTo(coords[0], coords[1], 1, MoveTo_Orientation_mode.TO_TARGET, 0.0)) >> donatello( moveTo(coords[0], coords[1], 1, MoveTo_Orientation_mode. TO_TARGET, 0.0))).wait().success()
def moveto(drone, longt, lati, alti): drone(moveTo(longt,lati,alti,0,0) >> FlyingStateChanged(state="hovering", _timeout=5)).wait() getgpsposition(drone)
print("*******************************************************************************************************") print("TAKING OFF") print("*******************************************************************************************************") drone( TakeOff() >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() #Go to HOME os.system('cls' if os.name == 'nt' else 'clear') clear_output(wait=True) print("*******************************************************************************************************") print("GOING TO HOME") print("*******************************************************************************************************") drone( moveTo(latitude=homeLatitude,longitude=homeLongitude,altitude=homeAltitude, orientation_mode=0, heading=0) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() #Go to picture point os.system('cls' if os.name == 'nt' else 'clear') clear_output(wait=True) print("*******************************************************************************************************") print("GOING TO PICTURE POINT") print("*******************************************************************************************************") drone( moveTo(latitude=pictureLatitude,longitude=pictureLongitude,altitude=pictureAltitude, orientation_mode=0, heading=0) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() #Rotate camera down print("*******************************************************************************************************") print("AIMING CAMERA")
def move(coords): april( moveTo(coords[0], coords[1], 1, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success() updateSwarm()
michelangelo.connect() raphael.connect() splinter.connect() every_event_listener.unsubscribe() # You can also subscribe/unsubscribe automatically using a with statement with FlightListener(drone) as flight_listener: for i in range(2): assert drone( FlyingStateChanged(state="hovering") | (TakeOff() & FlyingStateChanged(state="hovering"))).wait().success() assert drone( FlyingStateChanged(state="hovering", _timeout=5) >> moveTo( 21.36945383, -157.7133445, 15, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo( 21.37028804, -157.7134336, 15, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37040696, -157.7134463, 15, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37055568, -157.7134622, 15, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37079381, -157.7134876, 15, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37096092, -157.7135054, 15, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37136676, -157.7135488, 15, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37236059, -157.7128414, 15, MoveTo_Orientation_mode. TO_TARGET, 0.0) >> moveToChanged(status="DONE") >>
& FlyingStateChanged( state="hovering", _timeout=10, _policy="check_wait")))).wait() donatello( FlyingStateChanged(state="hovering", _policy="check") | FlyingStateChanged(state="flying", _policy="check") | (GPSFixStateChanged(fixed=1, _timeout=10, _policy="check_wait") >> (TakeOff(_no_expect=True) & FlyingStateChanged( state="hovering", _timeout=10, _policy="check_wait")))).wait() drone_location = drone.get_state(GpsLocationChanged) coords = [21.377386152841197, -157.712818] # Go back home drone( moveBy(0, -1000, 0, math.pi) >> casey( moveTo(coords[0], coords[1], 50, MoveTo_Orientation_mode.TO_TARGET, 0.0)) >> donatello( moveTo(coords[0], coords[1], 10, MoveTo_Orientation_mode.TO_TARGET, 0.0)) >> FlyingStateChanged(state="hovering", _timeout=5) >> moveToChanged( latitude=drone_location["latitude"], longitude=drone_location["longitude"], altitude=drone_location["altitude"], orientation_mode=MoveTo_Orientation_mode.TO_TARGET, status='DONE', _policy='wait') >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() # Go back home drone( moveTo(drone_location["latitude"], drone_location["longitude"], drone_location["altitude"], MoveTo_Orientation_mode.TO_TARGET, 0.0)
def onPositionChanged(self, event, scheduler): global poiIndex poiIndex += 1 # lat = event.args["latitude"] # lon = event.args["longitude"] # c_poi = (lat, lon) # poi = (21.371518, -157.71161) print('\n ------->') print('\n ------->') print('\n ------->') #print(poiIndex) print('\n ------->') print('\n ------->') print('\n ------->') # two_lat = event.args["latitude"] # two_lon = event.args["longitude"] # if meters < 8: # casey(moveToChanged(status="CANCELED") # >> moveTo(21.370950, -157.709998, 10, MoveTo_Orientation_mode.TO_TARGET, 0.0) # >> moveToChanged(status="DONE") # ) # donatello(moveToChanged(status="CANCELED") # >> moveTo(21.370950, -157.709998, 20, MoveTo_Orientation_mode.TO_TARGET, 0.0) # >> moveToChanged(status="DONE") # ) # leonardo(moveToChanged(status="CANCELED") # >> moveTo(21.370950, -157.709998, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) # >> moveToChanged(status="DONE") # ) # two_lat = 21.370950 # two_lon = -157.709998 # casey_coords = findOffset(two_lat,two_lon,-5,0) # donatello_coords = findOffset(two_lat,two_lon,5,0) # leonardo_coords = findOffset(two_lat,two_lon,0,5) # michelangelo_coords = findOffset(event.args["latitude"],event.args["longitude"],0,-10) # raphael_coords = findOffset(event.args["latitude"],event.args["longitude"],10,10) # splinter_coords = findOffset(event.args["latitude"],event.args["longitude"],-10,-10) donatello( moveTo(float(d2[poiIndex]["lat"]), float(d2[poiIndex]["lng"]), 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) leonardo( moveTo(float(d3[poiIndex]["lat"]), float(d3[poiIndex]["lng"]), 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) michelangelo( moveTo(float(d4[poiIndex]["lat"]), float(d4[poiIndex]["lng"]), 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) raphael( moveTo(float(d5[poiIndex]["lat"]), float(d5[poiIndex]["lng"]), 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) splinter( moveTo(float(d6[poiIndex]["lat"]), float(d6[poiIndex]["lng"]), 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) casey( moveTo(float(d7[poiIndex]["lat"]), float(d7[poiIndex]["lng"]), 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) # casey(moveTo(casey_coords[0], casey_coords[1], 10, MoveTo_Orientation_mode.TO_TARGET, 0.0)) # donatello(moveTo(donatello_coords[0], donatello_coords[1], 15, MoveTo_Orientation_mode.TO_TARGET, 0.0)) # leonardo(moveTo(leonardo_coords[0], leonardo_coords[1], 20, MoveTo_Orientation_mode.TO_TARGET, 0.0)) # michelangelo(moveTo(michelangelo_coords[0], michelangelo_coords[1], 25, MoveTo_Orientation_mode.TO_TARGET, 0.0)) # raphael(moveTo(raphael_coords[0], raphael_coords[1], 30, MoveTo_Orientation_mode.TO_TARGET, 0.0)) # splinter(moveTo(splinter_coords[0], splinter_coords[1], 35, MoveTo_Orientation_mode.TO_TARGET, 0.0)) print( "latitude = {latitude} longitude = {longitude} altitude = {altitude}" .format(**event.args))
print("Drone moving "+str(FW*math.cos(DIRECTION*math.pi/180))+" m forward and "+str(FW*math.sin(DIRECTION*math.pi/180))+" up.") drone( moveBy(FW*math.cos(DIRECTION*math.pi/180), 0, -FW*math.sin(DIRECTION*math.pi/180), 0) >> FlyingStateChanged(state="hovering", _timeout=5) ).wait() saver = threading.Thread(target=save_packets, args=(seconds, paths_CR1[STEP], CR1, paths_CR2[STEP], CR2)) saver.start() saver.join() print("\n\n\n ---- Experience finished, Back to home ---- \n\n\n") drone( moveTo(drone_home['latitude'], drone_home['longitude'], drone_home['altitude'], MoveTo_Orientation_mode.NONE, 0.0) >> moveToChanged(status='DONE') ).wait() print("\n\n\n ---- Landing... ---- \n\n\n") drone( Landing() ).wait() print("\n\n\n ---- Drone landed ---- \n\n\n") #Leaving the with statement and disconnecting the drone. print("Ending thread:", threading.current_thread().name)
casey.connect() donatello.connect() leonardo.connect() michelangelo.connect() every_event_listener.unsubscribe() # You can also subscribe/unsubscribe automatically using a with statement with FlightListener(drone) as flight_listener: for i in range(2): assert drone( FlyingStateChanged(state="hovering") | (TakeOff() & FlyingStateChanged(state="hovering")) ).wait().success() assert drone( FlyingStateChanged(state="hovering", _timeout=5) >> moveTo(21.371518652227294, -157.71239, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.371518652227294, -157.7116182859902, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.3708, -157.7116182859902, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.370081347772704, -157.7116182859902, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.370081347772704, -157.71239, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.370081347772704, -157.7131617140098, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.3708, -157.7131617140098, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.371518652227294, -157.7131617140098, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE")
def moveCasey(coords): casey( moveTo(coords[0], coords[1], 0.8, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> PCMD(1, 0, 0, 0, 0, 0) >> FlyingStateChanged( state="hovering", _timeout=5)).wait().success()
michelangelo.connect() raphael.connect() splinter.connect() every_event_listener.unsubscribe() # You can also subscribe/unsubscribe automatically using a with statement with FlightListener(drone) as flight_listener: for i in range(2): assert drone( FlyingStateChanged(state="hovering") | (TakeOff() & FlyingStateChanged(state="hovering")) ).wait().success() assert drone( FlyingStateChanged(state="hovering", _timeout=5) >> moveTo(21.36882162,-157.713277, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.36945383,-157.7133445, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37028804,-157.7134336, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37040696,-157.7134463, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37055568,-157.7134622, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37079381,-157.7134876, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37096092,-157.7135054, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE") >> moveTo(21.37136676,-157.7135488, 15, MoveTo_Orientation_mode.TO_TARGET, 0.0) >> moveToChanged(status="DONE")