def do_takeoff(args): try: ret = command.takeoff(min_pitch=args.min_pitch, yaw=args.yaw, latitude=args.latitude, longitude=args.longitude, altitude=args.altitude) except rospy.ServiceException as ex: fault(ex) _check_ret(args, ret)
def takeoff(altitude=0.1): print 'Taking off' try: ret = command.takeoff( min_pitch=0, yaw=0, latitude=0, longitude=0, altitude=altitude) except rospy.ServiceException as ex: fault(ex) if not ret.success: fault('Request failed. Check mavros logs')
def command_takeoff_cur(self, alt): """ Takeoff at the current GPS position """ if self.global_position is not None: ret = command.takeoff(min_pitch=0, yaw=0, latitude=self.global_position.latitude, longitude=self.global_position.longitude, altitude=alt) return ret.success else: rospy.logerr("Cannot do takeoff, no GPS data.") return False
def startFlight(self): self.setMode(mode='GUIDED') self.arm() command.takeoff(min_pitch=0, yaw=1, latitude=self.lat, longitude=self.lng, altitude=10) rospy.sleep(TRAVEL_TIME) pub_thread = threading.Thread(target=self.publishPos) pub_thread.start() for point in self.flight_path: self.setPosition(point[0], point[1], point[2]) rospy.sleep(TRAVEL_TIME) self._is_done = True pub_thread.join() command.land(min_pitch=0.0, yaw=0, latitude=self.lat, longitude=self.lng, altitude=0.0)
def takeoff(self): if self.takeoff: print("Vehicle has already Taken Off") else: try: alt = param.param_get("MIS_TAKEOFF_ALT") print("Taking off at Current Latitude = %3f Longitude = %3f" % (self.latitude, self.longitude)) ret = command.takeoff(min_pitch=0, yaw=0, latitude=self.latitude, longitude=self.longitude, altitude=alt) while self.altitude <= (alt - 0.1): continue self.takeoff = True if not ret.success: utils.fault("Request failed. Check mavros logs") except rospy.ServiceException as ex: utils.fault(ex) print("Takeoff Command result: %s" % (self.takeoff == True))
#!/usr/bin/env python import mavros from mavros import command mavros.set_namespace() # arming command.arming(True) # takeoff command.takeoff(altitude=5, latitude=0, longitude=0, min_pitch=0, yaw=0) # disarming command.arming(False)