Exemplo n.º 1
0
    def execute(self, userdata):
        found = 'tb05'
        foreign_master_uri = make_master_uri(found)

        try:
            msg = CommunicationProtocol()
            msg.sender = self.id
            msg.receiver = found
            msg.request = 'hive'

            connect(self.topic, foreign_master_uri)
            rospy.sleep(0.2)
            self.publisher.publish(msg)
            disconnect(self.topic, foreign_master_uri)

        except:
            print "exception"
            disconnect(self.topic, foreign_master_uri)

        return 'done'
Exemplo n.º 2
0
    def execute(self, userdata):
        found = 'tb05'
        foreign_master_uri = make_master_uri(found)

        try:
            msg = CommunicationProtocol()
            msg.sender = self.id
            msg.receiver = found
            msg.request = 'hive'

            connect(self.topic, foreign_master_uri)
            rospy.sleep(0.2)
            self.publisher.publish(msg)
            disconnect(self.topic, foreign_master_uri)

        except:
            print "exception"
            disconnect(self.topic, foreign_master_uri)

        return 'done'
Exemplo n.º 3
0
def send(receiver, msg):
    global open_cons, sending
    sending = True
    foreign_master_uri = make_master_uri(receiver)
    try:
        print open_cons
        if not foreign_master_uri in open_cons.keys():
            if connect(foreign_master_uri):
                print "connected"
                open_cons[foreign_master_uri]['last_used'] = rospy.Time.now()
                rospy.sleep(1.5)
            else:
                print "failed"

        rospy.sleep(0.5)
        for i in xrange(2):
            comm_pub.publish(msg)
            rospy.sleep(0.2)
        open_cons[foreign_master_uri]['last_used'] = rospy.Time.now()
       
    except Exception as e:
        print "exception", e

    sending = False