def writeVar():
    print 'What would you like to write?'
    s = raw_input(':')
    if BB.WriteSharedVar(SharedVarTypes.STRING, 'test_string', s):
        print 'Written to var: ' + str(s)
    else:
        print 'Var NOT written'
Example #2
0
 def bridgeROSTopicData(self, topicData):
     rospy.logdebug('ROS Topic "' + str(self.rosTopicName) +
                    '" updated from ROS. New value "' + str(topicData) +
                    '"')
     #try to parse the ros topic data to a BB SV valid data
     dicSuccess = False
     try:
         bbSharedVarValue = bridge_utils.ROS2BB_TYPE_MAP[
             self.rosMsgType][1](topicData)
         dicSuccess = True
     except KeyError:
         rospy.logfatal(
             'Error ocurred when updating the Shared Var "' +
             str(self.bbVarName) + '" from ROS. The "' +
             str(self.rosMsgType) +
             '" ROS MSG type doesn\'t have an associate function to parse a value. No value updated.'
         )
     except:
         rospy.logfatal(
             'An unexpected error ocurred when trying to update the Shared Var "'
             + str(self.bbVarName) + '" from ROS. No value updated.')
     if dicSuccess:
         if BB.WriteSharedVar(self.bbVarType, self.bbVarName,
                              bbSharedVarValue):
             rospy.loginfo('BB shared Var "' + str(self.bbVarName) +
                           '" updated from ROS.')
         else:
             rospy.logwarn('BB Shared Var "' + str(self.bbVarName) +
                           '" not updated from ROS.')
Example #3
0
def main():
  
	initialize()
    
	s = ''
	while s != 'exit':
		s = 'A1 motor on left 16:51:21'
		BB.WriteSharedVar(BB.SharedVarTypes.STRING, 'actuator', s)
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)
Example #5
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)
def main():

    global ban_ejec
    global s
    magnetTime = " "
    movTime = " "
    magnetStatus = " "
    Initialize()
    while True:
        if ban_ejec == 1:
            ban_ejec = 0
            BB.WriteSharedVar(BB.SharedVarTypes.STRING, 'interface', s)
        os.system('echo "st" | nc localhost 1099')
        os.system('echo "st" | nc localhost 1099')
        os.system('echo "st" | nc localhost 1099')

        s = os.popen('echo "st" | nc localhost 1099').read(500)
        i = 0
        b_fin = 0
        while b_fin == 0:
            if s != "":
                i = i + 1
                if s[i] == "7":
                    i = i + 1
                    if s[i] == "7":
                        i = i + 1
                        if s[i] == "E":
                            i = i + 1
                            if s[i] == "D":
                                i = i + 1
                                if s[i] == "0":
                                    i = i + 1
                                    if s[i] == "0":
                                        magnetTime = s[i + 8] + s[i + 9] + s[
                                            i + 10] + s[i + 11] + s[i + 12]
                                        print magnetTime
                                        magnetStatus = s[i + 14] + s[
                                            i +
                                            15] + s[i + 16] + s[i + 17] + s[
                                                i + 18] + s[i + 19] + s[
                                                    i + 20] + s[i + 21] + s[
                                                        i +
                                                        22] + s[i + 23] + s[
                                                            i + 24] + s[
                                                                i + 25] + s[
                                                                    i +
                                                                    26] + s[i +
                                                                            27]

                elif s[i] == "8":
                    i = i + 1
                    if s[i] == "8":
                        i = i + 1
                        if s[i] == "0":
                            i = i + 1
                            if s[i] == "2":
                                i = i + 1
                                if s[i] == "8":
                                    i = i + 1
                                    if s[i] == "0":
                                        movTime = s[i + 8] + s[i + 9] + s[
                                            i + 10] + s[i + 11] + s[i + 12]
                                        print movTime
                elif s[i] == "E":
                    i = i + 1
                    if s[i] == "n":
                        i = i + 1
                        if s[i] == "d":
                            b_fin = 1
        s = magnetTime + " " + movTime + " " + magnetStatus
        BB.WriteSharedVar(BB.SharedVarTypes.STRING, 'interface', s)
        time.sleep(.5)