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


Python SITL.stop方法代码示例

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


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

示例1: test_can_arm

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
def test_can_arm():
    sitl = SITL()
    sitl.download('copter', '3.3')
    sitl.launch(copter_args, verbose=True, await_ready=True)
    vehicle = dronekit.connect("tcp:127.0.0.1:5760", wait_ready=True)
    # Wait for vehicle to be armable
    timeout = time.time() + 10
    while not vehicle.is_armable and time.time() < timeout:
        time.sleep(0.35)
    timed_out = time.time() >= timeout
    if timed_out:
        sitl.stop()
    assert_false(timed_out, "Vehicle init timed out")

    # Arm it
    vehicle.mode = dronekit.VehicleMode("GUIDED")
    vehicle.armed = True

    # Confirm that it armed
    timeout = time.time() + 10
    while not vehicle.armed and time.time() < timeout:
        time.sleep(0.35)
    timed_out = time.time() >= timeout
    vehicle.close()
    sitl.stop()
    assert_false(timed_out, "Vehicle arming timed out")
开发者ID:sciencectn,项目名称:dronekit-sitl,代码行数:28,代码来源:test_sitl.py

示例2: test_sitl

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
def test_sitl():
    sitl = SITL()
    sitl.download('copter', '3.3')
    sitl.launch(copter_args)
    sitl.block_until_ready()
    
    assert_equals(sitl.poll(), None, 'SITL should still be running.')
    assert_equals(sitl.using_sim, False, 'SITL for copter-3.3 should not be using pysim')

    sitl.stop()
    assert sitl.poll() != None, 'SITL should stop running after kill.'

    # Test "relaunch"
    sitl.launch(copter_args)
    try:
    	sitl.launch(copter_args)
    	assert False, 'SITL should fail to launch() again when running'
    except:
    	pass
    try:
    	sitl.launch(copter_args, restart=True)
    except:
    	assert False, 'SITL should succeed in launch() when restart=True'

    sitl.stop()
开发者ID:AndriiDSD,项目名称:dronekit-sitl,代码行数:27,代码来源:test_sitl.py

示例3: test_set_current

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
 def test_set_current(self):
     sitl = SITL()
     sitl.download('copter', '3.3', verbose=True)
     sitl_args = ['-I0', '--model', 'quad', '--home=-35.363261,149.165230,584,353']
     sitl.launch(sitl_args, await_ready=True, restart=True)
     print "Connecting to vehicle on: 'tcp:127.0.0.1:5760'"
     vehicle = connect('tcp:127.0.0.1:5760', wait_ready=True)
     print " Battery: %s" % vehicle.battery
     battery_test = Battery(vehicle.battery)
     # check number negative the limit
     battery_test.set_current(NEGATIVE_NUMBER)
     self.assertEqual(battery_test.current, 0)
     # check number positive the limit
     battery_test.set_current(POSITIVE_NUMBER)
     self.assertEqual(battery_test.get_current(), POSITIVE_NUMBER)
     # check ZERO
     battery_test.set_current(0)
     self.assertEqual(battery_test.get_current(), 0)
     #check char that non number
     battery_test.set_current(CHARACTER)
     self.assertEqual(battery_test.get_current(), 0)
     #check char that  number
     battery_test.set_current(CHAR_NUMBER)
     self.assertEqual(battery_test.get_current(), int(CHAR_NUMBER))
     sitl.stop()
开发者ID:adiGr,项目名称:FinalProjectDrone,代码行数:27,代码来源:test_battery.py

示例4: test_land

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
 def test_land(self):
     sitl = SITL()
     sitl.download('copter', '3.3', verbose=True)
     sitl_args = ['-I0', '--model', 'quad', '--home=31.768923,35.193595,0,0']
     sitl.launch(sitl_args, await_ready=True, restart=True)
     drone = Drone('tcp:127.0.0.1:5760')
     headBefor =drone.vehicle.heading
     locBefor = drone.vehicle.location.global_relative_frame
     drone.take_off(25)
     print drone.vehicle.location.global_relative_frame
     drone.land()
     print drone.vehicle.location.global_relative_frame
     drone.take_off(4)
     print drone.vehicle.location.global_relative_frame
     drone.land()
     print drone.vehicle.location.global_relative_frame
     drone.take_off(2)
     print drone.vehicle.location.global_relative_frame
     drone.land()
     print drone.vehicle.location.global_relative_frame
     drone.take_off(10)
     print drone.vehicle.location.global_relative_frame
     drone.land()
     print drone.vehicle.location.global_relative_frame
     drone.vehicle.close()
     sitl.stop()
开发者ID:adiGr,项目名称:FinalProjectDrone,代码行数:28,代码来源:test_drone.py

示例5: test_take_off

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
 def test_take_off(self):
     sitl = SITL()
     sitl.download('copter', '3.3', verbose=True)
     sitl_args = ['-I0', '--model', 'quad', '--home=31.768923,35.193595,0,0']
     sitl.launch(sitl_args, await_ready=True, restart=True)
     drone = Drone('tcp:127.0.0.1:5760')
     headBefor =drone.vehicle.heading
     locBefor = drone.vehicle.location.global_relative_frame
     drone.take_off(3)
     headAfter = drone.vehicle.heading
     locAfter = drone.vehicle.location.global_relative_frame
     self.assertTrue( round(locAfter.alt-locBefor.alt)==3 and ((headBefor+5)%360<headAfter or(headBefor-5)%360 >headAfter))
     drone.vehicle.close()
     sitl.stop()
开发者ID:adiGr,项目名称:FinalProjectDrone,代码行数:16,代码来源:test_drone.py

示例6: test_preserve_eeprom

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
def test_preserve_eeprom():
    # Start an SITL instance and change SYSID_THISMAV
    print "test"
    sitl = SITL()
    sitl.download('copter', '3.3')
    new_sysid = 10
    working_dir = tempfile.mkdtemp()
    sitl.launch(copter_args, verbose=True, await_ready=True, use_saved_data=True, wd=working_dir)
    vehicle = dronekit.connect("tcp:127.0.0.1:5760", wait_ready=True)
    print "Changing SYSID_THISMAV to {0}".format(new_sysid)
    while vehicle.parameters["SYSID_THISMAV"] != new_sysid:
        vehicle.parameters["SYSID_THISMAV"] = new_sysid
        time.sleep(0.1)
    time.sleep(6)   # Allow time for the parameter to go back to EEPROM
    print "Changed SYSID_THISMAV to {0}".format(new_sysid)
    vehicle.close()
    sitl.stop()

    # Now see if it persisted
    sitl.launch(copter_args, await_ready=True, use_saved_data=True, wd=working_dir)
    vehicle = dronekit.connect("tcp:127.0.0.1:5760", wait_ready=True)
    assert_equals(new_sysid, vehicle.parameters["SYSID_THISMAV"])
    vehicle.close()
    sitl.stop()
开发者ID:sciencectn,项目名称:dronekit-sitl,代码行数:26,代码来源:test_sitl.py

示例7: test_preserve_eeprom

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
def test_preserve_eeprom():
    # Start an SITL instance and change COMPASS_USE
    sitl = SITL()
    sitl.download('copter', '3.3')
    sitl.launch(copter_args, verbose=True, await_ready=True, use_saved_data=False)
    connection_string = sitl.connection_string()
    vehicle = dronekit.connect(connection_string, wait_ready=True)
    new_compass_use = 10
    print("Changing COMPASS_USE to {0}".format(new_compass_use))
    while vehicle.parameters["COMPASS_USE"] != new_compass_use:
        vehicle.parameters["COMPASS_USE"] = new_compass_use
        time.sleep(0.1)
    print("Changed COMPASS_USE to {0}".format(new_compass_use))
    time.sleep(5) # give parameters time to write
    sitl.stop()
    vehicle.close()

    # Now see if it persisted
    sitl.launch(copter_args, await_ready=True, use_saved_data=True)
    vehicle = dronekit.connect(connection_string, wait_ready=True)
    assert_equals(new_compass_use, vehicle.parameters["COMPASS_USE"])

    vehicle.close()
    sitl.stop()
开发者ID:dronekit,项目名称:dronekit-sitl,代码行数:26,代码来源:test_sitl.py

示例8: arm_and_takeoff

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
arm_and_takeoff(10)

print "Set default/target airspeed to 3"
vehicle.airspeed = 3

print "Going towards first point for 30 seconds ..."
point1 = LocationGlobalRelative(-35.361354, 149.165218, 20)
vehicle.simple_goto(point1)

# sleep so we can see the change in map
time.sleep(30)

print "Going towards second point for 30 seconds (groundspeed set to 10 m/s) ..."
point2 = LocationGlobalRelative(-35.363244, 149.168801, 20)
vehicle.simple_goto(point2, groundspeed=10)

# sleep so we can see the change in map
time.sleep(30)

print "Returning to Launch"
vehicle.mode = VehicleMode("RTL")

#Close vehicle object before exiting script
print "Close vehicle object"
vehicle.close()

# Shut down simulator if it was started.
if sitl is not None:
    sitl.stop()
开发者ID:Aerobota,项目名称:dronekit-python,代码行数:31,代码来源:simple_goto.py

示例9: countdown

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
            break
        time.sleep(1)

def countdown(amtTime):
    i = 0
    while i <= amtTime:
        print("COUNTDOWN: "+str(amtTime-i))
        time.sleep(1)
        i = i+1

def countdownAlt(amTime):
    o = 0
    while o <= amTime:
        print("COUNTDOWN: "+str(amTime-o))
        print " Altitude: ", vehicle.location.global_relative_frame.alt
        time.sleep(1)
        o = o+1

countdown(5)
cmds = vehicle.commands
cmds.download()
cmds.wait_ready()
home = vehicle.home_location
print home.lat
print home.lon
arm_and_takeoff(2);
vehicle.mode    = VehicleMode("RTL")
countdownAlt(30);
sitl.stop();
print("Done")
开发者ID:sohanvichare,项目名称:AutoDrone,代码行数:32,代码来源:sitl.py

示例10: test_move_left

# 需要导入模块: from dronekit_sitl import SITL [as 别名]
# 或者: from dronekit_sitl.SITL import stop [as 别名]
    def test_move_left(self):
        """"
        sitl = SITL()
        sitl.download('copter', '3.3', verbose=True)
        sitl_args = ['-I0', '--model', 'quad', '--home=31.768923,35.193595,0,0']
        sitl.launch(sitl_args, await_ready=True, restart=True)
        drone = Drone('tcp:127.0.0.1:5760')
        drone.take_off(2)
        print drone.vehicle.location.global_relative_frame
        drone.move_left(2)
        print drone.vehicle.location.global_relative_frame
        drone.land()
        drone.vehicle.close()
        sitl.stop()
        """""
        """"
        sitl = SITL()
        sitl.download('copter', '3.3', verbose=True)
        sitl_args = ['-I0', '--model', 'quad', '--home=31.768923,35.193595,0,45']
        sitl.launch(sitl_args, await_ready=True, restart=True)
        drone = Drone('tcp:127.0.0.1:5760')
        drone.take_off(2)
        print drone.vehicle.location.global_relative_frame
        drone.move_left(2)
        print drone.vehicle.location.global_relative_frame
        drone.land()
        drone.vehicle.close()
        sitl.stop()
        #self.assertTrue(True)
        """
        """"
        sitl = SITL()
        sitl.download('copter', '3.3', verbose=True)
        sitl_args = ['-I0', '--model', 'quad', '--home=31.768923,35.193595,0,90']
        sitl.launch(sitl_args, await_ready=True, restart=True)
        drone = Drone('tcp:127.0.0.1:5760')
        drone.take_off(2)
        print drone.vehicle.location.global_relative_frame
        drone.move_left(2)
        print drone.vehicle.location.global_relative_frame
        drone.land()
        drone.vehicle.close()
        sitl.stop()
        #self.assertTrue(True)
        """
        """"
        sitl = SITL()
        sitl.download('copter', '3.3', verbose=True)
        sitl_args = ['-I0', '--model', 'quad', '--home=31.768923,35.193595,0,135']
        sitl.launch(sitl_args, await_ready=True, restart=True)
        drone = Drone('tcp:127.0.0.1:5760')
        drone.take_off(2)
        print drone.vehicle.location.global_relative_frame
        drone.move_left(2)
        print drone.vehicle.location.global_relative_frame
        drone.land()
        drone.vehicle.close()
        sitl.stop()
        #self.assertTrue(True)
        """
        """"
        sitl = SITL()
        sitl.download('copter', '3.3', verbose=True)
        sitl_args = ['-I0', '--model', 'quad', '--home=31.768923,35.193595,0,180']
        sitl.launch(sitl_args, await_ready=True, restart=True)
        drone = Drone('tcp:127.0.0.1:5760')
        drone.take_off(2)
        print drone.vehicle.location.global_relative_frame
        drone.move_left(2)
        print drone.vehicle.location.global_relative_frame
        drone.land()
        drone.vehicle.close()
        sitl.stop()
        #self.assertTrue(True)
        """
        """"
        sitl = SITL()
        sitl.download('copter', '3.3', verbose=True)
        sitl_args = ['-I0', '--model', 'quad', '--home=31.768923,35.193595,0,225']
        sitl.launch(sitl_args, await_ready=True, restart=True)
        drone = Drone('tcp:127.0.0.1:5760')
        drone.take_off(2)
        print drone.vehicle.location.global_relative_frame
        drone.move_left(2)
        print drone.vehicle.location.global_relative_frame
        drone.land()
        drone.vehicle.close()
        sitl.stop()
        #self.assertTrue(True)
        """

        sitl = SITL()
        sitl.download('copter', '3.3', verbose=True)
        sitl_args = ['-I0', '--model', 'quad', '--home=31.768923,35.193595,0,270']
        sitl.launch(sitl_args, await_ready=True, restart=True)
        drone = Drone('tcp:127.0.0.1:5760')
        drone.take_off(2)
        print drone.vehicle.location.global_relative_frame
        drone.move_left(2)
        print drone.vehicle.location.global_relative_frame
#.........这里部分代码省略.........
开发者ID:adiGr,项目名称:FinalProjectDrone,代码行数:103,代码来源:test_drone.py


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