Beispiel #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)
 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)
 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)
Beispiel #4
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)
Beispiel #5
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 wmOutgoingMsg(msg):
    """ method must convert from AcousticModemData uint8[]]
    to AcousticModemPayload string 
    """
    global evologics_pub
    rospy.loginfo("WM outgoing msg being converted and sent to Evologics driver")
    
    uint8_payload = msg.payload
    converted_payload = str(uint8_payload)
    
    # populate new msg and send to evologics modem driver
    converted_msg = AcousticModemPayload()
    converted_msg.address = 5
    converted_msg.payload = converted_payload
    evologics_pub.publish(converted_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)
    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.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 send_from_buffer(self):
        if len(self.outgoing_msg_buffer) == 0:
            return

        msg_box = self.outgoing_msg_buffer.pop()

        header = struct.pack(FORMAT[HEADER], TYPE_TO_ID[msg_box.type], msg_box.id, rospy.Time.now().to_sec())
        payload = '{0}{1}'.format(header, msg_box.payload_body)

        modem_msg = AcousticModemPayload()
        modem_msg.header.stamp = rospy.Time.now()
        modem_msg.address = msg_box.address

        modem_msg.payload = payload

        if msg_box.id in self.single_msgs_out.keys():
            self.single_msgs_out[msg_box.id].update_last_time(rospy.Time.now().to_sec())

        rospy.loginfo('%s: Sending message of type %s with id %s to %s' % (self.name, msg_box.type, msg_box.id, msg_box.address))
        self.pub_modem.publish(modem_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)