예제 #1
0
    def __init__(self):

        rospy.init_node('exp_script')

        #shuffle gains
        pat_gains = [15,30]
        shuffle_pg = pat_gains
        np.random.shuffle(shuffle_pg)
        spg = shuffle_pg
        led_ids2.write('{0}\n'.format(spg))
        
        #shuffle patterns
        pat_ids = [5, 4, 6, 3]
        shuffle_ids = pat_ids
        np.random.shuffle(shuffle_ids)
        spids = shuffle_ids
        led_ids2.write('{0}\n'.format(spids))
        
        #3 - -90
        #5 - 0
        #4 - +90
        #6 - 180
        
        ### Experiment Protocol ###

        t0 = 12 #dark
        pattern_id0 = functools.partial(self.panels_off)
        
        t1 = 30 #1 min panels ON
        pattern_id1 = functools.partial(self.show_pattern, pattern_id=1, gain_x=30, bias_x = 0)

        t2 = 360 #2 min
        pattern_id2 = functools.partial(self.show_pattern, pattern_id=spids[0], gain_x=spg[0], bias_x = 0)
        
        t3 = 360 #2 min
        pattern_id3 = functools.partial(self.show_pattern, pattern_id=spids[1], gain_x=spg[1], bias_x = 0)
         

        self.display_action_list = [
                {'type': 'fixed', 'duration': t0, 'func': pattern_id0},
                
                {'type': 'fixed', 'duration': t1, 'func': pattern_id1},                
                {'type': 'fixed', 'duration': t2, 'func': pattern_id2},
                                
                {'type': 'fixed', 'duration': t1, 'func': pattern_id1},               
                {'type': 'fixed', 'duration': t3, 'func': pattern_id3},                                                   
                ]

        self.config_id = 1
        self.ctrl = display_ctrl.LedControler()
        self.ctrl.set_config_id(self.config_id)

        self.start_t = rospy.get_time()
        self.lock = threading.Lock()
        self.rolling_circ_mean = RollingCircularMean(size=1800)
        self.angles = rospy.Subscriber('/angle_data', MsgAngleData,self.on_angle_data_callback) 
        self.display_event = DisplayEvent(0.0, 0.0, self.do_nothing)
        
        self.pubpatters = rospy.Publisher('/pattern_ids',String , queue_size=10)
        self.mymsg = spids
예제 #2
0
with open(os.path.join(script_dir, 'tracked_git_repos.txt')) as f:
    repo_dirs = f.readlines()
assert git_tools.check_git_status(repo_dirs)
git_SHA = git_tools.get_SHA_keys(repo_dirs)

#############################################################################
################################ Run experiment #############################
#############################################################################

if __name__ == '__main__':
    try:
        import numpy as np
        print 'start'
        rospy.init_node('exp_script')
        exp_dir = script_dir
        ctrl = display_ctrl.LedControler()
        ctrl.load_SD_inf(exp_dir + '/firmware/SD.mat')

        exp_pub = rospy.Publisher('/exp_scripts/exp_state',
                                  MsgExpState,
                                  queue_size=10)
        exp_msg = MsgExpState()
        meta_pub = rospy.Publisher('/exp_scripts/exp_metadata',
                                   MsgExpMetadata,
                                   queue_size=10)

        rospy.wait_for_service('RefFrameServer')
        get_ref_frame = rospy.ServiceProxy('RefFrameServer', SrvRefFrame)
        # init experiment
        time.sleep(5)  # wait for all the publishers to come online