evaluate_trajectories.py
Go to the documentation of this file.
00001 
00002 from hrl_generic_arms.ep_control import EPGenerator, EPC, EPStopConditions
00003 
00004 ##
00005 # Runs a series of trials by generating new EPGenerators on a list of different
00006 # parameters.
00007 # @param ep_gen_eval_creator Function which takes a parameter object and returns an EPGenerator
00008 # @param ep_gen_eval_params a list of trials to be evaluated
00009 # @param time_step: Time between successive calls to equi_pt_generator
00010 # @param timeout - time after which the epc motion will stop.
00011 # @return (dict, list) A dictionary of the result statistics and a list of the results.
00012 def evaluate_trajectories(ep_gen_setup_creator, ep_gen_setup_params,
00013                           ep_gen_eval_creator, ep_gen_eval_params, time_step, timeout):
00014     epc = EPC('eval_trajs')
00015     result_dict = {'test not run' : len(ep_gen_eval_params)}
00016     result_list = ['test not run'] * len(ep_gen_eval_params)
00017     i = 0
00018     for ep_gen_setup_param, ep_gen_eval_param in zip(ep_gen_setup_params, ep_gen_eval_params):
00019         ep_gen_setup = ep_gen_eval_creator(ep_gen_param)
00020         stop = epc.epc_motion(ep_gen_setup, time_step, timeout)
00021         if stop == EPStopConditions.ROSPY_SHUTDOWN
00022             break
00023         if stop == EPStopConditions.SUCCESSFUL:
00024             ep_gen_eval = ep_gen_eval_creator(ep_gen_eval_param)
00025             stop = epc.epc_motion(ep_gen_eval, time_step, timeout)
00026             if stop == EPStopConditions.ROSPY_SHUTDOWN
00027                 break
00028         else:
00029             rospy.loginfo('[evaluate_trajectories] Unsuccessful setup, not doing trajectory.')
00030             stop = 'unsuccessful setup'
00031         if stop not in result_dict:
00032             result_dict[stop] = 1
00033         else:
00034             result_dict[stop] += 1
00035         result_dict['test not run'] -= 1
00036         result_list[i] = stop
00037         i += 1
00038         yield result_dict, result_list
00039 


hrl_generic_arms
Author(s): Kelsey Hawkins
autogenerated on Wed Nov 27 2013 11:53:37