Skip to content

Commit

Permalink
add python script to publisch Dummy-VAM
Browse files Browse the repository at this point in the history
  • Loading branch information
gkueppers committed Aug 22, 2024
1 parent df404cd commit 7d7db64
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ ros2 run etsi_its_conversion etsi_its_conversion_node \
```bash
./publish_cpm_ts.py
```

```bash
./publish_vam_ts.py
```
71 changes: 71 additions & 0 deletions utils/scripts/publish_vam_ts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python

# ==============================================================================
# MIT License
#
# Copyright (c) 2023-2024 Institute for Automotive Engineering (ika), RWTH Aachen University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ==============================================================================

import rclpy
from rclpy.node import Node
from etsi_its_vam_ts_msgs.msg import *


class Publisher(Node):

def __init__(self):

super().__init__("vam_ts_publisher")
topic = "/etsi_its_conversion/vam_ts/in"
self.publisher = self.create_publisher(VAM, topic, 1)
self.timer = self.create_timer(1.0, self.publish)

def publish(self):

msg = VAM()

msg.header.value.protocol_version.value = 2
msg.header.value.message_id.value = msg.header.value.message_id.VAM
msg.header.value.station_id.value = 32

msg.vam.generation_delta_time.value = msg.vam.generation_delta_time.ONE_MILLI_SEC

msg.vam.vam_parameters.basic_container.station_type.value = msg.vam.vam_parameters.basic_container.station_type.PASSENGER_CAR
msg.vam.vam_parameters.basic_container.reference_position.latitude.value = int(1e7 * 51.215169611787054)

vru_high_frequency_container = VruHighFrequencyContainer()
vru_high_frequency_container.speed.speed_value.value = 1
vru_high_frequency_container.heading.value.value = vru_high_frequency_container.heading.value.WGS84_NORTH
vru_high_frequency_container.longitudinal_acceleration.longitudinal_acceleration_value.value = 0
vru_high_frequency_container.device_usage_is_present = True
vru_high_frequency_container.device_usage.value = vru_high_frequency_container.device_usage.LISTENING_TO_AUDIO
msg.vam.vam_parameters.vru_high_frequency_container = vru_high_frequency_container

self.get_logger().info(f"Publishing VAM (TS)")
self.publisher.publish(msg)


if __name__ == "__main__":

rclpy.init()
publisher = Publisher()
rclpy.spin(publisher)
rclpy.shutdown()

0 comments on commit 7d7db64

Please sign in to comment.