Created
August 18, 2016 19:11
-
-
Save rjehangir/973a2b4ef75e57690de6531f122a100d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from pymavlink import mavutil | |
from pymavlink.dialects.v10 import common as mavlink | |
# UDP settings (must match a udpout port running on mavproxy) | |
address = 'localhost' | |
port = 9001 | |
#master = mavutil.mavlink_connection(args.device, baud=args.baudrate, source_system=args.SOURCE_SYSTEM) | |
master = mavutil.mavlink_connection('udpout:'+address+':'+str(port)) | |
# Send mock distance sensor measurements | |
current_distance = 100 # cm | |
while ( True ): | |
current_distance = current_distance + 10.5 # cm | |
print "Sending current_distance=%f cm to mavproxy on %s:%i" % (current_distance,address,port) | |
# distance_sensor_send(self, time_boot_ms, min_distance, max_distance, current_distance, type, id, orientation, covariance): | |
master.mav.distance_sensor_send(0, 0, 0, current_distance, 1, 0, 0, 0) | |
import time | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This runs on a Raspberry Pi that is connected to a Pixhawk. The Raspberry Pi is also running
mavproxy
with the following settings:Port 9001 is used for communication from this script. Make sure you add it to your
mavproxy
command.Also, set the Pixhawk to accept a "mavlink rangefinder" by setting
RNGFND_TYPE
to "MAVLink".