Пример #1
0
    def launch_arducopter(self):
        waypoints,_,_ = ReadFlightplanFile(os.path.join(icarous_home,
                                           self.scenario["waypoint_file"]))
        start_point = ','.join(str(x) for x in waypoints[0][0:3]+[0])

        # Set up parameters for SITL
        sitl_param_file = self.scenario.get("sitl_parameter_file", sitl_default)
        sitl_params = LoadIcarousParams(os.path.join(icarous_home, sitl_param_file))

        icarous_param_file = self.scenario["parameter_file"]
        icarous_params = LoadIcarousParams(os.path.join(icarous_home, icarous_param_file))
        icarous_params.update(self.scenario["param_adjustments"])

        sitl_params["WPNAV_SPEED"] = icarous_params["DEF_WP_SPEED"]*100
        filename = "sitlparams-%d" % self.spacecraft_id
        sitl_param_file = os.path.join(self.output_dir, filename)
        with open(sitl_param_file, 'w') as f:
            for param_id, param_value in sitl_params.items():
                f.write("%-16s %f\n" % (param_id, param_value))

        # Launch SITL
        arguments = ["sim_vehicle.py", "-v", "ArduCopter",
                     "-l", str(start_point),
                     "--add-param-file", sitl_param_file,
                     "--use-dir", "sitl_files",
                     "-I", str(self.spacecraft_id)]
        logname = "sitl-%d-%f.tlog" % (self.spacecraft_id, time.time())
        logfile = os.path.join(self.output_dir, logname)
        arguments += ["-m", "--logfile="+logfile]
        subprocess.Popen(arguments, stdout=subprocess.DEVNULL)

        if self.verbose:
            print("Waiting several seconds to allow ArduCopter to start up")
        time.sleep(60)
Пример #2
0
 def InputFlightplanFromFile(self,filename,scenarioTime=0,eta=False):
     wp, time, speed = ReadFlightplanFile(filename)
     fp = []
     if eta:
         combine = time
     else:
         combine = speed
     for w,i in zip(wp,combine):
         if not eta and i < 0:
             i = self.defaultWPSpeed
         fp.append(w + [i])
     self.InputFlightplan(fp,scenarioTime,eta)
Пример #3
0
 def InputMergeFixes(self, filename):
     wp, ind, _, _, _ = ReadFlightplanFile(filename)
     self.localMergeFixes = list(map(self.ConvertToLocalCoordinates, wp))
     self.mergeFixes = wp
     self.core.SetIntersectionData(list(zip(ind, wp)))
Пример #4
0
 def InputMergeFixes(self, filename):
     wp, _, _ = ReadFlightplanFile(filename)
     self.localMergeFixes = list(map(self.ConvertToLocalCoordinates, wp))
     self.mergeFixes = wp
     dest = os.path.join(icarous_home, "exe", "ram", "merge_fixes.txt")
     shutil.copy(filename, dest)