How to hide DroneKit-Python API messages

247 views Asked by At

Displayed DroneKit message

Quick question. There is any way to hide or suppress messages from DroneKit-Python API (marked in red line)?

As a reference, below are the code I use.

#!/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)

Another example of DroneKit messages I want to hide. Example 1 Example 2

1

There are 1 answers

0
Baskara On BEST ANSWER

Just create a dummy printing function that do nothing.

def dummy_printer(x):
    pass

Then pass it to the status_printer argument.

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