示例#1
0
    def run(self):
        camera = geometric_transformation.geometric_transformation(0, 0, 0)

        # open CSV file
        with open(self.camerafilepath, 'r') as cameracsv:

            for line in csv.reader(cameracsv, skipinitialspace=True):

                # skip row with comments or empty
                if len(line) == 0: continue
                if line[0][0] == '#': continue

                # transform text to integers
                line = map(lambda x: float(x), line)

                # compute fix to errors
                camera_correction = self.move()
                print self.getName() + ": line:", line
                print self.getName(
                ) + ": camera_correction:", camera_correction

# apply fix to error
        camera.rotate_X_axis(line[0] + line[1] - camera_correction[0])
        camera.rotate_Y_axis(line[2] + line[3] - camera_correction[1])
        camera.rotate_Z_axis(line[4] + line[5] - camera_correction[2])
        camera.traslate(line[6] + line[7] - camera_correction[3],
                        line[8] + line[9] - camera_correction[4],
                        line[10] + line[11] - camera_correction[5])

        # show stats about the current value and distance from corrections
        self.stats(line, camera_correction)

        cameracsv.close()
示例#2
0
	def run(self):
		camera = geometric_transformation.geometric_transformation(0,0,0)

		# open CSV file 
		with open(self.camerafilepath, 'r') as cameracsv:
			
			for line in csv.reader(cameracsv, skipinitialspace=True):
				
				# skip row with comments or empty
				if len(line) == 0: continue
				if line[0][0] == '#': continue

				# transform text to integers
				line = map(lambda x: float(x), line)

                # compute fix to errors 
				camera_correction = self.move()
				print self.getName() + ": line:", line
				print self.getName() + ": camera_correction:", camera_correction

                # apply fix to error 
                camera.rotate_X_axis(line[0] + line[1] - camera_correction[0])
                camera.rotate_Y_axis(line[2] + line[3] - camera_correction[1])
                camera.rotate_Z_axis(line[4] + line[5] - camera_correction[2])
                camera.traslate(line[6] + line[7] - camera_correction[3], line[8] + line[9] - camera_correction[4], line[10] + line[11] - camera_correction[5])

                # show stats about the current value and distance from corrections 
                self.stats(line, camera_correction)

		cameracsv.close()
示例#3
0
文件: main.py 项目: depsir/university
def main():

    point = geometric_transformation.geometric_transformation(3, 5, 7)

    with open(CAMERAS_DATA_FILE, 'rb') as csvfile:
        data = csv.reader(csvfile, skipinitialspace=True)

        for row in data:

            # skip row with comments or empty
            if len(row) == 0: continue
            if row[0][0] == '#': continue

            # transform text to integers
            row = map(lambda x: float(x), row)

            point.rotate_X_axis(row[0])  # rotate of value
            point.rotate_X_axis(row[1])  # rotate as the error value

            print point.actual_position

            point.rotate_Y_axis(row[2])  # rotate on Y as value
            point.rotate_Y_axis(row[3])  # rotate as the error value

            print point.actual_position

            point.rotate_Z_axis(row[4])  # rotate on Y as value
            point.rotate_Z_axis(row[5])  # rotate as the error value

            print point.actual_position

            point.traslate(row[6] + row[7], row[8] + row[9], row[10] + row[11])
            print point.actual_position

            print "-----------------------"
示例#4
0
文件: main.py 项目: depsir/university
def main():

    point = geometric_transformation.geometric_transformation(3,5,7)

    with open(CAMERAS_DATA_FILE, 'rb') as csvfile:
        data = csv.reader(csvfile, skipinitialspace=True)

        for row in data:

			# skip row with comments or empty 
            if len(row) == 0: continue
            if row[0][0] == '#': continue

			# transform text to integers 
            row = map(lambda x: float(x), row)

            point.rotate_X_axis(row[0]) # rotate of value
            point.rotate_X_axis(row[1]) # rotate as the error value 

            print point.actual_position

            point.rotate_Y_axis(row[2]) # rotate on Y as value 
            point.rotate_Y_axis(row[3]) # rotate as the error value  

            print point.actual_position

            point.rotate_Z_axis(row[4]) # rotate on Y as value 
            point.rotate_Z_axis(row[5]) # rotate as the error value 

            print point.actual_position

            point.traslate(row[6]+row[7], row[8]+row[9], row[10]+row[11])
            print point.actual_position

            print "-----------------------"
示例#5
0
    def feasible_moves_selection(self,
                                 attractiveness_weight=None,
                                 trails_weight=None):
        """ statistically select wich of the feasible move is the right one to select 
            attractivness is the 'a priori' desiderability of that move
            trail level   is the 'a posteriori' desiderability of that move
            """

        # set default value if not otherwise fixed
        if attractiveness_weight == None:
            attractiveness_weight = self.attractiveness_weight

        if trails_weight == None:
            trails_weight = self.trails_weight

        # memorize all evaluated position with respective fitness and trail level
        evaluated_positions = list()
        most_feasible = (0, 0, 0, 0)
        numerator = denominator = 0

        # for each move:
        for move in self.feasible_moves:

            # set from where the object is located
            gt = geometric_transformation.geometric_transformation(
                self.actual_position[0], self.actual_position[1],
                self.actual_position[2])

            # compute what the actual choice do to the object position
            evaluated_position = gt.rototraslate_on_all_axis(
                move[0], move[1], move[2], move[3], move[4], move[5])

            # compute the attractivness of that move (a priory move )
            a_priory_desiderability = self.compute_fitness(evaluated_position)
            # print "a_priory_desiderability:", a_priory_desiderability

            # compute trail level on this particular move ( a posteriori move ) using hints from others ANT's
            a_posteriori_desiderability = self.trails.value(evaluated_position)
            # print "a_posteriori_desiderability:", a_posteriori_desiderability

            # add to evaluted position every choice with it's respective fitness
            evaluated_positions.append(
                (evaluated_position, a_priory_desiderability,
                 a_posteriori_desiderability))

        # Compute now in probability how good are the choices

        # First we need the denominator value
        for position in evaluated_positions:

            # for every evaluated position get previous calculated values
            a_priory_desiderability = position[1]
            a_posteriori_desiderability = position[2]

            # compute denominator
            denominator += (
                1 - attractiveness_weight) * a_priory_desiderability + (
                    trails_weight * a_posteriori_desiderability)

# Then we need to compute numerator and get data in probability
        count = 0
        for position in evaluated_positions:

            numerator = (
                1 - attractiveness_weight
            ) * a_priory_desiderability + trails_weight * a_posteriori_desiderability

            # NOTE: I've skiped tabu list exclusion to evaluate the probability of a move using it in move creation
            # using a short term tabu list task

            # compute the probability of that move
            position_probability = numerator / denominator

            # As choice are created, memorize the move number of the best one !
            if most_feasible[3] < position_probability:
                most_feasible = position[0][0][0], position[0][1][0], position[
                    0][2][0], position_probability[0]
                most_feasible_id = count

            count = count + 1

        # return the best feasible move
        return self.feasible_moves[most_feasible_id]
示例#6
0
	def feasible_moves_selection(self, attractiveness_weight = None, trails_weight = None):
		""" statistically select wich of the feasible move is the right one to select 
            attractivness is the 'a priori' desiderability of that move
            trail level   is the 'a posteriori' desiderability of that move
            """

		# set default value if not otherwise fixed
		if attractiveness_weight == None:
			attractiveness_weight = self.attractiveness_weight

		if trails_weight == None:
			trails_weight = self.trails_weight

		# memorize all evaluated position with respective fitness and trail level
		evaluated_positions = list()
		most_feasible = (0,0,0,0) 
		numerator = denominator = 0 

        # for each move:
		for move in self.feasible_moves:

			# set from where the object is located 
			gt = geometric_transformation.geometric_transformation(self.actual_position[0], self.actual_position[1], self.actual_position[2])

			# compute what the actual choice do to the object position 
			evaluated_position = gt.rototraslate_on_all_axis(move[0], move[1], move[2], move[3], move[4], move[5])

			# compute the attractivness of that move (a priory move ) 
			a_priory_desiderability = self.compute_fitness(evaluated_position)
			# print "a_priory_desiderability:", a_priory_desiderability
			
			# compute trail level on this particular move ( a posteriori move ) using hints from others ANT's
			a_posteriori_desiderability = self.trails.value(evaluated_position)
			# print "a_posteriori_desiderability:", a_posteriori_desiderability

			# add to evaluted position every choice with it's respective fitness
			evaluated_positions.append((evaluated_position, a_priory_desiderability, a_posteriori_desiderability))

		# Compute now in probability how good are the choices 

        # First we need the denominator value 
		for position in evaluated_positions:

			# for every evaluated position get previous calculated values 
			a_priory_desiderability = position[1]
			a_posteriori_desiderability = position[2]

            # compute denominator 
			denominator += (1 - attractiveness_weight) * a_priory_desiderability + (trails_weight * a_posteriori_desiderability)

        # Then we need to compute numerator and get data in probability 
		count = 0 
		for position in evaluated_positions:

			numerator = (1 - attractiveness_weight) * a_priory_desiderability + trails_weight * a_posteriori_desiderability

            # NOTE: I've skiped tabu list exclusion to evaluate the probability of a move using it in move creation 
            # using a short term tabu list task 

        	# compute the probability of that move 
			position_probability = numerator / denominator

			# As choice are created, memorize the move number of the best one ! 
			if most_feasible[3] < position_probability:
				most_feasible = position[0][0][0], position[0][1][0], position[0][2][0], position_probability[0]
				most_feasible_id = count 

			count = count + 1 

		# return the best feasible move 
		return self.feasible_moves[most_feasible_id]
示例#7
0
		# wait for all thread are stopped
		for ant in atomic_ant_colony:
			ant.join()
		
		# 
		for ant in atomic_ant_colony:
			ant.compute_fitness()

    with open(REAL_POSITION_FILE, 'rb') as rpositionfile:
        data = csv.reader(rpositionfile, skipinitialspace=True)
        for row in data: real_position = row
        rpositionfile.close()

    print "Real position of the object is: ", real_position

    point = geometric_transformation.geometric_transformation(0,0,0)
    print dir(point)

    # for every camera roto-traslate the object 
    with open(CAMERAS_DATA_FILE, 'rb') as csvfile:

        data = csv.reader(csvfile, skipinitialspace=True)

        for row in data:

            # skip row with comments or empty 
            if len(row) == 0: continue
            if row[0][0] == '#': continue

            # transform text to integers 
            row = map(lambda x: float(x), row)