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


Python dronekit.connect方法代码示例

本文整理汇总了Python中dronekit.connect方法的典型用法代码示例。如果您正苦于以下问题:Python dronekit.connect方法的具体用法?Python dronekit.connect怎么用?Python dronekit.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dronekit的用法示例。


在下文中一共展示了dronekit.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_timeout

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def test_timeout(connpath):
    v = connect(connpath, wait_ready=True)

    value = v.parameters['THR_MIN']
    assert_equals(type(value), float)

    start = current_milli_time()
    v.parameters['THR_MIN'] = value + 10
    end = current_milli_time()

    newvalue = v.parameters['THR_MIN']
    assert_equals(type(newvalue), float)
    assert_equals(newvalue, value + 10)

    # Checks that time to set parameter was <1s
    # see https://github.com/dronekit/dronekit-python/issues/12
    assert end - start < 1000, 'time to set parameter was %s, over 1s' % (end - start, )

    v.close() 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:21,代码来源:test_12.py

示例2: test_reboot

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def test_reboot(connpath):
    """Tries to reboot the vehicle, and checks that the autopilot ACKs the command."""

    vehicle = connect(connpath, wait_ready=True)

    reboot_acks = []

    def on_ack(self, name, message):
        if message.command == 246:  # reboot/shutdown
            reboot_acks.append(message)

    vehicle.add_message_listener('COMMAND_ACK', on_ack)
    vehicle.reboot()
    time.sleep(0.5)
    vehicle.remove_message_listener('COMMAND_ACK', on_ack)

    assert_equal(1, len(reboot_acks))  # one and only one ACK
    assert_equal(246, reboot_acks[0].command)  # for the correct command
    assert_equal(0, reboot_acks[0].result)  # the result must be successful

    vehicle.close() 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:23,代码来源:test_reboot.py

示例3: test_mavlink

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def test_mavlink(connpath):
    vehicle = connect(connpath, wait_ready=True)
    out = MAVConnection('udpin:localhost:15668')
    vehicle._handler.pipe(out)
    out.start()

    vehicle2 = connect('udpout:localhost:15668', wait_ready=True)

    result = {'success': False}

    @vehicle2.on_attribute('location')
    def callback(*args):
        result['success'] = True

    i = 20
    while not result['success'] and i > 0:
        time.sleep(1)
        i -= 1

    assert result['success']

    vehicle2.close()
    vehicle.close() 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:25,代码来源:test_mavlink.py

示例4: test_115

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def test_115(connpath):
    """Provide a custom status_printer function to the Vehicle and check that
    the autopilot messages are correctly logged.
    """

    logging_check = {'ok': False}

    def errprinter_fn(msg):
        if isinstance(msg, str) and "APM:Copter" in msg:
            logging_check['ok'] = True

    vehicle = connect(connpath, wait_ready=False, status_printer=errprinter_fn)

    i = 5
    while not logging_check['ok'] and i > 0:
        time.sleep(1)
        i -= 1

    assert_true(logging_check['ok'])
    vehicle.close()

    # Cleanup the logger
    autopilotLogger = logging.getLogger('autopilot')
    autopilotLogger.removeHandler(autopilotLogger.handlers[0]) 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:26,代码来源:test_errprinter.py

示例5: test_parameters

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def test_parameters(connpath):
    vehicle = connect(connpath)

    # When called on startup, parameter (may!) be none.
    # assert_equals(vehicle.parameters.get('THR_MIN', wait_ready=False), None)

    # With wait_ready, it should not be none.
    assert_not_equals(vehicle.parameters.get('THR_MIN', wait_ready=True), None)

    try:
        assert_not_equals(vehicle.parameters['THR_MIN'], None)
    except:
        assert False

    # Garbage value after all parameters are downloaded should be None.
    assert_equals(vehicle.parameters.get('xXx_extreme_garbage_value_xXx', wait_ready=True), None)

    vehicle.close() 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:20,代码来源:test_parameters.py

示例6: test_set_home

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def test_set_home(connpath):
    vehicle = connect(connpath, wait_ready=True)

    # Wait for home position to be real and not 0, 0, 0
    # once we request it via cmds.download()
    time.sleep(10)
    vehicle.commands.download()
    vehicle.commands.wait_ready()
    assert_not_equals(vehicle.home_location, None)

    # Note: If the GPS values differ heavily from EKF values, this command
    # will basically fail silently. This GPS coordinate is tailored for that
    # the with_sitl initializer uses to not fail.
    vehicle.home_location = LocationGlobal(-35, 149, 600)
    vehicle.commands.download()
    vehicle.commands.wait_ready()

    assert_equals(vehicle.home_location.lat, -35)
    assert_equals(vehicle.home_location.lon, 149)
    assert_equals(vehicle.home_location.alt, 600)

    vehicle.close() 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:24,代码来源:test_waypoints.py

示例7: test_227

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def test_227(connpath):
    """
    Tests race condition when downloading items
    """

    vehicle = connect(connpath, wait_ready=True)

    def assert_commands(count):
        vehicle.commands.download()
        vehicle.commands.wait_ready()
        assert_equals(len(vehicle.commands), count)

    assert_commands(0)

    vehicle.commands.add(Command(0, 0, 0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT,
                                 mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 0, 0, 0, 0, 0, 10, 10,
                                 10))
    vehicle.flush()  # Send commands

    assert_commands(1)

    vehicle.close() 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:24,代码来源:test_waypoints.py

示例8: test_accelerometer_calibration

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def test_accelerometer_calibration(connpath):
    """Request accelerometer calibration, and check for the COMMAND_ACK."""

    vehicle = connect(connpath, wait_ready=True)

    # The calibration is expected to fail because in the SITL we don't tilt the Vehicle.
    # We just check that the command isn't denied or unsupported.
    with assert_command_ack(
        vehicle,
        mavutil.mavlink.MAV_CMD_PREFLIGHT_CALIBRATION,
        timeout=30,
        ack_result=mavutil.mavlink.MAV_RESULT_FAILED,
    ):
        vehicle.send_calibrate_accelerometer(simple=False)

    vehicle.close() 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:18,代码来源:test_sensor_calibration.py

示例9: test_timeout_empty

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def test_timeout_empty():
    # Create a dummy server.
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(('127.0.0.1', 5760))
    s.listen(1)

    try:
        # Connect with timeout of 10s.
        vehicle = connect('tcp:127.0.0.1:5760', wait_ready=True, heartbeat_timeout=20)

        vehicle.close()

        # Should not pass
        assert False
    except:
        pass 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:19,代码来源:test_timeout.py

示例10: vehicle_connect

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def vehicle_connect():
    global vehicle, is_vehicle_connected
    
    try:
        vehicle = connect(connection_string, wait_ready = True, baud = connection_baudrate, source_system = 1)
    except:
        print('Connection error! Retrying...')
        sleep(1)

    if vehicle == None:
        is_vehicle_connected = False
        return False
    else:
        is_vehicle_connected = True
        return True

######################################################
##  Functions - D4xx cameras                        ##
###################################################### 
开发者ID:thien94,项目名称:vision_to_mavros,代码行数:21,代码来源:d4xx_to_mavlink.py

示例11: vehicle_connect

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def vehicle_connect():
    global vehicle, is_vehicle_connected
    
    try:
        vehicle = connect(connection_string, wait_ready = True, baud = connection_baudrate, source_system = 1)
    except:
        print('Connection error! Retrying...')
        sleep(1)

    if vehicle == None:
        is_vehicle_connected = False
        return False
    else:
        is_vehicle_connected = True
        return True

# List of notification events: https://github.com/IntelRealSense/librealsense/blob/development/include/librealsense2/h/rs_types.h
# List of notification API: https://github.com/IntelRealSense/librealsense/blob/development/common/notifications.cpp 
开发者ID:thien94,项目名称:vision_to_mavros,代码行数:20,代码来源:t265_to_mavlink.py

示例12: vehicle_connect

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def vehicle_connect():
    global vehicle

    try:
        vehicle = connect(connection_string, wait_ready = True, baud = connection_baudrate, source_system = 1)
    except KeyboardInterrupt:    
        pipe.stop()
        print("INFO: Exiting")
        sys.exit()
    except:
        print('Connection error! Retrying...')

    if vehicle == None:
        return False
    else:
        return True

# Connect to the T265 through USB 3.0 (must be USB 3.0 since image streams are being consumed) 
开发者ID:thien94,项目名称:vision_to_mavros,代码行数:20,代码来源:t265_precland_apriltags.py

示例13: main

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def main(top_block_cls=control_gui, options=None):

    from distutils.version import StrictVersion
    if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
        style = gr.prefs().get_string('qtgui', 'style', 'raster')
        Qt.QApplication.setGraphicsSystem(style)
    qapp = Qt.QApplication(sys.argv)
    
    tb = top_block_cls()
    #connection_string = tb.sitl.connection_string()
    #print connection_string
    tb.connect_to_vehicle('udp:127.0.0.1:14562')
    tb.start()
    tb.show()

    # Connect to the Vehicle.
    #print("Connecting to vehicle on: %s" % (connection_string,))
    #vehicle = connect(connection_string, wait_ready=True)
    def quitting():
        tb.stop()
        tb.wait()
    qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
    qapp.exec_() 
开发者ID:deptofdefense,项目名称:gr-uaslink,代码行数:25,代码来源:control_gui_override.py

示例14: closeEvent

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def closeEvent(self, event):
        self.settings = Qt.QSettings("GNU Radio", "control_gui")
        self.settings.setValue("geometry", self.saveGeometry())
        event.accept()
    
    #def connect_to_vehicle(self,connection_string,baud_rate):
    #    self.connection_string=connection_string
    #    self.baud_rate=baud_rate
    #    print("Connecting to vehicle on: %s" % (self.connection_string,))
        #self.vehicle = connect(self.connection_string,baud=57600, wait_ready='gps_0')
   #     self.mavlink_connection = mavutil.mavlink_connection(self.connection,   baud=self.baud_rate)
   #     print("connected")
    #def send_rc(master, data):
	#    for i in xrange(1):
	#	    self.mavlink_connection.mav.rc_channels_override_encode (
	#		     master.target_system, master.target_component, *data)
    #        print ("sending rc: %s"%data) 
开发者ID:deptofdefense,项目名称:gr-uaslink,代码行数:19,代码来源:control_gui_override_mavutil.py

示例15: main

# 需要导入模块: import dronekit [as 别名]
# 或者: from dronekit import connect [as 别名]
def main(top_block_cls=control_gui, options=None):

    from distutils.version import StrictVersion
    if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
        style = gr.prefs().get_string('qtgui', 'style', 'raster')
        Qt.QApplication.setGraphicsSystem(style)
    qapp = Qt.QApplication(sys.argv)
    
    tb = top_block_cls()
    #connection_string = tb.sitl.connection_string()
    #print connection_string
    #tb.connect_to_vehicle('udp:127.0.0.1:14552',baud_rate)
    tb.zmq_setup('tcp://127.0.0.1:14000')
    tb.start()
    tb.show()

    # Connect to the Vehicle.
    #print("Connecting to vehicle on: %s" % (connection_string,))
    #vehicle = connect(connection_string, wait_ready=True)
    def quitting():
        tb.stop()
        tb.wait()
    qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
    qapp.exec_() 
开发者ID:deptofdefense,项目名称:gr-uaslink,代码行数:26,代码来源:control_gui_override_mavutil.py


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