$search
00001 #!/usr/bin/env python 00002 ################################################################# 00003 # \note randomly generate historical data(just mimic the DEM to generate historical data) 00004 # \input(from DEM) action sequence for task 00005 # \output(from DEM to learning) action sequence for task 00006 # \feedback(from learning to DEM) non 00007 # Project name: srs learning service for choosing priority 00008 # \author 00009 # Tao Cao, email:itaocao@gmail.com 00010 # 00011 # \date Date of creation: Dec 2011 00012 ################################################################# 00013 00014 import roslib; roslib.load_manifest('srs_likelihood_calculation') 00015 import rospy 00016 from std_msgs.msg import String 00017 00018 from random import choice 00019 00020 """ 00021 tasks=['get milk table1','get book table2','bring a cup of tea','open the door','get cup table1','help me walk around','cook paster','hoover the living room','get milk table2','get book table1','get cup table2','get milk fridge','get cup table3','help me walk around'] 00022 00023 intervals= [2,5,3,4,7,8,9,10,15,17,19,20] 00024 00025 """ 00026 00027 #the candidates locations/patent object for milkbox 00028 00029 foo = ['table2', 'table1','fridge'] 00030 00031 def historical_data_publisher(): 00032 pub = rospy.Publisher('historical_data', String) 00033 rospy.init_node('DEM_talker') 00034 while not rospy.is_shutdown(): 00035 #str = "%s %s"%(rospy.get_time(), choice(tasks)) 00036 #location= choice(foo) 00037 action="move(base,%s)"%choice(foo)#randomly chose locations 00038 actions=[action] 00039 actions.append('detect(milkbox)') 00040 action="move(base,%s)"%choice(foo)#randomly chose locations 00041 actions.append(action) 00042 actions.append('detect(milkbox)') 00043 actions.append('grasp(Milk box)') 00044 actions.append('place_on_tray(Milk box)') 00045 00046 #str='The action sequence is: '.join(actions) 00047 str=', '.join(actions) 00048 #str=actions 00049 print str 00050 #print'\n' 00051 #rospy.loginfo(str) 00052 pub.publish(String(str)) 00053 #interval_between_tasks=choice(intervals) 00054 #print "the random interval between tasks is %d" %interval_between_tasks 00055 rospy.sleep(1.0) 00056 if __name__ == '__main__': 00057 try: 00058 historical_data_publisher() 00059 except rospy.ROSInterruptException: pass