本文整理汇总了Python中dronekit.VehicleMode方法的典型用法代码示例。如果您正苦于以下问题:Python dronekit.VehicleMode方法的具体用法?Python dronekit.VehicleMode怎么用?Python dronekit.VehicleMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dronekit
的用法示例。
在下文中一共展示了dronekit.VehicleMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: complete
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def complete(self):
# debug
if self.debug:
print "Complete!"
# stop the vehicle and give up control
if self.controlling_vehicle:
self.guided_target_vel = (0,0,0)
self.send_nav_velocity(self.guided_target_vel[0], self.guided_target_vel[1], self.guided_target_vel[2])
self.guided_last_update = time.time()
# if in GUIDED mode switch back to LOITER
if self.vehicle.mode.name == "GUIDED":
self.vehicle.mode = VehicleMode("LOITER")
self.vehicle.flush()
# if in AUTO move to next command
if self.vehicle.mode.name == "AUTO":
self.advance_current_cmd();
# flag we are not in control of the vehicle
self.controlling_vehicle = False
return
示例2: takeoff
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def takeoff(self, mode="STABILIZE", altitude=7):
# Mode can be GUIDED or STABILIZE
# altitude is in meters
if not self.vehicle:
return False
self.vehicle.mode = VehicleMode(mode)
if not self.vehicle.armed and self.vehicle.is_armable:
self.vehicle.armed = True
elif not self.vehicle.armed:
# Not armed and can't arm it. Just exit
return False
while not self.vehicle.armed:
sleep(1)
self.vehicle.simple_takeoff(altitude)
# self.vehicle.location.global_relative_frame.alt will tell you if it's there yet
# Say while < 0.95 * altitude
return True
示例3: complete
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def complete(self):
# debug
if self.debug:
print "Complete!"
# stop the vehicle and give up control
if self.controlling_vehicle:
self.guided_target_vel = (0,0,0)
self.send_nav_velocity(self.guided_target_vel[0], self.guided_target_vel[1], self.guided_target_vel[2])
self.guided_last_update = time.time()
# if in GUIDED mode switch back to LOITER
if self.vehicle.mode.name == "GUIDED":
self.vehicle.mode = VehicleMode("LOITER")
self.vehicle.flush()
# if in AUTO move to next command
if self.vehicle.mode.name == "AUTO":
self.advance_current_cmd();
# flag we are not in control of the vehicle
self.controlling_vehicle = False
time.sleep(2.00)
return
示例4: set_ap_mode
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def set_ap_mode(self, mode): #--- Set Autopilot mode
""" Set Autopilot mode
"""
time_0 = time.time()
try:
tgt_mode = VehicleMode(mode)
except:
return(False)
while (self.get_ap_mode() != tgt_mode):
self.vehicle.mode = tgt_mode
time.sleep(0.2)
if time.time() < time_0 + 5:
return (False)
return (True)
示例5: arm_and_takeoff
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def arm_and_takeoff(altitude):
while not vehicle.is_armable:
print("waiting to be armable")
time.sleep(1)
print("Arming motors")
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
while not vehicle.armed: time.sleep(1)
print("Taking Off")
vehicle.simple_takeoff(altitude)
while True:
v_alt = vehicle.location.global_relative_frame.alt
print(">> Altitude = %.1f m"%v_alt)
if v_alt >= altitude - 1.0:
print("Target altitude reached")
break
time.sleep(1)
#-- Define the function for sending mavlink velocity command in body frame
示例6: arm_and_takeoff
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def arm_and_takeoff(altitude):
while not vehicle.is_armable:
print("waiting to be armable")
time.sleep(1)
print("Arming motors")
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
while not vehicle.armed: time.sleep(1)
print("Taking Off")
vehicle.simple_takeoff(altitude)
while True:
v_alt = vehicle.location.global_relative_frame.alt
print(">> Altitude = %.1f m"%v_alt)
if v_alt >= altitude - 1.0:
print("Target altitude reached")
break
time.sleep(1)
#-- Define the function for sending mavlink velocity command in body frame
示例7: arm_and_takeoff
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def arm_and_takeoff(altitude):
while not vehicle.is_armable:
print("waiting to be armable")
time.sleep(1)
print("Arming motors")
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
while not vehicle.armed: time.sleep(1)
print("Taking Off")
vehicle.simple_takeoff(altitude)
while True:
v_alt = vehicle.location.global_relative_frame.alt
print(">> Altitude = %.1f m"%v_alt)
if v_alt >= altitude - 1.0:
print("Target altitude reached")
break
time.sleep(1)
示例8: arm_and_takeoff
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def arm_and_takeoff(aTargetAltitude):
"""
Arms vehicle and fly to aTargetAltitude.
"""
print("Basic pre-arm checks")
# Don't let the user try to arm until autopilot is ready
while not vehicle.is_armable:
print(" Waiting for vehicle to initialise...")
time.sleep(1)
print("Arming motors")
# Copter should arm in GUIDED mode
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
while not vehicle.armed:
print(" Waiting for arming...")
time.sleep(1)
print("Taking off!")
vehicle.simple_takeoff(aTargetAltitude) # Take off to target altitude
# Wait until the vehicle reaches a safe height before processing the goto (otherwise the command
# after Vehicle.simple_takeoff will execute immediately).
while True:
print(" Altitude: ", vehicle.location.global_relative_frame.alt)
if vehicle.location.global_relative_frame.alt>=aTargetAltitude*0.95: #Trigger just below target alt.
print("Reached target altitude")
break
time.sleep(1)
示例9: setMode
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def setMode(mode):
# Now change the vehicle into auto mode
vehicle.mode = VehicleMode(mode)
示例10: change_mode
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def change_mode(self, mode):
self._log("Changing to mode: {0}".format(mode))
self.vehicle.mode = VehicleMode(mode)
while self.vehicle.mode.name != mode:
self._log(' ... polled mode: {0}'.format(mode))
time.sleep(1)
示例11: arm_and_takeoff
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def arm_and_takeoff(aTargetAltitude):
"""
Arms vehicle and fly to aTargetAltitude.
"""
# Don't try to arm until autopilot is ready
while not vehicle.is_armable:
print(" Waiting for vehicle to initialise...")
time.sleep(1)
# Set mode to GUIDED for arming and takeoff:
while (vehicle.mode.name != "GUIDED"):
vehicle.mode = VehicleMode("GUIDED")
time.sleep(0.1)
# Confirm vehicle armed before attempting to take off
while not vehicle.armed:
vehicle.armed = True
print(" Waiting for arming...")
time.sleep(1)
print(" Taking off!")
vehicle.simple_takeoff(aTargetAltitude) # Take off to target altitude
# Wait until the vehicle reaches a safe height
# before allowing next command to process.
while True:
requiredAlt = aTargetAltitude*0.95
#Break and return from function just below target altitude.
if vehicle.location.global_relative_frame.alt>=requiredAlt:
print(" Reached target altitude of ~%f" % (aTargetAltitude))
break
print(" Altitude: %f < %f" % (vehicle.location.global_relative_frame.alt,
requiredAlt))
time.sleep(1)
示例12: arm_and_takeoff
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def arm_and_takeoff(aTargetAltitude):
"""
Arms vehicle and fly to aTargetAltitude.
"""
print("Basic pre-arm checks")
# Don't let the user try to arm until autopilot is ready
while not vehicle.is_armable:
print(" Waiting for vehicle to initialise...")
time.sleep(1)
print("Arming motors")
# Copter should arm in GUIDED mode
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
while not vehicle.armed:
print(" Waiting for arming...")
time.sleep(1)
print("Taking off!")
vehicle.simple_takeoff(aTargetAltitude) # Take off to target altitude
# Wait until the vehicle reaches a safe height before processing the goto (otherwise the command
# after Vehicle.simple_takeoff will execute immediately).
while True:
print(" Altitude: ", vehicle.location.global_relative_frame.alt)
if vehicle.location.global_relative_frame.alt>=aTargetAltitude*0.95: #Trigger just below target alt.
print("Reached target altitude")
break
time.sleep(1)
#Arm and take of to altitude of 5 meters
示例13: arm_and_takeoff
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def arm_and_takeoff(aTargetAltitude):
"""
Arms vehicle and fly to aTargetAltitude.
"""
print("Basic pre-arm checks")
# Don't try to arm until autopilot is ready
while not vehicle.is_armable:
print(" Waiting for vehicle to initialise...")
time.sleep(1)
print("Arming motors")
# Copter should arm in GUIDED mode
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
# Confirm vehicle armed before attempting to take off
while not vehicle.armed:
print(" Waiting for arming...")
time.sleep(1)
print("Taking off!")
vehicle.simple_takeoff(aTargetAltitude) # Take off to target altitude
# Wait until the vehicle reaches a safe height before processing the goto
# (otherwise the command after Vehicle.simple_takeoff will execute
# immediately).
while True:
print(" Altitude: ", vehicle.location.global_relative_frame.alt)
# Break and return from function just below target altitude.
if vehicle.location.global_relative_frame.alt >= aTargetAltitude * 0.95:
print("Reached target altitude")
break
time.sleep(1)
示例14: test_vehicle_mode_eq
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def test_vehicle_mode_eq():
assert_equals(VehicleMode('GUIDED'), VehicleMode('GUIDED'))
示例15: test_vehicle_mode_neq
# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def test_vehicle_mode_neq():
assert_not_equals(VehicleMode('AUTO'), VehicleMode('GUIDED'))