I am currently working on a windows wsl 18.04 with dronekit and ardupilot looking at an air sim sitl. I can use the script to have the drone take off and land with proper altitude readings. However, I cannot get the * message
listener to print anything at all as well as a rangefinder despite one being defined in the settings.json.
Dronekit version:2.9.2
The script I am using:
import dronekit
import pymavlink
from dronekit import connect,VehicleMode
import time
# Connect to the Vehicle (in this case a simulator running the same computer)
vehicle = connect('127.0.0.1:14550', wait_ready=True)
@vehicle.on_message('*')
def listener(self, name, message):
print ('message: %s' % message)
print ('potato')
print ("Mode: %s" % vehicle.mode.name ) # settable
#Create a message listener using the decorator.
@vehicle.on_message('LIDAR')
def listener(self, name, message):
print ( 'message: %s' % message)
print ('have fun at boss fight')
def arm_and_takeoff(aTargetAltitude):
"""
Arms vehicle and fly to aTargetAltitude.
"""
print ("Basic pre-arm checks")
# Don't try to arm until autopilot is ready
while not vehicle.is_armable:
print (" Waiting for vehicle to initialise...")
time.sleep(1)
print ("Arming motors")
# Copter should arm in GUIDED mode
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
# Confirm vehicle armed before attempting to take off
while not vehicle.armed:
print (" Waiting for arming...")
time.sleep(1)
print ("Taking off!")
vehicle.simple_takeoff(aTargetAltitude) # Take off to target altitude
# Wait until the vehicle reaches a safe height before processing the goto (otherwise the command
# after Vehicle.simple_takeoff will execute immediately).
while True:
print (" Altitude: ", vehicle.location.global_relative_frame.alt)
#Break and return from function just below target altitude.
if vehicle.location.global_relative_frame.alt>=aTargetAltitude*0.95:
print ("Reached target altitude")
break
time.sleep(1)
arm_and_takeoff(20)
time.sleep(10)
vehicle.mode = VehicleMode("LAND")
time.sleep(5)
arm_and_takeoff(10)
time.sleep(1)
vehicle.mode = VehicleMode("LAND")
vehicle.remove_message_listener();
I am currently working on a windows wsl 18.04 with dronekit and ardupilot looking at an air sim sitl. I can use the script to have the drone take off and land with proper altitude readings. However, I cannot get the * message listener to print anything at all as well as a rangefinder despite one being defined in the settings.json.
Dronekit version:2.9.2
The script I am using:
The settings file:
The command I use to launch ardupilot: