4 """ Radar_Pa package, this is radar_pa_node """ 64 from can_msgs.msg
import Frame
65 from radar_pa_msgs.msg
import radar_msg_A
66 from radar_pa_msgs.msg
import radar_msg_B
67 from radar_pa_msgs.msg
import radar_msg
68 from extract_message
import extract_GPR_v10
73 """This is a Radar Node class, which instansiate a node and 74 subscribig to received_messages topice to be able to read can messages. 75 Then, publish the extracted message A on "can_messages_A", extracted 76 message A on "can_messages_A" and both A,B on "radar_messages".""" 81 rospy.init_node(
'radar_pa_node.py', anonymous=
True)
87 rospy.Subscriber(
'received_messages', Frame, self.
callback)
90 self.
pub_a = rospy.Publisher(
'can_messages_A', radar_msg_A, queue_size=10)
92 self.
pub_b = rospy.Publisher(
'can_messages_B', radar_msg_B, queue_size=10)
94 self.
pub = rospy.Publisher(
'radar_messages', radar_msg , queue_size=10)
100 self.global_msg.header = std_msgs.msg.Header()
103 self.global_msg.header.frame_id =
"radar" 106 self.global_msg.header.stamp = rospy.Time.now()
110 """This method calling the extection function and fill the msg with 111 the result from the extraction function.""" 112 self.global_msg.header.stamp = data.header.stamp
115 if (data.id >= 512
and data.id <= 607):
123 if (isinstance(msg, radar_msg_A)):
125 self.pub_a.publish(msg)
128 self.pub_b.publish(msg)
133 rospy.logdebug(
'the whole packet is completed')
137 rospy.logdebug(
'can id out of range %d (%s)', data.id, hex(data.id))
143 """ Ths function to fill the global message with the extracted result""" 144 if (data.id % 2 == 0):
146 i = (data.id - 512)/2
147 self.global_msg.data_A[i] = msg
150 j = (data.id - 513) / 2
151 self.global_msg.data_B[j] = msg
158 """ This function used to cehck all counters are the same before 159 publishing the message to the topic""" 162 for i
in range(len(self.global_msg.data_A)):
163 if ((self.global_msg.data_A[0].counter != self.global_msg.data_A[i].counter)
or \
164 (self.global_msg.data_A[0].counter != self.global_msg.data_B[i].counter)):
165 rospy.loginfo(
'counter is not equal')
172 if __name__ ==
'__main__':
179 except rospy.ROSInterruptException:
def fill_message(self, data, msg)
def check_message_counter(self)