예제 #1
0
def main():
    BB.Initialize(2001, fmap)
    BB.Start()
    BB.SetReady(True)

    print 'Waiting for commands...'
    BB.Wait()
예제 #2
0
def initialize():
    BB.Initialize(2100, fmap)
    BB.Start()

    BB.CreateSharedVar(BB.SharedVarTypes.STRING, 'actuator')
    BB.WriteSharedVar(BB.SharedVarTypes.STRING, 'actuator', 'initial_value')

    BB.SetReady(True)
예제 #3
0
def initialize():
	
	BB.Initialize(2100, fmap)
  	BB.Start()
	BB.SetReady(True)
	
	BB.SubscribeToSharedVar('recognizedSpeech',mySubscriptionHandler)
	BB.SubscribeToSharedVar('hypothesizedSpeech',myHandlerHypothesis)
예제 #4
0
def initialize():
	BB.Initialize(2100, fmap)
  	BB.Start()
	
	BB.CreateSharedVar(BB.SharedVarTypes.STRING, 'actuator')
        BB.WriteSharedVar(BB.SharedVarTypes.STRING, 'actuator', 'initial_value')
        BB.SubscribeToSharedVar('actuator',ActuatorHandler, subscriptionType='writeothers', reportType='content')

	BB.SetReady(True)
예제 #5
0
def main():
    BB.Initialize(2003)
    BB.Start()
    BB.SetReady(True)

    BB.SubscribeToSharedVar('test_string', printingFunc)

    print 'Waiting for shared variable updates...'

    BB.Wait()
예제 #6
0
def Initialize():
    BB.Initialize(2030, fmap)
    BB.Start()
    BB.CreateSharedVar(BB.SharedVarTypes.STRING, 'interface')
    BB.CreateSharedVar(BB.SharedVarTypes.STRING, 'smarthause')
    BB.SubscribeToSharedVar('smarthause',
                            LamparaHandler,
                            subscriptionType='writeothers',
                            reportType='content')
    BB.SetReady()
def main():
    BB.Initialize(2000, fmap)
    BB.Start()
    BB.SetReady(True)

    print 'Sending command say...'
    print BB.SendAndWait(Command('spg_say', 'This is a test.'), 5000, 3)

    print 'Sending Async command...'
    ps = ParallelSender(
        Command('othertst_slowfunction', 'This is another test.'), 5000, 3)

    while ps.sending:
        print 'sending...'
        time.sleep(0.3)

    print 'Response received...'
    print ps.response

    BB.Wait()
def main():

    BB.Initialize(2002)
    BB.Start()
    BB.SetReady(True)

    s = ''
    while s != '4':
        print '1. Create var'
        print '2. Write var'
        print '3. Read var'
        print '4. exit'

        s = raw_input(':')

        if s == '1':
            createVar()
        elif s == '2':
            writeVar()
        elif s == '3':
            readVar()
예제 #9
0
def main():
    BB.Initialize(2100, fmap)
    BB.Start()
    BB.SetReady(True)

    BB.Wait()
예제 #10
0
def main():
	bbConnectionPort = 2080;
	topicsInclusionList = ["*"];
	svInclusionList = ["*"];
	srvInclusionList = [];
	cmdInclusionList = [];

	#load the config files
	parser = OptionParser()
	parser.add_option('-f', '--configfile', action='store', type='string', dest='configFile', help='Bridge rules')
	(options, args) = parser.parse_args()

	if options.configFile:
		#parser.error('Configuration File not given')
		#load the configuration options
		with open(options.configFile) as config_file:
			configOptions = json.load(config_file)
		#print configOptions
		try:
			topicsInclusionList = configOptions['ros_topics']
		except:
			topicsInclusionList = []
		try:
			svInclusionList = configOptions['blackboard_sv']
		except:
			svInclusionList = []
		try:
			srvInclusionList = configOptions['ros_services']
		except:
			srvInclusionList = []
		try:
			cmdInclusionList = configOptions['blackboard_cmd']
		except:
			cmdInclusionList = []
		try:
			bbConnectionPort = configOptions["bb_port"]
		except:
			bbConnectionPort = 2080
	
	#define the list of topics to be bridged and its msg types
	callersMap = {
		#'add_two_ints' : BB2ROS_ServiceCallers.add_two_ints_caller,
		'default_server' : BB2ROS_DefaultServicesCallers.default_caller
	}

	#Manage BB connection
	print 'Initializing BB connection'
	BB.Initialize(bbConnectionPort, callersMap)
	BB.Start()
	BB.SetReady(True)

	#Manage ROS connection
	#rospy.init_node('bbros_bridge', log_level = rospy.DEBUG)
	rospy.init_node('bbros_bridge')
	#atend calls from ROS nodes to BB commands
	for bbCommand in cmdInclusionList:
		ROS2BB_CommandsCalls(bbCommand, Default_ROS_BB_Bridge)

	#BRIDGE SHARED VARS AND TOPICS
	#create a dictionary of bridges, for the BB shared vars and for the ROS topics
	bb2rosPublishersDictionary = {}
	ros2bbPublishersDictionary = {}
	#initialize the dictionaries of shared vars and topics already bridged
	bbVarsList = {}
	rosTopicsDictionary = {}

	#verify if new shared vars or ros topic where created
	rate = rospy.Rate(10) # 1hz rate
	while not rospy.is_shutdown():
		#get the BB shared vars list, this list is a dictionary {varName:varType}
		new_bbVarsList = getBBSharedVars(svInclusionList)
		#get the ROS published topics list
		new_rosTopicsDictionary = getROSTopicList(topicsInclusionList)

		#verify if there are news bb sv not bridged yet
		bbVarsToBridge = dictionaryDifference(new_bbVarsList, bbVarsList)
		#verify if there are news ros topics not bridged yet
		rosTopicsToBridge = dictionaryDifference(new_rosTopicsDictionary, rosTopicsDictionary)

		if len(bbVarsToBridge) > 0:
			rospy.logdebug('Current BB var-type dictionary: ' + str(bbVarsList))
			rospy.logdebug('New BB var-type dictionary: ' + str(new_bbVarsList))
		if len(rosTopicsToBridge) > 0:
			rospy.logdebug('Current ROS topic-type dictionary: ' + str(rosTopicsDictionary))
			rospy.logdebug('New ROS topic-type dictionary: ' + str(new_rosTopicsDictionary))

		#bridge the bb shared vars to ros topics
		bridge_BB2ROS_SharedVars(bbVarsToBridge, rosTopicsDictionary, bb2rosPublishersDictionary)
		#bridge the ros topics to bb shared vars
		bridge_ROS2BB_Topics(rosTopicsToBridge, bbVarsList, ros2bbPublishersDictionary)

		#update the originals bb sv dictionary and ros topics dictionary
		dictionaryAddition(bbVarsList, bbVarsToBridge)
		dictionaryAddition(rosTopicsDictionary, rosTopicsToBridge)

		rate.sleep()