当前位置: 首页>>代码示例>>Python>>正文


Python dronekit.VehicleMode方法代码示例

本文整理汇总了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 
开发者ID:patrickpoirier51,项目名称:OpenTracker,代码行数:26,代码来源:balloon_strategy.py

示例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 
开发者ID:ghostop14,项目名称:sparrow-wifi,代码行数:24,代码来源:sparrowdrone.py

示例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 
开发者ID:patrickpoirier51,项目名称:OpenTracker,代码行数:27,代码来源:balloon_strategy_2.py

示例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) 
开发者ID:tizianofiorenzani,项目名称:how_do_drones_work,代码行数:18,代码来源:plane.py

示例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 
开发者ID:tizianofiorenzani,项目名称:how_do_drones_work,代码行数:26,代码来源:05_trajectory_tracking.py

示例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 
开发者ID:tizianofiorenzani,项目名称:how_do_drones_work,代码行数:26,代码来源:02_control_with_arrow_keys.py

示例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) 
开发者ID:tizianofiorenzani,项目名称:how_do_drones_work,代码行数:24,代码来源:04_mission.py

示例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) 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:34,代码来源:follow_me.py

示例9: setMode

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def setMode(mode):
    # Now change the vehicle into auto mode
    vehicle.mode = VehicleMode(mode) 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:5,代码来源:microgcs.py

示例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) 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:9,代码来源:drone_delivery.py

示例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) 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:37,代码来源:flight_replay.py

示例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 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:37,代码来源:guided_set_speed_yaw.py

示例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) 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:36,代码来源:simple_goto.py

示例14: test_vehicle_mode_eq

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import VehicleMode [as 别名]
def test_vehicle_mode_eq():
    assert_equals(VehicleMode('GUIDED'), VehicleMode('GUIDED')) 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:4,代码来源:test_api.py

示例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')) 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:4,代码来源:test_api.py


注:本文中的dronekit.VehicleMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。