CARLA
Loading...
Searching...
No Matches
CustomV2XSensor.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
13#include "V2X/PathLossModel.h"
14#include <list>
15#include <map>
16#include <memory>
17#include <mutex>
18#include "CustomV2XSensor.generated.h"
19
20
21UCLASS()
22class CARLA_API ACustomV2XSensor : public ASensor
23{
24 GENERATED_BODY()
25
26 using FV2XData = carla::sensor::data::CustomV2XDataS;
27 using V2XDataList = std::list<carla::sensor::data::CustomV2XData>;
28 struct SenderId {
30 std::string ChannelId;
31
32 bool operator < (const SenderId & other) const {
33 if ( Actor != other.Actor ) {
34 return Actor < other.Actor;
35 }
36 else {
37 return ChannelId < other.ChannelId;
38 }
39 }
40 };
41 using ActorV2XDataMap = std::map<SenderId, V2XDataList>;
42
43public:
44 ACustomV2XSensor(const FObjectInitializer &ObjectInitializer);
45
46 static FActorDefinition GetSensorDefinition();
47
48 void Set(const FActorDescription &ActorDescription) override;
49 void SetPropagationParams(const float TransmitPower,
50 const float ReceiverSensitivity,
51 const float Frequency,
52 const float combined_antenna_gain,
53 const float path_loss_exponent,
54 const float reference_distance_fspl,
55 const float filter_distance,
56 const bool use_etsi_fading,
57 const float custom_fading_stddev);
58 void SetScenario(EScenario scenario);
59 void SetPathLossModel(const EPathLossModel path_loss_model);
60
61 virtual void PrePhysTick(float DeltaSeconds) override;
62 virtual void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTime) override;
63 void SetOwner(AActor *Owner) override;
64 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
65
66 void Send(const carla::rpc::CustomV2XBytes &data);
67
68private:
69 SenderId GetSenderId() { return {this, mChannelId}; }
70
71 // infrastructure stationID cannot be dermined before sending data, because on construction time the CARLA Actor is not yet created
72 void UpdateStationId();
73 // global data
74 static std::mutex v2xDataLock;
77
78 std::unique_ptr<PathLossModel> PathLossModelObj;
79
80 const long mProtocolVersion = 2;
81 const long mMessageId = ITSContainer::messageID_custom;
82 long mStationId {0};
83 std::string mChannelId;
84};
EScenario
EPathLossModel
SenderId GetSenderId()
std::list< carla::sensor::data::CustomV2XData > V2XDataList
std::map< SenderId, V2XDataList > ActorV2XDataMap
static std::mutex v2xDataLock
static ActorV2XDataMap gActorV2XDataMapNextFrame
std::string mChannelId
std::unique_ptr< PathLossModel > PathLossModelObj
static ActorV2XDataMap gActorV2XDataMap
@ messageID_custom
Definition LibITS.h:176
Fixed-size binary payload carried by the custom V2X sensor (sensor.other.v2x_custom).
This file contains definitions of common data structures used in traffic manager.
A definition of a Carla Actor with all the variation and attributes.
A description of a Carla Actor with all its variation.