コード例 #1
0
def configure_sensor_bb_output(device_name, record=False, data_type="iq"):

    if data_type == "iq":
        x4m200_par_settings['output_control'] = (XTS_ID_BASEBAND_IQ, 1)
        x4m300_par_settings['output_control'] = (XTS_ID_BASEBAND_IQ, 1)
    elif data_type == "ap":
        x4m200_par_settings['output_control'] = (
            XTS_ID_BASEBAND_AMPLITUDE_PHASE, 1)
        x4m300_par_settings['output_control'] = (
            XTS_ID_BASEBAND_AMPLITUDE_PHASE, 1)
    else:
        print('data_taype is set to ' + data_type +
              ". It is not supported, please check arguments!")
        raise

    order_code = print_module_info(device_name)
    if order_code == "X4M200":
        xt_sensor = configure_x4m200(device_name, record, x4m200_par_settings)
    elif order_code == "X4M300":
        xt_sensor = configure_x4m300(device_name, record, x4m300_par_settings)
    else:
        print("This module is " + order_code +
              ". It does not support sensor baseband data output!!!")
        raise
    return xt_sensor
コード例 #2
0
def main():
    parser = OptionParser()
    parser.add_option(
        "-d",
        "--device",
        dest="device_name",
        help="Seral port name used by target XeThru sensor, i.e com8, /dev/ttyACM0",
        metavar="FILE")
    parser.add_option(
        "-r",
        "--record",
        action="store_true",
        default=False,
        dest="record",
        help="Enable recording")
    parser.add_option(
        "-f",
        "--file",
        dest="meta_filename",
        metavar="FILE",
        help="meta file from recording")

    (options, args) = parser.parse_args()

    if not options.meta_filename:
        if options.device_name:
            device_name = options.device_name
        else:
            try:
                device_name = auto()[0]
            except:
                print("Fail to find serial port, please specify it by use -d!")
                raise
        print_module_info(device_name)
        x4m200 = configure_x4m200(
            device_name, options.record, x4m200_par_settings)

    else:
        player = start_player(meta_filename=options.meta_filename)
        mc = ModuleConnector(player, log_level=0)
        x4m200 = mc.get_x4m200()
    print_x4m200_messages(x4m200)
コード例 #3
0
def configure_sensor_dp_output(device_name, record, datatype, format, dopplers,
                               num_messages):

    # Turn on outputs.
    if dopplers == "both":
        ctrl = XTID_OUTPUT_CONTROL_PD_FAST_ENABLE | XTID_OUTPUT_CONTROL_PD_SLOW_ENABLE
    elif dopplers == "fast":
        ctrl = XTID_OUTPUT_CONTROL_PD_FAST_ENABLE
    elif dopplers == "slow":
        ctrl = XTID_OUTPUT_CONTROL_PD_SLOW_ENABLE
    else:
        print("Pulse-Doppler instance not recognized.", file=sys.stderr)
        raise SystemExit(1)

    if datatype == "pulsedoppler" and format == "byte":
        x4m200_par_settings['output_control'] = (XTS_ID_PULSEDOPPLER_BYTE,
                                                 ctrl)
        x4m300_par_settings['output_control'] = (XTS_ID_PULSEDOPPLER_BYTE,
                                                 ctrl)
    elif datatype == "pulsedoppler" and format == "float":
        x4m200_par_settings['output_control'] = (XTS_ID_PULSEDOPPLER_FLOAT,
                                                 ctrl)
        x4m300_par_settings['output_control'] = (XTS_ID_PULSEDOPPLER_FLOAT,
                                                 ctrl)
    elif datatype == "noisemap" and format == "byte":
        x4m200_par_settings['output_control'] = (XTS_ID_NOISEMAP_BYTE, ctrl)
        x4m300_par_settings['output_control'] = (XTS_ID_NOISEMAP_BYTE, ctrl)
    elif datatype == "noisemap" and format == "float":
        x4m200_par_settings['output_control'] = (XTS_ID_NOISEMAP_FLOAT, ctrl)
        x4m300_par_settings['output_control'] = (XTS_ID_NOISEMAP_FLOAT, ctrl)
    else:
        print("Datatype/format not recognized.", file=sys.stderr)
        raise SystemExit(1)

    order_code = print_module_info(device_name)
    if order_code == "X4M200":
        xt_sensor = configure_x4m200(device_name, record, x4m200_par_settings)
    elif order_code == "X4M300":
        xt_sensor = configure_x4m300(device_name, record, x4m300_par_settings)
    else:
        print("This module is " + order_code +
              ". It does not support sensor baseband data output!!!")
        raise

    return xt_sensor
コード例 #4
0
def plot_record_movinglist_messages(device_name, record=False):
    history = 100
    empty_list = [None] * history
    distance_list = collections.deque(empty_list, maxlen=history)

    order_code = print_module_info(device_name)

    if order_code == "X4M200":
        xt_sensor = configure_x4m200(device_name, record, x4m200_par_settings)
    elif order_code == "X4M300":
        xt_sensor = configure_x4m300(device_name, record, x4m300_par_settings)
    else:
        print('This module does not support movinglist output!!!')
    print(
        "Initializing, it will take aroud 120s or 20s, depending on noise map option."
    )

    count = 0
    if order_code == "X4M200":
        while xt_sensor.read_message_respiration_sleep().sensor_state == 4:
            xt_sensor.read_message_respiration_movinglist()
            count = count + 1
            print(str(count))
    elif order_code == "X4M300":
        while xt_sensor.read_message_presence_single().presence_state == 2:
            xt_sensor.read_message_presence_movinglist()
            count = count + 1
            print(str(count))
    print("Initializing Done!")

    print("Start plot movinglist...")

    def read_movelist():
        respiration_sensor_state_text = ("BREATHING", "MOVEMENT",
                                         "MOVEMENT TRACKING", "NO MOVEMENT",
                                         "INITIALIZING")
        presence_sensor_state_text = ("NO_PRESENCE", "PRESENCE",
                                      "INITIALIZING")

        respiration_state_text = []
        respiration_state_text.append("BREATHING")
        respiration_state_text.append("MOVEMENT")
        respiration_state_text.append("MOVEMENT TRACKING")
        respiration_state_text.append("NO MOVEMENT")
        respiration_state_text.append("INITIALIZING")

        if order_code == "X4M200":
            d2 = xt_sensor.read_message_respiration_sleep()
            # sensor state
            state_txt.set_text('State: ' +
                               respiration_sensor_state_text[d2.sensor_state])
            # Object Distance
            distance_list.append(d2.distance)
            distance_txt.set_text('Distance: ' + str(d2.distance))
            d = xt_sensor.read_message_respiration_movinglist()
        elif order_code == "X4M300":
            d2 = xt_sensor.read_message_presence_single()
            # Sensor state
            state_txt.set_text('State: ' +
                               presence_sensor_state_text[d2.presence_state])
            # Object Distance
            distance_list.append(d2.distance)
            distance_txt.set_text('Distance: ' + str(d2.distance))
            d = xt_sensor.read_message_presence_movinglist()
        # Movement fast and slow
        mfast = np.array(d.movement_fast_items)
        mslow = np.array(d.movement_slow_items)
        return mfast, mslow, distance_list

    def animate(i):
        # Update plot data
        mfast, mslow, distance_list = read_movelist()
        line1.set_ydata(mfast)
        line2.set_ydata(mslow)
        line3.set_ydata(distance_list)
        return line1, line2, line3

    fig = plt.figure()
    state_txt = fig.text(0.75, 0.9, 'State: ')
    distance_txt = fig.text(0.5, 0.9, 'Distance: ')
    fig.suptitle("MovingList Example")
    ax1 = fig.add_subplot(3, 1, 1)
    ax2 = fig.add_subplot(3, 1, 2)
    ax3 = fig.add_subplot(3, 1, 3)
    ax1.set_ylabel('Fast Movement Metric')
    ax2.set_ylabel('Slow Movement Metric')
    ax3.set_ylabel('Distance')

    mfast, mslow, dist = read_movelist()

    # setting upperlimits for y-axsis
    ax1.set_ylim(0, 100)
    ax2.set_ylim(0, 100)
    ax3.set_xlim(0, history)
    ax3.set_ylim(0, 2)
    line1, = ax1.plot(mfast)
    line2, = ax2.plot(mslow)
    line3, = ax3.plot(dist)
    ani = FuncAnimation(fig, animate, interval=100)
    try:
        plt.show()
    finally:
        xt_sensor.set_sensor_mode(XTID_SM_STOP, 0)