Пример #1
0
    def simulate(self, individual):
        self.robot.client.display_activation(False)
        simulation = Simulation(self.robot.client)
        simulation.start()
        self.robot.init_stream()
        time.sleep(0.1)
        start = self.robot.position

        for move in individual.moves:
            self.robot.pause(True)
            self.robot.wrist = math.radians(move.x())
            self.robot.elbow = math.radians(move.y())
            self.robot.shoulder = math.radians(move.z())
            self.robot.pause(False)
            self.robot.wait()

        end = self.robot.position
        simulation.stop()
        time.sleep(0.1)
        return euclidean_distance(start, end)
Пример #2
0
    exit(1)

print client.id
robot = Robot(client)
if not robot.load():
    print "Robot initialization failed!"
    exit(1)

client.synchronous_mode()

random.seed()
for i in range(0, 3):
    # Wait until the robot is settled to the default position
    print "----- Simulation started -----"
    simulation = Simulation(client)
    simulation.start()
    # client.display_activation(False)
    robot.init_stream()
    start = robot.position
    # client.display_activation(False)

    # Make the robot move randomly five times
    for j in range(0, 20):
        # Generating random positions for the motors
        awrist = random.randint(0, 300)
        aelbow = random.randint(0, 300)
        ashoulder = random.randint(0, 300)

        robot.pause(True)
        robot.wrist = math.radians(awrist)
        robot.elbow = math.radians(aelbow)