publish_denm_ts.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_ts_msgs.msg import *
30 import utils
31 
32 class Publisher(Node):
33 
34  def __init__(self):
35 
36  super().__init__("denm_ts_publisher")
37  topic = "/etsi_its_conversion/denm_ts/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.value = 2
46  msg.header.message_id.value = msg.header.message_id.DENM
47  msg.header.station_id.value = 44
48 
49  msg.denm.management = ManagementContainer()
50  msg.denm.management.event_position.latitude.value = int(1e7 * 50.786852666670434)
51  msg.denm.management.event_position.longitude.value = int(1e7 * 6.046507490742381)
52  msg.denm.management.reference_time.value = utils.get_t_its(self.get_clock().now().nanoseconds)
53 
54  msg.denm.alacarte_is_present = True
55  msg.denm.alacarte.stationary_vehicle_is_present = True
56  msg.denm.alacarte.stationary_vehicle.carrying_dangerous_goods_is_present = True
57 
58  msg.denm.situation_is_present = True
59  msg.denm.situation.event_type.cc_and_scc.choice = CauseCodeChoice.CHOICE_HUMAN_PROBLEM93
60  msg.denm.situation.event_type.cc_and_scc.human_problem93.value = HumanProblemSubCauseCode.HEART_PROBLEM
61 
62  dangerous_goods_extended = DangerousGoodsExtended()
63  dangerous_goods_extended.emergency_action_code_is_present = True
64  dangerous_goods_extended.emergency_action_code = "22" # IA5String
65  dangerous_goods_extended.phone_number_is_present = True
66  dangerous_goods_extended.phone_number.value = "0241 8025600" # NumericString
67  dangerous_goods_extended.company_name_is_present = True
68  dangerous_goods_extended.company_name = "ika, RWTH Aachen" # UTF8String
69  msg.denm.alacarte.stationary_vehicle.carrying_dangerous_goods = dangerous_goods_extended
70 
71  self.get_logger().info(f"Publishing DENM (TS)")
72  self.publisher.publish(msg)
73 
74 
75 if __name__ == "__main__":
76 
77  rclpy.init()
78  publisher = Publisher()
79  rclpy.spin(publisher)
80  rclpy.shutdown()
utils.get_t_its
def get_t_its(unix_nanoseconds)
Definition: utils.py:30
msg
publish_denm_ts.Publisher.__init__
def __init__(self)
Definition: publish_denm_ts.py:34
publish_denm_ts.Publisher.publisher
publisher
Definition: publish_denm_ts.py:38
publish_denm_ts.Publisher.timer
timer
Definition: publish_denm_ts.py:39
publish_denm_ts.Publisher.publish
def publish(self)
Definition: publish_denm_ts.py:41
publish_denm_ts.Publisher
Definition: publish_denm_ts.py:32


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