Exemple #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)
Exemple #2
0
    # 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)
        robot.shoulder = math.radians(ashoulder)
        robot.pause(False)
        robot.wait()

    end = robot.position
    print
    print euclidean_distance(start, end)

    print "----- Simulation ended -----"

    simulation.stop()
    time.sleep(0.2)

client.disconnect()
print('End')