Пример #1
0
def main():
    out = sys.argv[1]
    m1 = map_rep.map_(fname='i.map')
    mv1 = move_list.MoveList(fname='i.mv')
    
    out_keys = ['max_rng', 'step', 'particle_number'] # keys from the dict to add to file
    
    s1 = {'map_':m1, 'move_list':mv1, 'max_rng':50, 'step': 25, 'particle_number': 1, 'out_file': out}
    #s2 = {'map_':m1, 'move_list':mv1, 'max_rng':50, 'step': 15, 'particle_number': 5, 'out_file': 'data.txt'}
    #s3 = {'map_':m1, 'move_list':mv1, 'max_rng':50, 'step': 5, 'particle_number': 5, 'out_file': 'data.txt'}
    #s4 = {'map_':m1, 'move_list':mv1, 'max_rng':75, 'step': 15, 'particle_number': 5, 'out_file': 'data.txt'}
    s5 = {'map_':m1, 'move_list':mv1, 'max_rng':50, 'step': 15, 'particle_number': 3, 'out_file': out}
    s6 = {'map_':m1, 'move_list':mv1, 'max_rng':50, 'step': 15, 'particle_number': 5, 'out_file': out}
    s7 = {'map_':m1, 'move_list':mv1, 'max_rng':50, 'step': 15, 'particle_number': 8, 'out_file': out}
    s8 = {'map_':m1, 'move_list':mv1, 'max_rng':50, 'step': 15, 'particle_number': 15, 'out_file': out}
    s9 = {'map_':m1, 'move_list':mv1, 'max_rng':50, 'step': 15, 'particle_number': 25, 'out_file': out}
    srs = [s1,s5]
    testnum = 2
    

    for cfg in srs:
        f = open(out, 'a')
        f.write('newconf\n')
        for key in out_keys:
            f.write('%s:%s/'%(key, cfg[key]))
        f.write('\n')
        f.close()
        s = sonar_sim.sonar(**cfg)
        for i in range(testnum):
            f = open(out, 'a')
            f.write('newtest\n')
            f.write('----START----: %s\n'%(time.time()))
            f.close()
            while s.sim_step() != -1:
                continue
            f = open(out, 'a')
            f.write('step 99999\n')
            f.write('----END----: %s\n'%(time.time()))
            f.close()
            mv1.reset()
Пример #2
0
            # that is closest to the current sonar location
            intersect = self.math.get_intersect_point(self.loc, ln, self.map)
            # calculate the distance to the intersection point, with
            # some parameters which limit the data to a certain range
            dist = self.math.intersect_distance(self.loc, intersect, self.min_range, self.max_range,)
            self.ranges.append(dist) # store the calculated distance
            # Store the other objects for drawing later if necessary
            self.scan_lines.append(ln)
            self.intersection_points.append(intersect)
            self.current_angle += self.step # increment the angle to the angle of the next measurement
        
    def generate_particles(self, number):
        """Create a number of particles."""
        if not self.particles.list():
            for i in range(number):
                # Create a particle within a gaussian range of the current sonar location
                self.particles.add(particle.Particle(Point(self.math.apply_point_noise(self.loc.x, self.loc.y, self.loc_noise, self.loc_noise)), self))
                
if __name__ == '__main__':
    simple_map = map_rep.map_(sys.argv[1])
    mvlist = move_list.MoveList()
    mvlist.read_from_file(sys.argv[2])
    #mvlist = move_list.MoveList([Point(0,0)])
    #param = {'map_':simple_map, 'move_list':mvlist, 'max_rng':50, 'step': 15, 'particle_number': 10, 'out_file': 'data.txt', 'param_file': 'params.txt'}
    param = {'map_':simple_map, 'move_list':mvlist, 'max_rng':50, 'step': 15, 'particle_number': 10, 'out_file': 'data.txt'}
    sonar = sonar(**param)
    #sonar = sonar(simple_map, mvlist, rng=50, step=15, particle_number=5)
    #a = particle.Particle(sonar.loc, sonar)
    #a.get_ranges()
    ab = gui.gui(sonar)