Esempio n. 1
0
    def apply_parameters_using_sitl(self):
        '''start SITL, apply parameter file, stop SITL'''
        sitl = util.start_SITL(self.binary,
                               wipe=True,
                               model=self.frame,
                               home=self.home,
                               speedup=self.speedup_default)
        self.mavproxy = util.start_MAVProxy_SITL(self.log_name)

        self.progress("WAITING FOR PARAMETERS")
        self.mavproxy.expect('Received [0-9]+ parameters')

        # setup test parameters
        vinfo = vehicleinfo.VehicleInfo()
        if self.params is None:
            frames = vinfo.options[self.vehicleinfo_key()]["frames"]
            self.params = frames[self.frame]["default_params_filename"]
        if not isinstance(self.params, list):
            self.params = [self.params]
        for x in self.params:
            self.mavproxy.send("param load %s\n" % os.path.join(testdir, x))
            self.mavproxy.expect('Loaded [0-9]+ parameters')
        self.set_parameter('LOG_REPLAY', 1)
        self.set_parameter('LOG_DISARMED', 1)

        # kill this SITL instance off:
        util.pexpect_close(self.mavproxy)
        util.pexpect_close(sitl)
        self.mavproxy = None
Esempio n. 2
0
 def defaults_filepath(self):
     vinfo = vehicleinfo.VehicleInfo()
     defaults_file = vinfo.options["ArduPlane"]["frames"][self.frame]["default_params_filename"]
     if isinstance(defaults_file, str):
         defaults_file = [defaults_file]
     defaults_list = []
     for d in defaults_file:
         defaults_list.append(os.path.join(testdir, d))
     return ','.join(defaults_list)
Esempio n. 3
0
    def apply_defaultfile_parameters(self):
        '''apply parameter file'''

        # setup test parameters
        vinfo = vehicleinfo.VehicleInfo()
        if self.params is None:
            frames = vinfo.options[self.vehicleinfo_key()]["frames"]
            self.params = frames[self.frame]["default_params_filename"]
        if not isinstance(self.params, list):
            self.params = [self.params]
        for x in self.params:
            self.mavproxy.send("param load %s\n" % os.path.join(testdir, x))
            self.mavproxy.expect('Loaded [0-9]+ parameters')
        self.set_parameter('LOG_REPLAY', 1)
        self.set_parameter('LOG_DISARMED', 1)
        self.reboot_sitl()
Esempio n. 4
0
    def init(self):
        super(AutoTestQuadPlane, self).init(os.path.realpath(__file__))
        if self.frame is None:
            self.frame = 'quadplane'

        self.mavproxy_logfile = self.open_mavproxy_logfile()

        vinfo = vehicleinfo.VehicleInfo()
        defaults_file = vinfo.options["ArduPlane"]["frames"][
            self.frame]["default_params_filename"]
        defaults_filepath = os.path.join(testdir, defaults_file)

        self.sitl = util.start_SITL(
            self.binary,
            wipe=True,
            model=self.frame,
            home=self.home,
            speedup=self.speedup,
            defaults_file=defaults_filepath,
            valgrind=self.valgrind,
            gdb=self.gdb,
            gdbserver=self.gdbserver,
            breakpoints=self.breakpoints,
        )
        self.mavproxy = util.start_MAVProxy_SITL(
            'QuadPlane',
            logfile=self.mavproxy_logfile,
            options=self.mavproxy_options())
        self.mavproxy.expect('Telemetry log: (\S+)\r\n')
        self.logfile = self.mavproxy.match.group(1)
        self.progress("LOGFILE %s" % self.logfile)
        self.try_symlink_tlog()

        self.mavproxy.expect('Received [0-9]+ parameters')

        util.expect_setup_callback(self.mavproxy, self.expect_callback)

        self.expect_list_clear()
        self.expect_list_extend([self.sitl, self.mavproxy])

        self.progress("Started simulator")

        self.get_mavlink_connection_going()

        self.progress("Ready to start testing!")
Esempio n. 5
0
 def fly_each_frame(self):
     vinfo = vehicleinfo.VehicleInfo()
     vinfo_options = vinfo.options[self.vehicleinfo_key()]
     known_broken_frames = {}
     for frame in sorted(vinfo_options["frames"].keys()):
         self.start_subtest("Testing frame (%s)" % str(frame))
         if frame in known_broken_frames:
             self.progress(
                 "Actually, no I'm not - it is known-broken (%s)" %
                 (known_broken_frames[frame]))
             continue
         frame_bits = vinfo_options["frames"][frame]
         print("frame_bits: %s" % str(frame_bits))
         if frame_bits.get("external", False):
             self.progress(
                 "Actually, no I'm not - it is an external simulation")
             continue
         model = frame_bits.get("model", frame)
         # the model string for Callisto has crap in it.... we
         # should really have another entry in the vehicleinfo data
         # to carry the path to the JSON.
         actual_model = model.split(":")[0]
         defaults = self.model_defaults_filepath(actual_model)
         if type(defaults) != list:
             defaults = [defaults]
         self.customise_SITL_commandline(
             [
                 "--defaults",
                 ','.join(defaults),
             ],
             model=model,
             wipe=True,
         )
         self.takeoff(10)
         self.do_RTL()
         self.set_rc(8, 1000)
Esempio n. 6
0
    except Exception as e:
        progress("kill_tasks failed: {}".format(str(e)))


def progress(text):
    """Display sim_vehicle progress text"""
    print("SIM_VEHICLE: " + text)


def wait_unlimited():
    """Wait until signal received"""
    while True:
        time.sleep(600)


vinfo = vehicleinfo.VehicleInfo()


def do_build_waf(opts, frame_options):
    """Build sitl using waf"""
    progress("WAF build")

    old_dir = os.getcwd()
    os.chdir(root_dir)

    waf_light = os.path.join(root_dir, "modules/waf/waf-light")

    cmd_configure = [waf_light, "configure", "--board", "sitl"]
    if opts.debug:
        cmd_configure.append("--debug")
Esempio n. 7
0
    def init(self):
        if self.frame is None:
            self.frame = 'rover'

        if self.viewerip:
            self.options += " --out=%s:14550" % self.viewerip
        if self.use_map:
            self.options += ' --map'

        self.sitl = util.start_SITL(self.binary,
                                    wipe=True,
                                    model=self.frame,
                                    home=self.home,
                                    speedup=self.speedup_default)
        self.mavproxy = util.start_MAVProxy_SITL('APMrover2')

        self.progress("WAITING FOR PARAMETERS")
        self.mavproxy.expect('Received [0-9]+ parameters')

        # setup test parameters
        vinfo = vehicleinfo.VehicleInfo()
        if self.params is None:
            frames = vinfo.options["APMrover2"]["frames"]
            self.params = frames[self.frame]["default_params_filename"]
        if not isinstance(self.params, list):
            self.params = [self.params]
        for x in self.params:
            self.mavproxy.send("param load %s\n" % os.path.join(testdir, x))
            self.mavproxy.expect('Loaded [0-9]+ parameters')
        self.set_parameter('LOG_REPLAY', 1)
        self.set_parameter('LOG_DISARMED', 1)
        self.progress("RELOADING SITL WITH NEW PARAMETERS")

        # restart with new parms
        util.pexpect_close(self.mavproxy)
        util.pexpect_close(self.sitl)

        self.sitl = util.start_SITL(self.binary,
                                    model=self.frame,
                                    home=self.home,
                                    speedup=self.speedup,
                                    valgrind=self.valgrind,
                                    gdb=self.gdb,
                                    gdbserver=self.gdbserver)
        self.mavproxy = util.start_MAVProxy_SITL('APMrover2',
                                                 options=self.options)
        self.mavproxy.expect('Telemetry log: (\S+)')
        logfile = self.mavproxy.match.group(1)
        self.progress("LOGFILE %s" % logfile)

        buildlog = self.buildlogs_path("APMrover2-test.tlog")
        self.progress("buildlog=%s" % buildlog)
        if os.path.exists(buildlog):
            os.unlink(buildlog)
        try:
            os.link(logfile, buildlog)
        except Exception:
            pass

        self.mavproxy.expect('Received [0-9]+ parameters')

        util.expect_setup_callback(self.mavproxy, self.expect_callback)

        self.expect_list_clear()
        self.expect_list_extend([self.sitl, self.mavproxy])

        self.progress("Started simulator")

        # get a mavlink connection going
        connection_string = '127.0.0.1:19550'
        try:
            self.mav = mavutil.mavlink_connection(connection_string,
                                                  robust_parsing=True)
        except Exception as msg:
            self.progress("Failed to start mavlink connection on %s" %
                          connection_string)
            raise
        self.mav.message_hooks.append(self.message_hook)
        self.mav.idle_hooks.append(self.idle_hook)
        self.hasInit = True
        self.progress("Ready to start testing!")
Esempio n. 8
0
 def defaults_filepath(self):
     vinfo = vehicleinfo.VehicleInfo()
     defaults_file = vinfo.options["ArduPlane"]["frames"][
         self.frame]["default_params_filename"]
     return os.path.join(testdir, defaults_file)