def __init__(self, boot_root=None): boot_root = expand_environment(boot_root) # Important, it can be deserialized from somewhere else self.boot_root = boot_root self.root = os.path.realpath(boot_root) self.dir_structure = DirectoryStructure(self.root) self.states_db = None self.log_index = None self.bo_config = None
def __init__(self, datadir): datadir = expand_environment(datadir) try: # concurrent if not os.path.exists(datadir): os.makedirs(datadir) except: pass self.storage = StorageFilesystem(datadir)
def __init__(self, root=None): if root is None: root = DirectoryStructure.DEFAULT_ROOT self.root = expand_environment(root) if not os.path.exists(self.root): msg = 'The root directory %r does not exist.' % self.root raise Exception(msg) self.log_format = BootOlympicsConstants.DEFAULT_LOG_FORMAT self.extra_log_dirs = []
def main(self): rospy.init_node('servo_demo', disable_signals=True) self.info('Started.') contracts.disable_all() boot_root = rospy.get_param('~boot_root') boot_root = expand_environment(boot_root) config_dir = rospy.get_param('~config_dir') id_robot_learned = rospy.get_param('~id_robot_learn') self.info('loading %r' % config_dir) GlobalConfig.global_load_dir(config_dir) id_agent = rospy.get_param('~id_agent') self.id_robot = rospy.get_param('~id_robot') self.sleep = rospy.get_param('~sleep', 0.005) self.info('sleep: %s' % self.sleep) # self.error_threshold = float(rospy.get_param('~error_threshold')) self.ratio_threshold = float(rospy.get_param('~ratio_threshold')) # 0.95 self.d_next_threshold = float(rospy.get_param('~d_next_threshold')) # 0.03 self.d_next_threshold_alone = float(rospy.get_param('~d_next_threshold_alone')) # 0.04 nmap = expand_environment(rospy.get_param('~map')) self.nmap = safe_pickle_load(nmap) raise_if_no_state = rospy.get_param('~raise_if_no_state', True) data_central = DataCentral(boot_root) ag_st = load_agent_state(data_central, id_agent, id_robot_learned, reset_state=False, raise_if_no_state=raise_if_no_state) self.agent, state = ag_st self.info('Loaded state: %s' % state) self.servo_agent = self.agent.get_servo() bo_config = get_boot_config() self.robot = bo_config.robots.instance(self.id_robot) self.boot_spec = self.robot.get_spec() self.publish_info_init() self.y = None self.y_goal = None self.started_now = False self.stopped_now = False self.e0 = 1 self.e = 1 self.last_boot_data = None self.state = STATE_WAIT self.index_cur = None self.info('Defining services') rospy.Service('set_goal', Empty, self.srv_set_goal) rospy.Service('start_servo', Empty, self.srv_start_servo) rospy.Service('stop_servo', Empty, self.srv_stop_servo) self.info('Finished initialization') self.count = 0 self.go()
def main(self): rospy.init_node('servo_demo', disable_signals=True) self.info('Started.') contracts.disable_all() boot_root = rospy.get_param('~boot_root') boot_root = expand_environment(boot_root) config_dir = rospy.get_param('~config_dir') id_robot_learned = rospy.get_param('~id_robot_learn') self.info('loading %r' % config_dir) GlobalConfig.global_load_dir(config_dir) id_agent = rospy.get_param('~id_agent') self.id_robot = rospy.get_param('~id_robot') self.sleep = rospy.get_param('~sleep', 0.005) self.info('sleep: %s' % self.sleep) # self.error_threshold = float(rospy.get_param('~error_threshold')) self.ratio_threshold = float( rospy.get_param('~ratio_threshold')) # 0.95 self.d_next_threshold = float( rospy.get_param('~d_next_threshold')) # 0.03 self.d_next_threshold_alone = float( rospy.get_param('~d_next_threshold_alone')) # 0.04 nmap = expand_environment(rospy.get_param('~map')) self.nmap = safe_pickle_load(nmap) raise_if_no_state = rospy.get_param('~raise_if_no_state', True) data_central = DataCentral(boot_root) ag_st = load_agent_state(data_central, id_agent, id_robot_learned, reset_state=False, raise_if_no_state=raise_if_no_state) self.agent, state = ag_st self.info('Loaded state: %s' % state) self.servo_agent = self.agent.get_servo() bo_config = get_boot_config() self.robot = bo_config.robots.instance(self.id_robot) self.boot_spec = self.robot.get_spec() self.publish_info_init() self.y = None self.y_goal = None self.started_now = False self.stopped_now = False self.e0 = 1 self.e = 1 self.last_boot_data = None self.state = STATE_WAIT self.index_cur = None self.info('Defining services') rospy.Service('set_goal', Empty, self.srv_set_goal) rospy.Service('start_servo', Empty, self.srv_start_servo) rospy.Service('stop_servo', Empty, self.srv_stop_servo) self.info('Finished initialization') self.count = 0 self.go()