diff --git a/include/autoware_v2x/cam_application.hpp b/include/autoware_v2x/cam_application.hpp index e606f43..80df55a 100644 --- a/include/autoware_v2x/cam_application.hpp +++ b/include/autoware_v2x/cam_application.hpp @@ -141,6 +141,7 @@ private: bool is_sender_; bool reflect_packet_; + unsigned long stationId_; int cam_num_; int received_cam_num_; diff --git a/src/cam_application.cpp b/src/cam_application.cpp index a7f54d3..3f1243f 100644 --- a/src/cam_application.cpp +++ b/src/cam_application.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,12 @@ namespace v2x RCLCPP_INFO(node_->get_logger(), "CamApplication started. is_sender: %d", is_sender_); set_interval(milliseconds(100)); //createTables(); + + // Generate ID for this station + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution dis(0, 4294967295); + stationId_ = dis(gen); } void CamApplication::set_interval(Clock::duration interval) { @@ -170,7 +177,7 @@ namespace v2x ItsPduHeader_t &header = message->header; header.protocolVersion = 2; header.messageID = ItsPduHeader__messageID_cam; - header.stationID = cam_num_; + header.stationID = stationId_; CoopAwareness_t &cam = message->cam; @@ -293,7 +300,7 @@ namespace v2x bvc.yawRate.yawRateConfidence = YawRateConfidence_unavailable; // ------------------------------ - RCLCPP_INFO(node_->get_logger(), "[CamApplication::send] Sending CAM"); + RCLCPP_INFO(node_->get_logger(), "[CamApplication::send] Sending CAM from station with ID %ld", stationId_); std::unique_ptr payload{new geonet::DownPacket()}; payload->layer(OsiLayer::Application) = std::move(message);