【问题标题】:How to hide DroneKit-Python API messages如何隐藏 DroneKit-Python API 消息
【发布时间】:2018-11-07 15:37:08
【问题描述】:

快速提问。有什么方法可以隐藏或抑制来自 DroneKit-Python API 的消息(标记为红线)?

作为参考,下面是我使用的代码。

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

# setting up modules used in the program
from __future__ import print_function
from dronekit import connect
import exceptions
import socket
import time
import os

# connect to Rover
os.system("clear")
vehicle = connect('/dev/ttyS0', heartbeat_timeout = 30, baud = 57600)
time.sleep(2)

# instruction
print("\nPress [Ctrl] + [c] to quit.\n\n")
# 3 sec delay
time.sleep(3)

# measure distance
while True:

    # reading from rangefinder
    rangefinder_distance = vehicle.rangefinder.distance
    # print out the reading from rangefinder
    print ("Rangefinder Distance: %.2f [m]" % float(rangefinder_distance))
    # 1 sec delay
    time.sleep(1)

另一个我想隐藏的 DroneKit 消息示例。

【问题讨论】:

  • 您能否详细说明或提供您要隐藏的消息示例?
  • @AgustinusBaskara 我在主要问题上添加了另一个示例图像。

标签: dronekit-python dronekit


【解决方案1】:

只需创建一个什么都不做的虚拟打印函数。

def dummy_printer(x):
    pass

然后将其传递给 status_printer 参数。

vehicle = connect('/dev/ttyS0', heartbeat_timeout = 30, baud = 57600, status_printer = dummy_printer)

【讨论】:

    猜你喜欢
    • 2017-12-26
    • 2012-10-30
    • 2016-06-22
    • 1970-01-01
    • 2011-10-02
    • 1970-01-01
    • 2019-04-21
    • 1970-01-01
    • 2012-01-02
    相关资源
    最近更新 更多