CARLA
 
载入中...
搜索中...
未找到
PathLossModel.h
浏览该文件的文档.
1// Copyright (c) 2024 Institut fuer Technik der Informationsverarbeitung (ITIV) at the
2// 卡尔斯鲁厄理工学院
3//
4// 路径损耗模型
5//
6// This work is licensed under the terms of the MIT license.
7// For a copy, see <https://opensource.org/licenses/MIT>.
8
9#pragma once
10
11#include <vector>
12
13
14using ActorPowerMap = std::map<AActor *, float>;
15using ActorPowerPair = std::pair<AActor *, float>;
16
23
29
36
38{
39public:
40 PathLossModel(URandomEngine *random_engine);
41 void SetOwner(AActor *Owner);
43 void Simulate(const std::vector<ActorPowerPair> ActorList, UCarlaEpisode *CarlaEpisode, UWorld *World);
45 void SetParams(const float TransmitPower,
46 const float ReceiverSensitivity,
47 const float Frequency,
48 const float combined_antenna_gain,
49 const float path_loss_exponent,
50 const float reference_distance_fspl,
51 const float filter_distance,
52 const bool use_etsi_fading,
53 const float custom_fading_stddev);
54 float GetTransmitPower() { return TransmitPower; }
55 void SetPathLossModel(const EPathLossModel path_loss_model);
56
57private:
58 // 非视距(NLOSv,non-line-of-sight) 衍射
59 double CalcVehicleLoss(const double d1, const double d2, const double h);
60 // 计算接收功率
61 float CalculateReceivedPower(AActor *OtherActor,
62 const float OtherTransmitPower,
63 const FVector Source,
64 const FVector Destination,
65 const double Distance3d,
66 const double ht,
67 const double ht_local,
68 const double hr,
69 const double hr_local,
70 const double reference_z);
71 void EstimatePathStateAndVehicleObstacles(AActor *OtherActor, FVector Source, double TxHeight, double RxHeight, double reference_z, EPathState &state, std::vector<FVector> &vehicle_obstacles);
72 double MakeVehicleBlockageLoss(double TxHeight, double RxHeight, double obj_height, double obj_distance);
73 // 变量
75 UCarlaEpisode *mCarlaEpisode;
76 UWorld *mWorld;
78
81
82 // 常量
83 constexpr static float c_speedoflight = 299792458.0; // 光速(单位为m/s)
84
85 // 完整的双摄像路径损失
86 const double epsilon_r = 1.02;
87
88 // 参数
89 static double Frequency_GHz; // 传输频率(GHz)。5.9 GHz 是多个物理信道的标准。 5.9f;//5.9 GHz
90 static double Frequency; // Frequency_GHz * std::pow(10,9);
91 static double lambda; // c_speedoflight/Frequency;
92 float reference_distance_fspl; // 对数距离路径损耗模型的参考距离(单位:米m)
93 float TransmitPower; // 发送方传输功率(单位:毫瓦分贝 dBm)
94 float ReceiverSensitivity; // 接收器灵敏度(单位:毫瓦分贝 dBm)
95 EScenario scenario; // 选项:[urban, rustic, highly available],定义衰落噪声参数
96 float path_loss_exponent; // 由于建筑物遮挡导致的非视距损耗参数。没有单位,默认为 2.7;
97 float filter_distance; // 最大传输距离(以米为单位,默认为 500.0),上面的路径损耗计算因模拟速度而略过
99 bool use_etsi_fading; // 使用 ETSI 出版物中提到的衰落参数(true),或使用自定义衰落标准偏差
100 float custom_fading_stddev; // 衰减标准偏差的自定义值,仅当use_etsi_fading设置为 false 时才使用
101 float combined_antenna_gain; // 10.0 dBi, 发射机和接收机天线的组合增益(以 dBi 为单位),辐射效率和方向性的参数
102
103 // 根据参数设置预先计算的依赖参数
105
106protected:
107 /// 如果要追踪光线,则允许预处理的方法。
108
109 float ComputeLoss(AActor *OtherActor, FVector Source, FVector Destination, double Distance3d, double TxHeight, double RxHeight, double reference_z);
110 bool IsVehicle(const FHitResult &HitInfo);
111 bool GetLocationIfVehicle(const FVector CurrentActorLocation, const FHitResult &HitInfo, const double reference_z, FVector &location);
112 bool HitIsSelfOrOther(const FHitResult &HitInfo, AActor *OtherActor);
113 float CalculatePathLoss_WINNER(EPathState state, double Distance);
114 double CalculateNLOSvLoss(const FVector Source, const FVector Destination, const double TxHeight, const double RxHeight, const double RxDistance3d, std::vector<FVector> &vehicle_obstacles);
115
117
118 // 完整的双射线模型
119 double CalculateTwoRayPathLoss(double Distance3d, double TxHeight, double RxHeight);
120 // 简化的双射线模型
121 float CalculateTwoRayPathLossSimple(double Distance3d, double TxHeight, double RxHeight);
122
123 // 预计算功能
124 void CalculateFSPL_d0();
125 TArray<FHitResult> HitResult;
126};
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld * World
std::pair< AActor *, float > ActorPowerPair
EPathState
@ NLOSb
@ NLOSv
@ LOS
std::map< AActor *, float > ActorPowerMap
EScenario
@ Rural
@ Urban
@ Highway
EPathLossModel
@ Winner
@ Geometric
float ReceiverSensitivity
static double Frequency
float ComputeLoss(AActor *OtherActor, FVector Source, FVector Destination, double Distance3d, double TxHeight, double RxHeight, double reference_z)
如果要追踪光线,则允许预处理的方法。
double CalcVehicleLoss(const double d1, const double d2, const double h)
UWorld * mWorld
static double lambda
FVector CurrentActorLocation
static double Frequency_GHz
PathLossModel(URandomEngine *random_engine)
ActorPowerMap GetReceiveActorPowerList()
void Simulate(const std::vector< ActorPowerPair > ActorList, UCarlaEpisode *CarlaEpisode, UWorld *World)
EPathLossModel model
UCarlaEpisode * mCarlaEpisode
float path_loss_exponent
void SetScenario(EScenario scenario)
URandomEngine * mRandomEngine
float CalculatePathLoss_WINNER(EPathState state, double Distance)
void SetPathLossModel(const EPathLossModel path_loss_model)
double CalculateTwoRayPathLoss(double Distance3d, double TxHeight, double RxHeight)
static constexpr float c_speedoflight
EScenario scenario
float custom_fading_stddev
bool GetLocationIfVehicle(const FVector CurrentActorLocation, const FHitResult &HitInfo, const double reference_z, FVector &location)
float CalculateReceivedPower(AActor *OtherActor, const float OtherTransmitPower, const FVector Source, const FVector Destination, const double Distance3d, const double ht, const double ht_local, const double hr, const double hr_local, const double reference_z)
float CalculateTwoRayPathLossSimple(double Distance3d, double TxHeight, double RxHeight)
float filter_distance
double CalculateNLOSvLoss(const FVector Source, const FVector Destination, const double TxHeight, const double RxHeight, const double RxDistance3d, std::vector< FVector > &vehicle_obstacles)
double MakeVehicleBlockageLoss(double TxHeight, double RxHeight, double obj_height, double obj_distance)
void EstimatePathStateAndVehicleObstacles(AActor *OtherActor, FVector Source, double TxHeight, double RxHeight, double reference_z, EPathState &state, std::vector< FVector > &vehicle_obstacles)
void SetParams(const float TransmitPower, const float ReceiverSensitivity, const float Frequency, const float combined_antenna_gain, const float path_loss_exponent, const float reference_distance_fspl, const float filter_distance, const bool use_etsi_fading, const float custom_fading_stddev)
AActor * mActorOwner
float reference_distance_fspl
ActorPowerMap mReceiveActorPowerList
float GetTransmitPower()
bool HitIsSelfOrOther(const FHitResult &HitInfo, AActor *OtherActor)
void SetOwner(AActor *Owner)
TArray< FHitResult > HitResult
float combined_antenna_gain
const double epsilon_r
float CalculateShadowFading(EPathState state)
bool IsVehicle(const FHitResult &HitInfo)