|
|
|
@ -7,6 +7,7 @@ import math
@@ -7,6 +7,7 @@ import math
|
|
|
|
|
import os |
|
|
|
|
import shutil |
|
|
|
|
import time |
|
|
|
|
import numpy |
|
|
|
|
|
|
|
|
|
from pymavlink import mavutil |
|
|
|
|
from pymavlink import mavextra |
|
|
|
@ -1847,6 +1848,73 @@ class AutoTestCopter(AutoTest):
@@ -1847,6 +1848,73 @@ class AutoTestCopter(AutoTest):
|
|
|
|
|
|
|
|
|
|
self.do_RTL() |
|
|
|
|
|
|
|
|
|
def fly_motor_vibration(self): |
|
|
|
|
"""Test flight with motor vibration""" |
|
|
|
|
self.context_push() |
|
|
|
|
|
|
|
|
|
ex = None |
|
|
|
|
try: |
|
|
|
|
self.set_rc_default() |
|
|
|
|
self.set_parameter("INS_LOG_BAT_MASK", 3) |
|
|
|
|
self.set_parameter("INS_LOG_BAT_OPT", 2) |
|
|
|
|
self.set_parameter("LOG_BITMASK", 958) |
|
|
|
|
self.set_parameter("LOG_DISARMED", 0) |
|
|
|
|
self.set_parameter("SIM_VIB_MOT_MAX", 350) |
|
|
|
|
self.set_parameter("SIM_GYR_RND", 100) |
|
|
|
|
self.set_parameter("SIM_DRIFT_SPEED", 0) |
|
|
|
|
self.set_parameter("SIM_DRIFT_TIME", 0) |
|
|
|
|
self.reboot_sitl() |
|
|
|
|
|
|
|
|
|
self.takeoff(10, mode="LOITER") |
|
|
|
|
self.change_alt(alt_min=15) |
|
|
|
|
|
|
|
|
|
hover_time = 5 |
|
|
|
|
tstart = self.get_sim_time() |
|
|
|
|
self.progress("Hovering for %u seconds" % hover_time) |
|
|
|
|
while self.get_sim_time_cached() < tstart + hover_time: |
|
|
|
|
attitude = self.mav.recv_match(type='ATTITUDE', blocking=True) |
|
|
|
|
tend = self.get_sim_time() |
|
|
|
|
|
|
|
|
|
self.do_RTL() |
|
|
|
|
psd = self.mavfft_fttd(1, 0, tstart * 1.0e6, tend * 1.0e6) |
|
|
|
|
# ignore the first 20Hz |
|
|
|
|
ignore_bins = 20 |
|
|
|
|
freq = psd["F"][numpy.argmax(psd["X"][ignore_bins:]) + ignore_bins] |
|
|
|
|
if numpy.amax(psd["X"][ignore_bins:]) < -22 or freq < 200 or freq > 300: |
|
|
|
|
raise NotAchievedException("Did not detect a motor peak, found %f at %f dB" % (freq, numpy.amax(psd["X"][ignore_bins:]))) |
|
|
|
|
else: |
|
|
|
|
self.progress("Detected motor peak at %fHz" % freq) |
|
|
|
|
|
|
|
|
|
# now add a notch and check that the peak is squashed |
|
|
|
|
self.set_parameter("INS_NOTCH_ENABLE", 1) |
|
|
|
|
self.set_parameter("INS_NOTCH_FREQ", freq) |
|
|
|
|
self.set_parameter("INS_NOTCH_ATT", 50) |
|
|
|
|
self.set_parameter("INS_NOTCH_BW", freq/2) |
|
|
|
|
self.reboot_sitl() |
|
|
|
|
|
|
|
|
|
self.takeoff(10, mode="LOITER") |
|
|
|
|
self.change_alt(alt_min=15) |
|
|
|
|
|
|
|
|
|
tstart = self.get_sim_time() |
|
|
|
|
self.progress("Hovering for %u seconds" % hover_time) |
|
|
|
|
while self.get_sim_time_cached() < tstart + hover_time: |
|
|
|
|
attitude = self.mav.recv_match(type='ATTITUDE', blocking=True) |
|
|
|
|
tend = self.get_sim_time() |
|
|
|
|
self.do_RTL() |
|
|
|
|
psd = self.mavfft_fttd(1, 0, tstart * 1.0e6, tend * 1.0e6) |
|
|
|
|
freq = psd["F"][numpy.argmax(psd["X"][ignore_bins:]) + ignore_bins] |
|
|
|
|
if numpy.amax(psd["X"][ignore_bins:]) < -22: |
|
|
|
|
self.progress("Did not detect a motor peak, found %f at %f dB" % (freq, numpy.amax(psd["X"][ignore_bins:]))) |
|
|
|
|
else: |
|
|
|
|
raise NotAchievedException("Detected motor peak at %f Hz" % (freq)) |
|
|
|
|
except Exception as e: |
|
|
|
|
ex = e |
|
|
|
|
|
|
|
|
|
self.context_pop() |
|
|
|
|
|
|
|
|
|
if ex is not None: |
|
|
|
|
raise ex |
|
|
|
|
|
|
|
|
|
def fly_vision_position(self): |
|
|
|
|
"""Disable GPS navigation, enable Vicon input.""" |
|
|
|
|
# scribble down a location we can set origin to: |
|
|
|
@ -4407,12 +4475,15 @@ class AutoTestCopter(AutoTest):
@@ -4407,12 +4475,15 @@ class AutoTestCopter(AutoTest):
|
|
|
|
|
"Test rangefinder drivers", |
|
|
|
|
self.fly_rangefinder_drivers), |
|
|
|
|
|
|
|
|
|
("MotorVibration", |
|
|
|
|
"Fly motor vibration test", |
|
|
|
|
self.fly_motor_vibration), |
|
|
|
|
|
|
|
|
|
("LogDownLoad", |
|
|
|
|
"Log download", |
|
|
|
|
lambda: self.log_download( |
|
|
|
|
self.buildlogs_path("ArduCopter-log.bin"), |
|
|
|
|
upload_logs=len(self.fail_list) > 0)) |
|
|
|
|
|
|
|
|
|
]) |
|
|
|
|
return ret |
|
|
|
|
|
|
|
|
|