publish_denm.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # ==============================================================================
4 # MIT License
5 #
6 # Copyright (c) 2023-2025 Institute for Automotive Engineering (ika), RWTH Aachen University
7 #
8 # Permission is hereby granted, free of charge, to any person obtaining a copy
9 # of this software and associated documentation files (the "Software"), to deal
10 # in the Software without restriction, including without limitation the rights
11 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 # copies of the Software, and to permit persons to whom the Software is
13 # furnished to do so, subject to the following conditions:
14 #
15 # The above copyright notice and this permission notice shall be included in all
16 # copies or substantial portions of the Software.
17 #
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 # SOFTWARE.
25 # ==============================================================================
26 
27 import rclpy
28 from rclpy.node import Node
29 from etsi_its_denm_msgs.msg import *
30 import utils
31 
32 class Publisher(Node):
33 
34  def __init__(self):
35 
36  super().__init__("denm_publisher")
37  topic = "/etsi_its_conversion/denm/in"
38  self.publisher = self.create_publisher(DENM, topic, 1)
39  self.timer = self.create_timer(1.0, self.publish)
40 
41  def publish(self):
42 
43  msg = DENM()
44 
45  msg.header.protocol_version = 2
46  msg.header.message_id = msg.header.MESSAGE_ID_DENM
47 
48  msg.denm.management = ManagementContainer()
49  msg.denm.management.event_position.latitude.value = int(msg.denm.management.event_position.latitude.ONE_MICRODEGREE_NORTH * 1e6 * 50.786852666670434)
50  msg.denm.management.event_position.longitude.value = int(msg.denm.management.event_position.longitude.ONE_MICRODEGREE_EAST * 1e6 * 6.046507490742381)
51  msg.denm.management.reference_time.value = utils.get_t_its(self.get_clock().now().nanoseconds)
52 
53  msg.denm.alacarte_is_present = True
54  msg.denm.alacarte.stationary_vehicle_is_present = True
55  msg.denm.alacarte.stationary_vehicle.carrying_dangerous_goods_is_present = True
56 
57  msg.denm.situation_is_present = True
58  msg.denm.situation.event_type.cause_code.value = 93
59  msg.denm.situation.event_type.sub_cause_code.value = 2
60 
61  dangerous_goods_extended = DangerousGoodsExtended()
62  dangerous_goods_extended.emergency_action_code_is_present = True
63  dangerous_goods_extended.emergency_action_code = "22" # IA5String
64  dangerous_goods_extended.phone_number_is_present = True
65  dangerous_goods_extended.phone_number.value = "0241 8025600" # NumericString
66  dangerous_goods_extended.company_name_is_present = True
67  dangerous_goods_extended.company_name = "ika, RWTH Aachen" # UTF8String
68  msg.denm.alacarte.stationary_vehicle.carrying_dangerous_goods = dangerous_goods_extended
69 
70  self.get_logger().info(f"Publishing DENM")
71  self.publisher.publish(msg)
72 
73 
74 if __name__ == "__main__":
75 
76  rclpy.init()
77  publisher = Publisher()
78  rclpy.spin(publisher)
79  rclpy.shutdown()
utils.get_t_its
def get_t_its(unix_nanoseconds)
Definition: utils.py:30
publish_denm.Publisher
Definition: publish_denm.py:32
publish_denm.Publisher.publisher
publisher
Definition: publish_denm.py:38
publish_denm.Publisher.publish
def publish(self)
Definition: publish_denm.py:41
msg
publish_denm.Publisher.timer
timer
Definition: publish_denm.py:39
publish_denm.Publisher.__init__
def __init__(self)
Definition: publish_denm.py:34


etsi_its_msgs_utils
Author(s): Jean-Pierre Busch , Guido Küppers , Lennart Reiher
autogenerated on Sun May 18 2025 02:32:12