Exemple #1
0
def start_cameras_and_mjpeg_servers():
    """
    Starts the cameras and mjpeg servers
    """
    if not DEVELOP: 

        # Stop camera triggers
        camera_trigger.stop()

        # Start cameras
        camera_master.set_camera_launch_param(
                frame_rate='camera_driver',
                trigger=True
                )
        camera_master.start_cameras()
        # Wait until the camera nodes are ready and then start the mjpeg servers
        while not mct_introspection.camera_nodes_ready(mode='calibration'):
            time.sleep(0.2)

        # Delay until all camera nodes are ready and start triggers
        time.sleep(10)
        frame_rates = file_tools.read_frame_rates()
        camera_trigger.start(frame_rates['camera_calibration'])

        # Start mjpeg servers
        mjpeg_servers.set_topics(['image_raw'])
        mjpeg_servers.start_servers()
        target_info = file_tools.read_target_info(config.camera_calib_target_type)
        calibrator_master.start(target_info['size'], target_info['square'])
Exemple #2
0
def start_nodes():

    if not DEVELOP: 
        # Stop camera triggers
        camera_trigger.stop()

        # Start camera nodes and wait until they are ready
        camera_master.set_camera_launch_param(
                frame_rate='camera_driver',
                trigger=True
                )
        camera_master.start_cameras()
        while not mct_introspection.camera_nodes_ready(mode='calibration'):
            time.sleep(0.2)
        
        # Delay until all camera nodes are ready and start triggers
        time.sleep(10)
        frame_rates = file_tools.read_frame_rates()
        camera_trigger.start(frame_rates['zoom_calibration'])

        # Start zoom tool nodes and wait until they are ready
        zoom_tool_master.start()
        while not mct_introspection.zoom_tool_image_ready():
            time.sleep(0.2)
        
        # Start mjpeg servers and throttleing 
        mjpeg_servers.set_topics(['image_zoom_tool'])
        mjpeg_servers.start_servers()
        
        # Turn on active target two led patter
        mct_active_target.led_pair()
Exemple #3
0
def start_nodes():
    if not DEVELOP: 

        # Stop camera triggers
        camera_trigger.stop()

        file_tools.rsync_camera_calibrations()
        
        # Start camera nodes and wait until they are ready
        camera_master.set_camera_launch_param(
                frame_rate='camera_driver',
                trigger=True
                )
        camera_master.start_cameras()
        while not mct_introspection.camera_nodes_ready(mode='calibration'):
            time.sleep(0.2)
        
        # Delay until all camera nodes are ready and start triggers
        time.sleep(10)
        frame_rates = file_tools.read_frame_rates()
        camera_trigger.start(frame_rates['transform_2d_calibration'])

        # Start image_proc nodes and wait until they are ready
        image_proc_master.start_image_proc()
        while not mct_introspection.image_proc_nodes_ready():
            time.sleep(0.2)
        
        # Wait for rectified images to be ready - required for launching transform 
        # calibrators.
        while not mct_introspection.image_rect_ready():
            time.sleep(0.2)
        
        # Start transform 2d calibrator nodes and wait until ready
        transform_2d_calibrator_master.start()
        while not mct_introspection.transform_2d_calibrator_nodes_ready():
            time.sleep(0.2)
        
        # Start mjpeg servers and throttleing 
        topic_list = [ 'image_transform_calibration_0', 'image_transform_calibration_1']
        mjpeg_servers.set_topics(topic_list)
        mjpeg_servers.start_servers()
Exemple #4
0
def start_cameras_and_mjpeg_servers():
    """
    Starts the cameras and mjpeg servers
    """
    if not DEVELOP:
        # Stop camera triggers
        camera_trigger.stop()

        # Wait until camera inspectors are running and then start cameras
        while not mct_introspection.camera_inspectors_ready():
            time.sleep(0.2)
        camera_inspector_master.start_cameras()

        # Delay until all camera nodes are ready and start triggers
        time.sleep(10)
        frame_rates = file_tools.read_frame_rates()
        camera_trigger.start(frame_rates['assignment'])

        # Wait until the camera nodes are ready and then start the mjpeg servers
        while not mct_introspection.camera_nodes_ready(mode='inspector'):
            time.sleep(0.2)
        mjpeg_servers.set_topics(['image_raw'])
        mjpeg_servers.start_servers()
Exemple #5
0
camera_master.start_cameras()
# Wait until the camera nodes are ready and then start the mjpeg servers
while not mct_introspection.camera_nodes_ready(mode='calibration'):
    time.sleep(0.2)
print('done')

# Delay until all camera nodes are ready and start triggers
print(' * camera nodes sync delay ... ', end='')
sys.stdout.flush()
time.sleep(10)
print('done')

print(' * starting camera triggers ... ', end='')
sys.stdout.flush()
frame_rates = file_tools.read_frame_rates()
camera_trigger.start(frame_rates['camera_calibration'])
print('done')

print(' * starting mjpeg servers... ',end='')
sys.stdout.flush()
mjpeg_servers.set_topics(['image_raw'])
mjpeg_servers.start_servers()
print('done')

print(' * starting camera calibrators ... ',end='')
sys.stdout.flush()
target_info = file_tools.read_target_info(config.camera_calib_target_type)
calibrator_master.start(target_info['size'], target_info['square'])
print('done')

Exemple #6
0
def tracking_2d_node_startup(debug=False):

    # Stop camera triggers
    debug_print(' * stopping camera triggers ... ', end='', debug=debug)
    sys.stdout.flush()
    camera_trigger.stop()
    debug_print('done', debug=debug)

    file_tools.rsync_camera_calibrations(verbose=True)

    # Start camera nodes and wait until they are ready
    debug_print(' * starting camera nodes ... ', end='', debug=debug)
    sys.stdout.flush()
    camera_master.set_camera_launch_param(frame_rate='camera_driver',
                                          trigger=True)
    camera_master.start_cameras()
    while not mct_introspection.camera_nodes_ready(mode='tracking'):
        time.sleep(ready_poll_dt)
    debug_print('done', debug=debug)

    # Delay until all camera nodes are ready
    debug_print(' * camera nodes sync delay ... ', end='', debug=debug)
    sys.stdout.flush()
    time.sleep(camera_startup_t)
    debug_print('done', debug=debug)

    # Reset rand sync
    debug_print(' * resetting rand sync ... ', end='', debug=debug)
    sys.stdout.flush()
    status = reset_rand_sync()
    if not status:
        raise RuntimeError, 'unable to reset rand_sync device'
    debug_print('done', debug=debug)

    # Restart camera triggers
    debug_print(' * starting camera triggers ... ', end='', debug=debug)
    sys.stdout.flush()
    frame_rates = file_tools.read_frame_rates()
    camera_trigger.start(frame_rates['tracking_2d'])
    debug_print('done', debug=debug)

    # Start image_proc nodes and wait until they are ready
    debug_print(' * starting image proc nodes ... ', end='', debug=debug)
    sys.stdout.flush()
    image_proc_master.start_image_proc()
    while not mct_introspection.image_proc_nodes_ready():
        time.sleep(ready_poll_dt)
    debug_print('done', debug=debug)

    # Wait for image rect topics
    debug_print(' * waiting for image_rect topics ... ', end='', debug=debug)
    sys.stdout.flush()
    while not mct_introspection.image_rect_ready():
        time.sleep(ready_poll_dt)
    debug_print('done', debug=debug)

    # Start frame drop corrector nodes and wait until they are ready
    debug_print(' * starting frame drop correctors ... ', end='', debug=debug)
    sys.stdout.flush()
    frame_drop_corrector_master.start()
    while not mct_introspection.frame_drop_correctors_ready():
        time.sleep(ready_poll_dt)
    debug_print('done', debug=debug)

    # Stop camera triggers again to sync frame drop correctors.  Note, It
    # appears we do need to stop the camera triggers twice during startup.
    # Sync'ing the frame drop correctors requires stopping the camera triggers
    # resetting the frame drop correctors and then re-starting the triggers.
    debug_print(' * stopping camera triggers ... ', end='', debug=debug)
    sys.stdout.flush()
    camera_trigger.stop()
    debug_print('done', debug=debug)

    # Reset frame drop correctors
    debug_print(' * frame drop corrector sync delay ... ', end='', debug=debug)
    time.sleep(buffer_flush_t)
    frame_drop_corrector.reset_all()
    debug_print('done', debug=debug)

    # --------------------------------------------------------------------
    # Need to reset time stamp watchdog ... or change how it functions
    #
    # Delay working on this until we know what modifcations we are making
    # to the watchdog.
    # --------------------------------------------------------------------

    # Restart camera triggers
    debug_print(' * starting camera triggers ... ', end='', debug=debug)
    sys.stdout.flush()
    frame_rates = file_tools.read_frame_rates()
    camera_trigger.start(frame_rates['tracking_2d'])
    debug_print('done', debug=debug)

    # Start frame skipper nodes and wait unti they are ready
    debug_print(' * starting frame skippers ... ', end='', debug=debug)
    sys.stdout.flush()
    frame_skipper_master.start_frame_skippers()
    while not mct_introspection.frame_skippers_ready():
        time.sleep(ready_poll_dt)
    debug_print('done', debug=debug)

    # Start image stitcher nodes and wait until stitched image topics ready
    debug_print(' * starting image stitchers ... ', end='', debug=debug)
    sys.stdout.flush()
    image_stitcher_master.start_image_stitchers()
    while not mct_introspection.stitched_images_ready():
        time.sleep(ready_poll_dt)
    debug_print('done', debug=debug)

    # Start three point tracker nodes and wait until they are ready.
    debug_print(' * starting three point trackers ... ', end='', debug=debug)
    sys.stdout.flush()
    three_point_tracker_master.start_three_point_trackers()
    while not mct_introspection.three_point_trackers_ready():
        time.sleep(ready_poll_dt)
    while not mct_introspection.three_point_tracker_synchronizers_ready():
        time.sleep(ready_poll_dt)
    debug_print('done', debug=debug)

    # Start stitched image labeler and wait until stitched images are published.
    debug_print(' * starting stitched image lablers ... ', end='', debug=debug)
    sys.stdout.flush()
    stitched_image_labeler_master.start_stitched_image_labelers()
    while not mct_introspection.stitched_image_labelers_ready():
        time.sleep(ready_poll_dt)
    debug_print('done', debug=debug)

    # Start avi writer nodes
    debug_print(' * starting avi writers ... ', end='', debug=debug)
    sys.stdout.flush()
    avi_writer_master.start_avi_writers()
    debug_print('done', debug=debug)

    # Start tracking pts loggers
    debug_print(' * starting tracking pts loggers ... ', end='', debug=debug)
    sys.stdout.flush()
    tracking_pts_logger_master.start_tracking_pts_loggers()
    debug_print('done', debug=debug)

    # Start mjpeg servers
    debug_print(' * starting mjpeg servers ... ', end='', debug=debug)
    sys.stdout.flush()

    # Set topics for mjpeg servers
    mjpeg_topics = []
    # Add time stamp watchdog image
    mjpeg_topics.append('/image_frame_drop_watchdog')

    # Add the stitched and tracking pts images for all regions
    for region in regions_dict:
        mjpeg_topics.append('/{0}/image_stitched_labeled'.format(region))
        mjpeg_topics.append('/{0}/image_tracking_pts'.format(region))
        mjpeg_topics.append('/{0}/image_tracking_info'.format(region))

    # Add any extra video images
    for v in extra_video_dict.values():
        mjpeg_topics.append(v)

    mjpeg_servers.set_topics(mjpeg_topics)
    mjpeg_servers.start_servers()
    debug_print('done', debug=debug)
Exemple #7
0
camera_master.set_camera_launch_param(frame_rate='camera_driver', trigger=True)
camera_master.start_cameras()
while not mct_introspection.camera_nodes_ready(mode='calibration'):
    time.sleep(0.2)
print('done')

# Delay until all camera nodes are ready
print(' * camera nodes sync delay ... ', end='')
sys.stdout.flush()
time.sleep(10)
print('done')

print(' * starting camera triggers ... ', end='')
sys.stdout.flush()
frame_rates = file_tools.read_frame_rates()
camera_trigger.start(frame_rates['transform_2d_calibration'])
print('done')

# Start image_proc nodes and wait until they are ready
print(' * starting image proc nodes ... ', end='')
sys.stdout.flush()
image_proc_master.start_image_proc()
while not mct_introspection.image_proc_nodes_ready():
    time.sleep(0.2)
print('done')

# Wait for rectified images to be ready - required for launching transform
# calibrators.
print(' * waiting for image rect topics ...', end='')
sys.stdout.flush()
while not mct_introspection.image_rect_ready():
Exemple #8
0
def mode_change_handler(obj_response, new_mode):

    old_mode = redis_tools.get_str(db, 'current_mode')
    new_mode = str(new_mode)

    if old_mode == new_mode:
        return

    redis_tools.set_str(db, 'current_mode', new_mode)
    frame_rate = redis_tools.get_dict(db, 'frame_rate_dict')['tracking_2d']
    regions_dict = redis_tools.get_dict(db, 'regions_dict')

    # Stop camera triggers
    camera_trigger.stop()
    time.sleep(0.5)  # wait for all frames to pass throught the system
    reset_rand_sync()

    if old_mode == 'recording' or new_mode == 'recording':

        # Find logging and avi recording commands
        service_list = mct_introspection.get_services()
        logging_nodes = get_logging_nodes(service_list)
        recording_nodes = get_recording_nodes(service_list)

        if (old_mode == 'recording') and (new_mode != 'recording'):

            # Stop logging and recording
            for node in logging_nodes:
                tracking_pts_logger.stop_logging(node)
            for node in recording_nodes:
                avi_writer.stop_recording(node, 'dummy.avi', frame_rate)

        if new_mode == 'recording':

            # Create sub-directory for log files.
            log_dir_base = redis_tools.get_dict(
                db, 'logging_params_dict')['directory']
            log_dir = os.path.join(log_dir_base,
                                   datetime.datetime.now().isoformat())
            os.mkdir(log_dir)

            # Start loggers
            for node in logging_nodes:
                filename = '_'.join(node.split('/')[1:3])
                filename = os.path.join(log_dir, '{0}.json'.format(filename))
                tracking_pts_logger.start_logging(node, filename)

            # Start avi recordings
            for node in recording_nodes:
                filename = '_'.join(node.split('/')[1:3])
                filename = os.path.join(log_dir, '{0}.avi'.format(filename))
                avi_writer.start_recording(node, filename, frame_rate)

    if new_mode in ('preview', 'recording'):
        regions_dict = redis_tools.get_dict(db, 'regions_dict')
        # Reset frame drop correctors and restart camera triggers
        frame_drop_corrector.reset_all()
        frame_drop_watchdog.reset()

        # Reset image_stitcher and three_point_tracker synchronizer for all tracking regions
        for region in regions_dict:
            image_stitcher.reset(region)
            three_point_tracker_synchronizer.reset(region)

        camera_trigger.start(frame_rate)
Exemple #9
0
camera_master.set_camera_launch_param(frame_rate='camera_driver', trigger=True)
camera_master.start_cameras()
while not mct_introspection.camera_nodes_ready(mode='calibration'):
    time.sleep(0.2)
print('done')

# Delay until all camera nodes are ready
print(' * camera nodes sync delay ... ', end='')
sys.stdout.flush()
time.sleep(10)
print('done')

print(' * starting camera triggers ... ', end='')
sys.stdout.flush()
frame_rates = file_tools.read_frame_rates()
camera_trigger.start(frame_rates['homography_calibration'])
print('done')

# Start image_proc nodes and wait until they are ready
print(' * starting image proc nodes ... ', end='')
sys.stdout.flush()
image_proc_master.start_image_proc()
while not mct_introspection.image_proc_nodes_ready():
    time.sleep(0.2)
print('done')

# Wait for rectified images to be ready - required for launching homography
# calibrators.
print(' * waiting for image rect topics ...', end='')
sys.stdout.flush()
while not mct_introspection.image_rect_ready():