如何隐藏DroneKit-Python API消息

时间:2018-11-07 15:37:09

标签: dronekit-python dronekit

Displayed DroneKit message

快速提问。是否可以通过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消息的另一个示例。 Example 1 Example 2

1 个答案:

答案 0 :(得分:2)

只需创建一个不执行任何操作的虚拟打印功能即可。

def dummy_printer(x):
    pass

然后将其传递给status_printer参数。

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