Example #1
0
	def send_msg(self, msg_idx, remote_address, ack, packet):
		acoustic_msg = AcousticModemPayload()
		acoustic_msg.msg_id = msg_idx
		acoustic_msg.address = remote_address
		acoustic_msg.ack = ack
		acoustic_msg.payload = packet
		# Send the packet to the Evologics driver which will send to modem
		self.acoustic_msg_pub.publish(acoustic_msg)
Example #2
0
 def send_info(self, data):
     # send a broadcast im to exchange the information stored
     print("Sending Broadcast IM with nav data...")
     self.flag_busy = True
     self.timer = rospy.Timer(rospy.Duration(0,
                                             int(self.time_for_bim * 1e9)),
                              self.timer_callback,
                              oneshot=True)
     # create and send the message
     msg = AcousticModemPayload()
     msg.ack = False
     msg.address = 255
     msg.payload = MSG_HEADER + self.data_packer.pack(data)
     self.pub_msg.publish(msg)
Example #3
0
 def send_requestV2(self, node):
     # send an im to a device to get his position
     # self.flag_busy = True
     self.timer = rospy.Timer(rospy.Duration(0,
                                             int(self.time_for_im * 1e9)),
                              self.timer_callback,
                              oneshot=True)
     # self.nodes_list.append(node)
     # create and send the message
     msg = AcousticModemPayload()
     msg.ack = True
     msg.address = node
     msg.payload = 'A'
     self.pub_msg.publish(msg)
    def parse_acoustic_im(self, tokens):
        """
        This method parses an incoming instant message and publish its content on a dedicated topic
        :param tokens: list of message fields
        """
        msg = AcousticModemPayload()
        msg.header.stamp = rospy.Time.now()

        msg.address = int(tokens[2])
        msg.duration = int(tokens[5])
        msg.rssi = float(tokens[6])
        msg.integrity = float(tokens[7])
        msg.relative_velocity = float(tokens[8])
        msg.payload = ','.join(tokens[9:])

        rospy.loginfo('%s: Received IM from node %s, payload: %s, info: %s' %(self.name, msg.address, repr(msg.payload), repr(msg.info)))
        self.received_cnt += 1
        self.pub_im_in.publish(msg)
Example #5
0
    def parse_acoustic_bm(self, tokens):
        """
        This method parse an incoming burst message and publish its content on a dedicated topic
        :param tokens: list of message fields
        """
        msg = AcousticModemPayload()
        msg.address = int(tokens[2])
        msg.payload = ','.join(tokens[9:])

        duration = int(tokens[7])  # in microseconds
        rel_speed = float(tokens[8])  # in meters per second
        info = {'duration': duration, 'relative_speed': rel_speed}
        msg.info = [KeyValue(key, value) for key, value in info.items()]

        rospy.loginfo(
            '%s: Received IM from node %s, payload: %s, info: %s' %
            (self.name, msg.address, repr(msg.payload), repr(msg.info)))
        self.pub_burst_in.publish(msg)
    def parse_acoustic_bm(self, tokens):
        """
        This method parse an incoming burst message and publish its content on a dedicated topic
        :param tokens: list of message fields
        """
        msg = AcousticModemPayload()
        msg.header.stamp = rospy.Time.now()

        msg.address = int(tokens[2])
        msg.bitrate = int(tokens[4])
        msg.rssi = float(tokens[5])
        msg.integrity = float(tokens[6])
        msg.propagation_time = int(tokens[7])
        self.propagation_time = int(tokens[7])
        # print 'Distance', self.propagation_time * 1500 * 10**-6
        msg.relative_velocity = float(tokens[8])

        msg.payload = ','.join(tokens[9:])

        rospy.loginfo('%s: Received burst message from node %s, payload: %s, info: %s' % (self.name, msg.address, repr(msg.payload), repr(msg.info)))
        self.received_cnt += 1
        self.pub_burst_in.publish(msg)