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


Python LogConfig.delete方法代码示例

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


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

示例1: __init__

# 需要导入模块: from cflib.crazyflie.log import LogConfig [as 别名]
# 或者: from cflib.crazyflie.log.LogConfig import delete [as 别名]

#.........这里部分代码省略.........
		# t = Timer(20, self.m_CrazyFlie.close_link)  # Start a timer to automatically disconnect in 20s
		# t.start()

		# Prepare for take off: clear PIDs, log start time...
		self.cf_str_status = "TAKING OFF"
		self.t_start = datetime.now()
		self.cf_PID_roll.clear()
		self.cf_PID_pitch.clear()
		self.cf_PID_yaw.clear()
		self.cf_PID_thrust.clear()

		# Alright, let's fly!
		tStop = None
		while tStop is None:  # tStop will remain None while everything's fine
			tStop = self.hover()  # hover returns None while everything's fine; the time to end the experiment otherwise

		# If we get here, either the user stopped the experiment or the code detected something went wrong
		print "AT t={}, A KEY WAS PRESSED -> STOPPING!".format(datetime.now().strftime("%H:%M:%S.%f")[:-3])
		save_logs = (self.cf_str_status != "TAKING OFF")  # Only store the logs if the drone ever started flying (not just took off)
		self.cf_str_status = "STOPPED"  # Updated new drone status

		while datetime.now() < tStop:  # Keep calling hover until tStop, so data is still logged
			self.hover()

		return save_logs  # Return whether or not to keep the logs

	def cleanup_experiment(self, save_logs=True):
		"""
		"Cleans up" the experiment: closes any open windows, saves logs, disconnects camera and drone, etc.
		"""
		# If we get here, either the user ended the experiment, or an exception occurred. Same action regardless:
		if self.cf_log is not None:  # If we were logging data from the CF, stop it (will reconnect faster next time)
			self.cf_log.stop()
			self.cf_log.delete()
		if self.crazyflie is not None:  # If the CF was ever initialized, make sure the communication link is closed
			self.crazyflie.close_link()

		self.video_capture = None  # Destroy the video capture object (this takes care of closing the camera etc.)
		cv2.destroyAllWindows()  # Close all UI windows that could be open
		if self.window_for_kb_input is not None:
			self.window_for_kb_input.hide()
			sdl2.ext.quit()

		if save_logs:  # If the experiment didn't crash before starting (the CF ever took off), plot and save the logs
			self.experiment_log.plot(False)
			self.experiment_log.save()
		else:  # Otherwise just delete the folder (and its contents) where cam frames would have been/were saved
			shutil.rmtree(self.VIDEO_FOLDER, ignore_errors=False)

	def run_experiment(self):
		"""
		DroneController's main method: initializes all components (vision, communication, drone params, etc.) then
		runs the experiment.
		"""
		logging.disable(logging.DEBUG)  # Seems to work better than .basicConfig(INFO), especially if logging has already been initialized -> Only show messages of level INFO or higher

		save_logs = True  # Use this auxiliary variable to prevent saving logs if the drone never took off
		try:
			self.connect_to_cf()  # Connect to the CrazyFlie
			self.setup_cf()  # Can't initialize LogConfig until we're connected, because it needs to check that the variables we'd like to add are in the TOC. So this function must be called after connect_to_cf()
			self.init_video_cam_and_cv_algorithm()  # Connect to the first available camera, load default settings, etc.
			self.init_UI_window()  # Open a window to receive user input to control the CF
			save_logs = self.fly_cf()  # And finally fly the CF
		except:
			logging.exception("Shutting down due to an exception =( See details below:")
开发者ID:CarlosRDomin,项目名称:SensorFlySwarm,代码行数:69,代码来源:full_control_with_cam.py


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