def __init__(self): self.critique_mode = rospy.get_param('~critique_mode') if self.critique_mode not in ['average']: raise ValueError('Unsupported critique mode: %s' % self.critique_mode) self.feedback_mode = rospy.get_param('~feedback_mode') if self.feedback_mode not in ['append']: raise ValueError('Unsupported feedback mode: %s' % self.feedback_mode) self.log_reward = rospy.get_param('~using_log_rewards') evaluator_info = dict(rospy.get_param('~evaluators')) self.evaluators = {} for name, topic in evaluator_info.iteritems(): if name in self.evaluators: raise ValueError('Evaluator %s already registered!' % name) rospy.loginfo('Registering evaluator %s with topic %s', name, topic) wait_for_service(topic) self.evaluators[name] = CritiqueInterface(topic) self.critique_server = rospy.Service('~get_critique', GetCritique, self.critique_callback)
def __init__(self): self.dim = rospy.get_param('~dim') def farr(x): if hasattr(x, '__iter__'): return np.array([float(xi) for xi in x]) else: return np.full(self.dim, float(x)) self.scale = farr(rospy.get_param('~scale', 1.0)) self.offset = farr(rospy.get_param('~offset', 0.0)) self.sample_mode = rospy.get_param('~sample_mode', 'uniform') if self.sample_mode == 'discrete': n = rospy.get_param('~num_actions') self.actions = [self._sample_action() for _ in range(n)] set_topic = rospy.get_param('~set_topic') wait_for_service(set_topic) self.param_proxy = rospy.ServiceProxy(set_topic, SetParameters, persistent=True) trigger_mode = rospy.get_param('~trigger_mode', 'timer') if trigger_mode == 'timer': rate = rospy.get_param('~timer_rate') self.timer = rospy.Timer(rospy.Duration(1.0 / rate), callback=self.timer_callback) elif trigger_mode == 'break': self.break_sub = rospy.Subscriber('break', EpisodeBreak, self.break_callback) else: raise ValueError('Unknown trigger mode: %s' % trigger_mode) self._set_action()
def __init__(self): topics = rospy.get_param('~topics') for i, topic in enumerate(topics): rospy.loginfo('Using %s for fidelity %d', topic, i) wait_for_service(topic) self.evaluators = [CritiqueInterface(topic) for topic in topics] self.critique_server = rospy.Service('~get_critique', GetCritique, self.critique_callback)
def __init__(self): reset_topic = rospy.get_param('~reset_service') wait_for_service(reset_topic) self.reset_proxy = rospy.ServiceProxy(reset_topic, ResetFilter) self.min_reward = rospy.get_param('~min_reward') self.break_pub = rospy.Publisher('~breaks', EpisodeBreak, queue_size=1) self.wait_for_reward = rospy.get_param('~wait_for_reward', True) self.active = True self.reward_sub = rospy.Subscriber('reward', RewardStamped, queue_size=1, callback=self.reward_callback)
def __init__(self): self.mutex = Lock() self.verbose = rospy.get_param('~verbose', False) # Create parameter setter proxy setter_topic = rospy.get_param('~parameter_set_service') wait_for_service(setter_topic) self.setter_proxy = rospy.ServiceProxy(setter_topic, SetParameters, True) # Parse evaluation mode self.eval_mode = rospy.get_param('~evaluation_mode') if self.eval_mode == 'service_call': evaluation_topic = rospy.get_param('~start_evaluation_service', None) wait_for_service(evaluation_topic) self.evaluation_proxy = rospy.ServiceProxy(evaluation_topic, StartEvaluation, True) elif self.eval_mode == 'fixed_duration': self.evaluation_time = rospy.get_param('~evaluation_time') elif self.eval_mode == 'interactive': pass else: raise ValueError('Unknown mode %s' % self.eval_mode) # Check for evaluation setup self.setup_proxy = None setup_topic = rospy.get_param('~start_setup_service', None) if setup_topic is not None: wait_for_service(setup_topic) self.setup_proxy = rospy.ServiceProxy(setup_topic, StartSetup, True) # Check for evaluation teardown self.teardown_proxy = None teardown_topic = rospy.get_param('~start_teardown_service', None) if teardown_topic is not None: wait_for_service(teardown_topic) self.teardown_proxy = rospy.ServiceProxy(teardown_topic, StartTeardown, True) # Create filter reset proxy self.reset_proxy = None reset_topic = rospy.get_param('~reset_filter_service', None) if reset_topic is not None: wait_for_service(reset_topic) self.reset_proxy = rospy.ServiceProxy(reset_topic, ResetFilter, True) # Register recorders recording_topics = dict(rospy.get_param('~recorders')) self.recorders = {} for name, topic in recording_topics.iteritems(): wait_for_service(topic) self.recorders[name] = rospy.ServiceProxy(topic, SetRecording, True) self.critique_record = rospy.get_param('~critique_record') if self.critique_record not in self.recorders: raise ValueError('Critique not a registered recorder!') # Parse eval delay eval_delay = rospy.get_param('~evaluation_delay', 0.0) self.evaluation_delay = rospy.Duration(eval_delay) # Create critique server self.critique_server = rospy.Service('~get_critique', GetCritique, self.critique_callback)
def info_proxy(req): wait_for_service(info_topic) proxy = rospy.ServiceProxy(info_topic, GetParameterInfo) return proxy(req)
def get_proxy(req): wait_for_service(get_topic) proxy = rospy.ServiceProxy(get_topic, GetRuntimeParameter) return proxy(req)