def main():
    connection = CESAPI.connection.Connection()
    try:
        # connection.connect()
        stream = connection.connect(host='localhost')
        command = CESAPI.command.CommandSync(connection)

        initialize(command, manualiof=False)

        # ri_algorithm = CESAPI.refract.AlgorithmFactory(CESAPI.refract.RI_ALG_CiddorAndHill)
        ri_algorithm = CESAPI.refract.AlgorithmFactory(
        ).refractionIndexAlgorithm(CESAPI.refract.RI_ALG_Leica)

        logger.info('Measuring reflector..')
        measurement = measure(command, rialg=ri_algorithm)
        print('theta:       {} rad'.format(measurement.dVal1))
        print('phi:         {} rad'.format(measurement.dVal2))
        print('r:           {} mm'.format(measurement.dVal3))
        print('SD[theta]:   {} rad'.format(measurement.dStd1))
        print('SD[phi]:     {} rad'.format(measurement.dStd2))
        print('SD[r]:       {} mm'.format(measurement.dStd3))
        print('Temperature: {} C'.format(measurement.dTemperature))
        print('Pressure:    {} mbar'.format(measurement.dPressure))
        print('Humidity:    {} %RH'.format(measurement.dHumidity))

        # command.GetStatisticMode()
    finally:
        connection.disconnect()
        pass
    logger.debug('Done')
Exemple #2
0
def main():
    # signal.signal(signal.SIGINT, signal_handler)

    connection = CESAPI.connection.Connection()
    try:
        logger.info('Connecting to the laser tracker...')
        connection.connect()
        command = CESAPI.command.CommandSync(connection)
    except Exception as e:
        logger.error('Failed to connect to the laster tracker:\n{}'.format(e))
        connection.disconnect()

    root = tk.Tk()
    root.title('Bootstrap Position')

    notebook = ttk.Notebook(root)
    notebook.grid(row=0, column=1, rowspan=6, columnspan=3)

    ref_network_DSCS_filename_entry = build_reference_network_page(
        notebook, command)
    other_network_DSCS_filename_entry = build_other_network_page(
        notebook, command, ref_network_DSCS_filename_entry)
    build_config_page(notebook, ref_network_DSCS_filename_entry,
                      other_network_DSCS_filename_entry)

    root.mainloop()

    connection.disconnect()
Exemple #3
0
def main():
    signal.signal(signal.SIGINT, signal_handler)

    parser = argparse.ArgumentParser()
    parser.add_argument(
        'filename',
        help='the CSV file path of the DSCS reference network coordinates')
    args = parser.parse_args()
    # filename = 'C:\\Users\\fms-local\\Desktop\\FMS\\FMS\\reference_network.csv'
    reflector_names, cylindrical_DSCS, cartesian_DSCS = loadDSCS(args.filename)

    connection = CESAPI.connection.Connection()
    try:
        logger.info('Connecting to the laser tracker...')
        connection.connect()
        command = CESAPI.command.CommandSync(connection)

        print("Acquire an initialization reflector.")
        press_any_key_to_continue()
        logger.info('Initializing laser tracker...')
        initialize(command, manualiof=False)

        target_reflector_names, initial_coordinates_LTCS = measure_initial_reflectors(
            command, reflector_names)
        print('Initial LTCS Coordinates:\n{}'.format(
            initial_coordinates_LTCS.transpose()))

        transform_matrix = calculate_transform(reflector_names,        cartesian_DSCS,\
                                               target_reflector_names, initial_coordinates_LTCS)
        logger.debug(
            'DSCS-to-LTCS Transform Matrix:\n{}'.format(transform_matrix))

        cartesian_LTCS = calculate_approx_LTCS(cartesian_DSCS,
                                               transform_matrix)

        spherical_LTCS = scan_reference_network(command, cartesian_LTCS)
        logger.info('Spherical LTCS:\n{}'.format(spherical_LTCS))

        _, _, prop_cartesian_DSCS = loadDSCS(
            'C:\\Users\\fms-local\\Desktop\\FMS\\FMS\\prop_network.csv')
        logger.info('Prop Cartesian DSCS:\n{}'.format(prop_cartesian_DSCS))
        prop_spherical_LTCS = convert_network_to_LTCS(transform_matrix,
                                                      prop_cartesian_DSCS)

        _, _, ds_cartesian_DSCS = loadDSCS(
            'C:\\Users\\fms-local\\Desktop\\FMS\\FMS\\ds_network.csv')
        logger.info('DS Cartesian DSCS:\n{}'.format(ds_cartesian_DSCS))
        ds_spherical_LTCS = convert_network_to_LTCS(transform_matrix,
                                                    ds_cartesian_DSCS)

        print_configuration(transform_matrix, spherical_LTCS, cylindrical_DSCS,
                            prop_spherical_LTCS, ds_spherical_LTCS)

    finally:
        connection.disconnect()
Exemple #4
0
def main():
    signal.signal(signal.SIGINT, signal_handler)

    connection = CESAPI.connection.Connection()
    try:
        logger.info('Connecting to the laser tracker...')
        stream = connection.connect()

        while (True):
            unread_count = stream.unreadCount()
            if unread_count > 0:
                in_packet = stream.read()
                packet_type = packetType(in_packet)
                logger.info('Packet Type: {}'.format(packet_type))
                time.sleep(0.2)

    finally:
        connection.disconnect()
def main():
    signal.signal(signal.SIGINT, signal_handler)

    ref_network_DSCS_filename, transform_filename, inv_transform_filename, ref_network_LTCS_filename \
        = determine_data_filenames()

    reflector_names, cylindrical_DSCS, cartesian_DSCS = loadDSCS(ref_network_DSCS_filename)

    connection = CESAPI.connection.Connection()
    try:
        logger.info('Connecting to the laser tracker...')
        connection.connect()
        command = CESAPI.command.CommandSync(connection)
        
        print("Acquire an initialization reflector.")
        press_any_key_to_continue()
        logger.info('Initializing laser tracker...')
        initialize(command, manualiof=False)

        target_reflector_names, initial_coordinates_LTCS = measure_initial_reflectors(command, reflector_names)
        logger.debug('Initial LTCS Coordinates:\n{}'.format(initial_coordinates_LTCS.transpose()))
    
        transform_matrix = calculate_transform(reflector_names,        cartesian_DSCS,\
                                               target_reflector_names, initial_coordinates_LTCS)
        logger.debug('LTCS-to-DSCS Transform Matrix:\n{}'.format(transform_matrix))

        inv_transform_matrix = linalg.inv(transform_matrix)
        cartesian_LTCS = calculate_approx_LTCS(cartesian_DSCS, inv_transform_matrix)

        spherical_LTCS = scan_reference_network(command, cartesian_LTCS)
        logger.debug('Spherical LTCS:\n{}'.format(spherical_LTCS))

        save_matrix(transform_filename, transform_matrix)
        save_matrix(inv_transform_filename, inv_transform_matrix)
        save_coordinates(ref_network_LTCS_filename, reflector_names, spherical_LTCS)

    finally:
        connection.disconnect()
Exemple #6
0
def main():
    signal.signal(signal.SIGINT, signal_handler)

    connection = CESAPI.connection.Connection()
    try:
        logger.info('Connecting to the laser tracker...')
        connection.connect()
        command = CESAPI.command.CommandSync(connection)

        logger.info('Getting compensations...')
        compensation = command.GetCompensations2()
        print('{} compensations available.'.format(compensation.iTotalCompensations))
        '''
        self.iTotalCompensations = int(0)
        self.iInternalCompensationId = int(0)
        self.cTrackerCompensationName = str()  # 32 bytes max
        self.cTrackerCompensationComment = str()  # 128 bytes max
        self.cADMCompensationName = str()  # 32 bytes max
        self.cADMCompensationComment = str()  # 128 bytes max
        self.bHasMeasurementCameraMounted = int(0)
        self.bIsActive = int(0)
        '''
    finally:
        connection.disconnect()
Exemple #7
0
def main():
    signal.signal(signal.SIGINT, signal_handler)

    connection = CESAPI.connection.Connection()
    try:
        logger.info('Connecting to the laser tracker...')
        connection.connect()
        command = CESAPI.command.CommandSync(connection)

        print("Acquire an initialization reflector.")
        press_any_key_to_continue()
        logger.info('Initializing laser tracker...')
        initialize(command, forceinit=False, manualiof=False)

        reflector_names, plane_coordinates_RHR = measure_plane_reflectors(
            command)
        logger.debug('Y-Z Plane Cartesian coordinates:\n{}'.format(
            plane_coordinates_RHR.transpose()))

        x_hatp, y_hatp, z_hatp = define_unit_vectors(plane_coordinates_RHR)
        logger.debug('Cartesian unit vectors:\n{}'.format(
            numpy.vstack([x_hatp, y_hatp, z_hatp]).transpose()))

        # For confirmation (but mostly for fun), physically point out the three coordinate axes.
        command.PointLaser(x_hatp[0], x_hatp[1], x_hatp[2])
        command.PointLaser(y_hatp[0], y_hatp[1], y_hatp[2])
        command.PointLaser(z_hatp[0], z_hatp[1], z_hatp[2])
        command.GoPosition(int(0), plane_coordinates_RHR[0, 0],
                           plane_coordinates_RHR[0, 1],
                           plane_coordinates_RHR[0, 2])
    finally:
        connection.disconnect()

    ref_coordinates_RHR = calculate_ref_coordinates(plane_coordinates_RHR,
                                                    y_hatp, z_hatp)
    logger.debug(
        'Reference Cartesian coordinates:\n{}'.format(ref_coordinates_RHR))

    logger.info(
        'Input Cartesian coordinates:\n{}'.format(plane_coordinates_RHR))
    logger.info(
        'Output Cartesian coordinates:\n{}'.format(ref_coordinates_RHR))

    transform_matrix = calculate_transform(plane_coordinates_RHR,
                                           ref_coordinates_RHR)

    csv_output = ['Transform Matrix:\n']
    for index, row in enumerate(transform_matrix):
        csv_output.append('{},{},{},{}\n'.format(row[0], row[1], row[2],
                                                 row[3]))
    logger.info(''.join(csv_output))

    tracker_coordinates_RHR = numpy.dot(transform_matrix,
                                        [[1.0], [0], [0], [0]])
    logger.info('Calculated tracker Cartesian coordinates:\n{}\n'.format(
        tracker_coordinates_RHR))

    theta_x, theta_y, theta_z = calculate_Euler_angles(transform_matrix[1:,
                                                                        1:])
    logger.info('Euler angles:\n{}, {}, {}\n'.format(theta_x, theta_y,
                                                     theta_z))

    ref_coordinates_SCC = convert_network_to_SCC(plane_coordinates_RHR)
    csv_output = ['Reference Spherical coordinates:\n']
    for index, point in enumerate(ref_coordinates_SCC):
        csv_output.append('{},{},{},{}\n'.format(reflector_names[index],
                                                 point[2], point[0], point[1]))
    logger.info(''.join(csv_output))

    ref_coordinates_CCC = convert_network_to_CCC(ref_coordinates_RHR)
    csv_output = ['Reference Cylindrical coordinates:\n']
    for index, point in enumerate(ref_coordinates_CCC):
        csv_output.append('{},{},{},{}\n'.format(reflector_names[index],
                                                 point[0], point[1], point[2]))
    logger.info(''.join(csv_output))