Exemplo n.º 1
0
def scan_reference_network(command, cartesian_LTCS):
    # adjust laser tracker
    logger.debug('setting coordinate system type to Counter-Clockwise Spherical...')
    command.SetCoordinateSystemType(ES_CS_SCC)  # one of ES_CoordinateSystemType
    
    logger.debug('Cartesian LTCS:\n{}'.format(cartesian_LTCS))
    spherical_points = numpy.ndarray(numpy.shape(cartesian_LTCS))
    for index,cartesian_point in enumerate(cartesian_LTCS):
        spherical_points[index,2] = math.sqrt(numpy.sum(cartesian_point**2))
        spherical_points[index,0] = math.atan2(cartesian_point[1], cartesian_point[0])
        spherical_points[index,1] = math.acos(cartesian_point[2]/spherical_points[index,2])
    logger.debug('Spherical LTCS:\n{}'.format(spherical_points))

    logger.info('Measuring reference network with (both faces)...')
    measurements_face1 = numpy.ndarray((numpy.shape(cartesian_LTCS)[0], 9))
    measurements_face2 = numpy.ndarray((numpy.shape(cartesian_LTCS)[0], 9))
    for index,spherical_point in enumerate(spherical_points):
        logger.debug('Directing laser to coordinates {}...'.format(spherical_point))
        command.GoPosition(int(1), spherical_point[0], spherical_point[1], spherical_point[2])

        # the tracker always switches to face 1 after a GoPosition command
        measurements_face1[index] = measurement_to_array(measure(command))

        # the tracker always switches to face 1 after a GoPosition command
        command.ChangeFace()
        measurements_face2[index] = measurement_to_array(measure(command))
    logger.debug('Face 2 Measurements:\n{}'.format(measurements_face2))
    logger.debug('Face 1 Measurements:\n{}'.format(measurements_face1))

    # calculate the average coordinates from the two-face measurements
    spherical_LTCS = numpy.ndarray((numpy.shape(cartesian_LTCS)))
    for index in range(numpy.shape(measurements_face1)[0]):
        spherical_LTCS[index] = (measurements_face1[index,:3] + measurements_face2[index,:3]) / 2.0
    return spherical_LTCS
Exemplo n.º 2
0
def initialize(command, forceinit=False, manualiof=False):
    units = SystemUnitsDataT()
    units.lenUnitType = ES_LU_Millimeter  # ES_LengthUnit
    # units.angUnitType = ES_AU_Radian  # ES_AngleUnit
    # units.tempUnitType = ES_TU_Celsius  # ES_TemperatureUnit
    # units.pressUnitType = ES_PU_Mbar  # ES_PressureUnit
    # units.humUnitType = ES_HU_RH  # ES_HumidityUnit
    logger.debug('Setting units...')
    command.SetUnits(units)

    status = command.GetSystemStatus()
    logger.debug('Tracker Processor Status: {}'.format(
        status.trackerProcessorStatus))
    if forceinit or status.trackerProcessorStatus != ES_TPS_Initialized:  # ES_TrackerProcessorStatus
        try:
            init_result = command.Initialize()
            logger.debug('Initialize status: {}'.format(
                init_result.packetInfo.status))
        except Exception as e:
            logger.error('Initialize failed: {}'.format(e))
            return
        # At least the AT401 seems to complain about an unknown command failing due to "the sensor" not being stable
        # on the next command after an initialize. The tracker is fine after that, so just ignore this as a bug in the firmware.
        try:
            status = command.GetSystemStatus()
            logger.debug('Tracker Processor Status: {}'.format(
                status.trackerProcessorStatus))
        except Exception as e:
            if not 'Command 64' in str(e):
                raise e

    logger.debug('setting measurement mode...')
    command.SetMeasurementMode(
        ES_MM_Stationary)  # ES_MeasMode (only choice for AT4xx)

    logger.debug('setting stationary mode parameters...')
    mode_params = StationaryModeDataT()
    mode_params.lMeasTime = 1000  # 1 second
    command.SetStationaryModeParams(mode_params)

    logger.debug(
        'setting coordinate system type to Right-Handed Rectangular...')
    command.SetCoordinateSystemType(
        ES_CS_RHR)  # one of ES_CoordinateSystemType

    logger.debug('setting system settings...')
    settings = SystemSettingsDataT()
    # one of ES_WeatherMonitorStatus
    if manualiof:
        settings.weatherMonitorStatus = ES_WMS_ReadOnly
    else:
        settings.weatherMonitorStatus = ES_WMS_ReadAndCalculateRefractions
    settings.bApplyStationOrientationParams = int(1)
    settings.bKeepLastPosition = int(1)
    settings.bSendUnsolicitedMessages = int(1)
    settings.bSendReflectorPositionData = int(0)
    settings.bTryMeasurementMode = int(0)
    settings.bHasNivel = int(1)
    settings.bHasVideoCamera = int(1)
    command.SetSystemSettings(settings)
Exemplo n.º 3
0
def initialize(command, forceinit=False, manualiof=False):
    units = CESAPI.packet.SystemUnitsDataT()
    units.lenUnitType = CESAPI.packet.ES_LU_Millimeter  # ES_LengthUnit
    # units.angUnitType = ES_AU_Radian  # ES_AngleUnit
    # units.tempUnitType = ES_TU_Celsius  # ES_TemperatureUnit
    # units.pressUnitType = ES_PU_Mbar  # ES_PressureUnit
    # units.humUnitType = ES_HU_RH  # ES_HumidityUnit
    logger.debug('Setting units...')
    command.SetUnits(units)

    status = command.GetSystemStatus()
    logger.debug('Tracker Processor Status: {}'.format(
        status.trackerProcessorStatus))
    if forceinit or status.trackerProcessorStatus != CESAPI.packet.ES_TPS_Initialized:  # ES_TrackerProcessorStatus
        logger.debug('Initializing...')
        command.Initialize()

    logger.debug('setting measurement mode...')
    command.SetMeasurementMode(
        CESAPI.packet.ES_MM_Stationary)  # ES_MeasMode (only choice for AT4xx)

    logger.debug('setting stationary mode parameters...')
    mode_params = CESAPI.packet.StationaryModeDataT()
    mode_params.lMeasTime = 1000  # 1 second
    command.SetStationaryModeParams(mode_params)

    logger.debug(
        'setting coordinate system type to Right-Handed Rectangular...')
    command.SetCoordinateSystemType(
        CESAPI.packet.ES_CS_SCC)  # one of ES_CoordinateSystemType

    logger.debug('setting system settings...')
    settings = CESAPI.packet.SystemSettingsDataT()
    # one of ES_WeatherMonitorStatus
    if manualiof:
        settings.weatherMonitorStatus = CESAPI.packet.ES_WMS_ReadOnly
    else:
        settings.weatherMonitorStatus = CESAPI.packet.ES_WMS_ReadAndCalculateRefractions
    settings.bApplyStationOrientationParams = int(1)
    settings.bKeepLastPosition = int(1)
    settings.bSendUnsolicitedMessages = int(1)
    settings.bSendReflectorPositionData = int(0)
    settings.bTryMeasurementMode = int(0)
    settings.bHasNivel = int(1)
    settings.bHasVideoCamera = int(1)
    command.SetSystemSettings(settings)
Exemplo n.º 4
0
def scan_other_network(command,
                       ref_network_DSCS_filename_entry,
                       network_DSCS_filename_entry,
                       status_label=None):
    ref_network_DSCS_filename = ref_network_DSCS_filename_entry.get()
    reflector_names, cylindrical_DSCS, cartesian_DSCS = load_DSCS_coordinates(
        ref_network_DSCS_filename)

    network_LTCS_filename, reflector_names, approx_spherical_LTCS = convert_network_to_LTCS(
        ref_network_DSCS_filename_entry,
        network_DSCS_filename_entry,
        status_label=None)

    set_status(
        status_label,
        'Setting coordinate system type to Counter-clockwise Spherical...')
    command.SetCoordinateSystemType(
        ES_CS_SCC)  # one of ES_CoordinateSystemType

    measurements_face1 = numpy.ndarray(
        (numpy.shape(approx_spherical_LTCS)[0], 9))
    for index, spherical_point in enumerate(approx_spherical_LTCS):
        logger.debug(
            'Directing laser to coordinates {}...'.format(spherical_point))
        command.GoPosition(int(1), spherical_point[0], spherical_point[1],
                           spherical_point[2])

        # the tracker always switches to face 1 after a GoPosition command
        measurements_face1[index] = measurement_to_array(measure(command))
    logger.debug('Face 1 Measurements:\n{}'.format(measurements_face1))

    # calculate the average coordinates from the two-face measurements
    spherical_LTCS = numpy.ndarray((numpy.shape(approx_spherical_LTCS)))
    for index in range(numpy.shape(measurements_face1)[0]):
        spherical_LTCS[index] = measurements_face1[index, :3]
    logger.debug('Spherical LTCS:\n{}'.format(spherical_LTCS))

    save_coordinates(network_LTCS_filename, reflector_names, spherical_LTCS)
    logger.info('Saved the spherical LTCS coordinates to\n{}'.format(
        network_LTCS_filename))
    set_status(status_label, 'Saved data.')
Exemplo n.º 5
0
def scan_reference_network(command,
                           ref_network_DSCS_filename_entry,
                           reflector_name_selections,
                           initial_measurements,
                           labels,
                           status_label=None):
    ref_network_DSCS_filename = ref_network_DSCS_filename_entry.get()
    reflector_names, cylindrical_DSCS, cartesian_DSCS = load_DSCS_coordinates(
        ref_network_DSCS_filename)

    initial_reflector_names = []
    for index, reflector_name_selection in enumerate(
            reflector_name_selections):
        reflector_name = reflector_name_selection.get()
        initial_reflector_names.append(reflector_name)
        logger.debug('Selected reflector {}: {}'.format(
            index, initial_reflector_names[index]))
    initial_reflector_names = numpy.array(initial_reflector_names)
    logger.debug('Initial reflector names: {}'.format(initial_reflector_names))
    if len(numpy.unique(initial_reflector_names)) != len(
            initial_reflector_names):
        raise Exception(
            'One or more duplicates were found in the reflector selections.')

    for index, label in enumerate(labels):
        if label.cget('bg') != 'green':
            raise Exception(
                'Initial reflector measurement {} was not performed.'.format(
                    index))

    initial_cartesian_LTCS = numpy.ndarray((len(initial_measurements), 3))
    for point_index, initial_measurement in enumerate(initial_measurements):
        for coordinate_index, coordinate in enumerate(initial_measurement):
            initial_cartesian_LTCS[point_index, coordinate_index] = coordinate
    transform_matrix = calculate_transform(reflector_names,        cartesian_DSCS,\
                                           initial_reflector_names, initial_cartesian_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)

    set_status(
        status_label,
        'Setting coordinate system type to Counter-clockwise Spherical...')
    command.SetCoordinateSystemType(
        ES_CS_SCC)  # one of ES_CoordinateSystemType

    logger.debug('Cartesian LTCS:\n{}'.format(cartesian_LTCS))
    approx_spherical_LTCS = cartesian_to_spherical(cartesian_LTCS)
    logger.debug('Spherical LTCS:\n{}'.format(approx_spherical_LTCS))

    set_status(status_label, 'Ref. network 2-face measurements...')
    measurements_face1 = numpy.ndarray((numpy.shape(cartesian_LTCS)[0], 9))
    measurements_face2 = numpy.ndarray((numpy.shape(cartesian_LTCS)[0], 9))
    for index, spherical_point in enumerate(approx_spherical_LTCS):
        logger.debug(
            'Directing laser to coordinates {}...'.format(spherical_point))
        command.GoPosition(int(1), spherical_point[0], spherical_point[1],
                           spherical_point[2])

        # the tracker always switches to face 1 after a GoPosition command
        measurements_face1[index] = measurement_to_array(measure(command))

        # the tracker always switches to face 1 after a GoPosition command
        command.ChangeFace()
        measurements_face2[index] = measurement_to_array(measure(command))
    logger.debug('Face 1 Measurements:\n{}'.format(measurements_face1))
    logger.debug('Face 2 Measurements:\n{}'.format(measurements_face2))

    # calculate the average coordinates from the two-face measurements
    spherical_LTCS = numpy.ndarray((numpy.shape(cartesian_LTCS)))
    for index in range(numpy.shape(measurements_face1)[0]):
        spherical_LTCS[index] = (measurements_face1[index, :3] +
                                 measurements_face2[index, :3]) / 2.0
    logger.debug('Spherical LTCS:\n{}'.format(spherical_LTCS))

    transform_filename, inv_transform_filename, ref_network_LTCS_filename \
        = generate_ref_data_filenames(ref_network_DSCS_filename)
    set_status(status_label, 'Saving data...')
    save_matrix(transform_filename, transform_matrix)
    logger.info('Saved the LTCS-to-DSCS transform matrix to\n{}'.format(
        transform_filename))
    save_matrix(inv_transform_filename, inv_transform_matrix)
    logger.info('Saved the DSCS-to-LTCS transform matrix to\n{}'.format(
        inv_transform_filename))
    save_coordinates(ref_network_LTCS_filename, reflector_names,
                     spherical_LTCS)
    logger.info('Saved the spherical LTCS reference coordinates to\n{}'.format(
        ref_network_LTCS_filename))
    set_status(status_label, 'Ready...')