Commits

iorodeo  committed 07eac74 Draft

Added dropped frames report to the mct command line tool.

  • Participants
  • Parent commits 8f16882

Comments (0)

Files changed (4)

File mct_computer_admin/manifest.xml

   <depend package="rospy"/>
   <depend package="mct_xml_tools"/>
   <depend package="mct_introspection"/>
-  <depand package="mct_file_tools"/>
+  <depend package="mct_frame_drop_corrector"/>
 
   <rosdep name="fabric"/>
 

File mct_computer_admin/src/mct_computer_admin/cluster_control_fab.py

 import mct_xml_tools
 import mct_introspection
 import mct_utilities
+from mct_frame_drop_corrector import frame_drop_corrector
 
 from fabric.api import *
 from fabric.decorators import hosts
 master = mct_introspection.get_master()
 
 cmd_msgs = {
-        'wakeup': 'waking up camera computers',
-        'push_setup': 'pushing setup to slave computers',
-        'shutdown': 'shutting down camera computers',
-        'list_slaves': 'listing slaves',
+        'wakeup': 'wake up camera computers',
+        'push_setup': 'push setup to slave computers',
+        'shutdown': 'shut down camera computers',
+        'list_slaves': 'listing slaves computers',
         'rospack_profile': 'run rospack profile on all slave computers', 
-        'pull': 'pulling latest version of the mct from repository to slave computers',
-        'pull_master': 'pulling laster version of the mct from repository on master',
+        'pull': 'pull latest version of the mct from repository to slave computers',
+        'pull_master': 'pull lastest version of the mct from repository on master',
         'pull_all': 'pull latest version of the mct repository for all computers in current machine',
         'pull_from_master': 'pull latest version of the mct repository from the master to the slaves', 
         'clone': 'clone new version of mct from repository of slave computers',
         'clean': 'remove old version of mct',
         'rosmake': 'use rosmake to build mct on slave computers',
         'rosmake_preclean': 'use rosmake to build mct on slave computers',
-        'update_machine_def': 'updating the ROS xml machine launch file',
-        'list_machine_def': 'listing current machine definition',
-        'list_cameras': 'listing cameras',
-        'list_camera_assignment': 'listing camera assignment', 
-        'rsync_camera_calibrations': 'rsyncing camera calibraitons',
-        'clean_camera_calibrations': 'cleaning camera calibrations',
-        'show_camera_info':  'launching camera_info viewers',
+        'update_machine_def': 'update the ROS xml machine launch file',
+        'list_machine_def': 'list current machine definition',
+        'list_cameras': 'list cameras',
+        'list_camera_assignment': 'list camera assignment', 
+        'rsync_camera_calibrations': 'rsync camera calibraitons',
+        'clean_camera_calibrations': 'clean camera calibrations',
+        'show_camera_info':  'launch camera_info viewers',
         'show_camera_info_header': 'launch camera_info/header viewers',
         'show_camera_info_header_seq': 'launch camera_info/header/seq viewers',
         'show_corrector_seq': 'launch seq_and_image_corr/seq viewers',
         'test': 'test command for development',
-        'camera_assignment': 'starting camera assigment application',
-        'zoom_calibration': 'starting zoom calibration application',
-        'camera_calibration': 'starting the camera calibration application',
-        'homography_calibration': 'starting the homography calibration application',
-        'transform_2d_calibration': 'starting the 2d transform calibration application',
-        'tracking_2d': 'starting the 2d tracking application',
+        'camera_assignment': 'start camera assigment application',
+        'zoom_calibration': 'start zoom calibration application',
+        'camera_calibration': 'start the camera calibration application',
+        'homography_calibration': 'start the homography calibration application',
+        'transform_2d_calibration': 'start the 2d transform calibration application',
+        'tracking_2d': 'start the 2d tracking application',
+        'frame_drop_test':  '2d tracking application w/ frame dropped frame logger',
+        'frames_dropped': 'print a report of the frames dropped by the system',
         'help': 'Command line interface to MCT (Multi-Camera Tracker)',
-        'frame_drop_test':  '2d tracking application w/ frame dropped frame logger',
+        'list_all': 'list all available commands',
         }
 
 fab_cmds = [ 
     print('  Testing')
     print('  -------')
     print('    frame_drop_test - 2D tracking application w/ dropped frame logger')
+    print('    frames_dropped  - prints a report listing the frames dropped by each camera')
     print()
     print('  Help')
     print('  ----')
-    print('    help                 - prints this menu')
-    print('    help_admin           - provides a list of advanced administrative commands')
+    print('    help      - prints this menu')
+    print('    list_all  - prints a list and description of all commands')
     print()
 
+def list_all():
+    """
+    Prints list of all available commands.
+    """
+    max_len = max([len(k) for k in cmd_msgs])
+    for k,v in sorted(cmd_msgs.items()):
+        n = max_len - len(k)
+        print('  ', k,' '*n, v)
+    print()
+
+
 def camera_assignment():
     """
     Starts the camera assignment application.
     for filename in filename_list:
         os.remove(filename)
 
+def frames_dropped():
+    """
+    Prints a simple report of the frames dropped by the system. 
+    """
+    info_dict = frame_drop_corrector.info_all()
+    max_name_len = max([len(name) for name in info_dict])
+    print('  ', 'camera', ' '*(max_name_len - len('camera')), '#','  seq list')
+    print('  ', '-'*60)
+    for name, seq_list in sorted(info_dict.items(),cmp=info_item_cmp):
+        pad = ' '*(max_name_len - len(name))
+        print('  ', name, pad, len(seq_list), '  ', seq_list)
+    print()
+
+def info_item_cmp(x,y):
+    """
+    Comparison function for items (k,v) in the dictionary returned
+    byt the frame_drop_corrector.info_all() function. 
+    """
+    x_num = int(x[0].split('_')[1])
+    y_num = int(y[0].split('_')[1])
+    if x_num > y_num:
+        return 1
+    elif x_num < y_num:
+        return -1
+    else:
+        return 0
+
 def test(*args):
     print('test')
 

File mct_frame_drop_corrector/src/mct_frame_drop_corrector/frame_drop_corrector.py

     resp = proxy()
     return list(resp.seq_list)
 
+def info_all():
+    service_name_list = mct_introspection.get_services()
+    service_name_list = [x for x in service_name_list if 'frame_drop_info' in x]
+    info_dict = {}
+    for name in service_name_list:
+        name_split = name.split('/')
+        camera = name_split[2]
+        info_dict[camera] = info(name)
+    return info_dict
+        
 def reset(namespace):
     if 'frame_drop_reset' in namespace:
         service_name = namespace
     if service == 'info':
         val = info(namespace)
         print(val)
+    elif service == 'info_all':
+        info_dict = info_all()
+        for k, v in info_dict.iteritems():
+            print(k,v)
     elif service == 'reset':
         reset(namespace)
     elif service == 'reset_all':

File mct_web_apps/src/mct_web_apps/tracking_2d_node_startup.py

         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)
+    # 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)
+    # 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)
+    # 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.
-    ## --------------------------------------------------------------------
+    # --------------------------------------------------------------------
+    # 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_time_stamp_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)
+    # 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_time_stamp_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)
 
 # ---------------------------------------------------------------------------------
 if __name__ == '__main__':