CARLA
 
载入中...
搜索中...
未找到
PathLossModel.h
浏览该文件的文档.
1// Copyright (c) 2024 Institut fuer Technik der Informationsverarbeitung (ITIV) at the
2// Karlsruhe Institute of Technology
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
9#include <vector>
10
11
12using ActorPowerMap = std::map<AActor *, float>;
13using ActorPowerPair = std::pair<AActor *, float>;
14
21
27
34
36{
37public:
38 PathLossModel(URandomEngine *random_engine);
39 void SetOwner(AActor *Owner);
41 void Simulate(const std::vector<ActorPowerPair> ActorList, UCarlaEpisode *CarlaEpisode, UWorld *World);
43 void SetParams(const float TransmitPower,
44 const float ReceiverSensitivity,
45 const float Frequency,
46 const float combined_antenna_gain,
47 const float path_loss_exponent,
48 const float reference_distance_fspl,
49 const float filter_distance,
50 const bool use_etsi_fading,
51 const float custom_fading_stddev);
52 float GetTransmitPower() { return TransmitPower; }
53 void SetPathLossModel(const EPathLossModel path_loss_model);
54
55private:
56 // diffraction for NLOSv
57 double CalcVehicleLoss(const double d1, const double d2, const double h);
58 // powers
59 float CalculateReceivedPower(AActor *OtherActor,
60 const float OtherTransmitPower,
61 const FVector Source,
62 const FVector Destination,
63 const double Distance3d,
64 const double ht,
65 const double ht_local,
66 const double hr,
67 const double hr_local,
68 const double reference_z);
69 void EstimatePathStateAndVehicleObstacles(AActor *OtherActor, FVector Source, double TxHeight, double RxHeight, double reference_z, EPathState &state, std::vector<FVector> &vehicle_obstacles);
70 double MakeVehicleBlockageLoss(double TxHeight, double RxHeight, double obj_height, double obj_distance);
71 // variables
74 UWorld *mWorld;
76
79
80 // constants
81 constexpr static float c_speedoflight = 299792458.0; // m/s
82
83 // full two ray path loss
84 const double epsilon_r = 1.02;
85
86 // params
87 static double Frequency_GHz; // 5.9f;//5.9 GHz
88 static double Frequency; // Frequency_GHz * std::pow(10,9);
89 static double lambda; // c_speedoflight/Frequency;
91 float TransmitPower; // dBm
92 float ReceiverSensitivity; // dBm
94 float path_loss_exponent; // no unit, default 2.7;
95 float filter_distance; // in meters default 500.0
99 float combined_antenna_gain; // 10.0 dBi
100
101 // dependent params that are precalculated on setting of params
103
104protected:
105 /// Method that allow to preprocess if the rays will be traced.
106
107 float ComputeLoss(AActor *OtherActor, FVector Source, FVector Destination, double Distance3d, double TxHeight, double RxHeight, double reference_z);
108 bool IsVehicle(const FHitResult &HitInfo);
109 bool GetLocationIfVehicle(const FVector CurrentActorLocation, const FHitResult &HitInfo, const double reference_z, FVector &location);
110 bool HitIsSelfOrOther(const FHitResult &HitInfo, AActor *OtherActor);
111 float CalculatePathLoss_WINNER(EPathState state, double Distance);
112 double CalculateNLOSvLoss(const FVector Source, const FVector Destination, const double TxHeight, const double RxHeight, const double RxDistance3d, std::vector<FVector> &vehicle_obstacles);
113
115
116 // full two ray model
117 double CalculateTwoRayPathLoss(double Distance3d, double TxHeight, double RxHeight);
118 // simplified two ray model
119 float CalculateTwoRayPathLossSimple(double Distance3d, double TxHeight, double RxHeight);
120
121 // functions for precalculation
122 void CalculateFSPL_d0();
123 TArray<FHitResult> HitResult;
124};
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)
Method that allow to preprocess if the rays will be traced.
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)
A simulation episode.