CARLA
 
载入中...
搜索中...
未找到
CaService.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
10
14#include "carla/geom/Math.h"
16#include <vector>
18#include <chrono>
19
21{
22public:
23// 构造函数,接收一个随机数引擎指针作为参数,可能用于生成噪声或其他随机化操作
24 CaService(URandomEngine *random_engine);
25 void SetOwner(UWorld *world, AActor *Owner);
26
27 void SetParams(const float GenCamMin, const float GenCamMax, const bool FixedRate);
28 void SetVelDeviation(const float noise_vel_stddev_x);
29 void SetYawrateDeviation(const float noise_yawrate_stddev, const float noise_yawrate_bias);
30 void SetAccelerationStandardDeviation(const FVector &Vec);
31// 设置GNSS(全球导航卫星系统)位置和方向的偏差,包括纬度、经度、高度和航向的标准差及偏置
32 void SetGNSSDeviation(const float noise_lat_stddev,
33 const float noise_lon_stddev,
34 const float noise_alt_stddev,
35 const float noise_head_stddev,
36 const float noise_lat_bias,
37 const float noise_lon_bias,
38 const float noise_alt_bias,
39 const float noise_head_bias);
40// 触发一次服务更新,基于给定的时间间隔 DeltaSeconds。返回值可能是表示成功与否的布尔值
41 bool Trigger(float DeltaSeconds);
42// 获取当前生成的CAM(Cooperative Awareness Message,合作意识消息)信息
43 // CAM_t 是一个自定义类型,代表要生成的消息格式
45
46private:
49 UCarlaEpisode *mCarlaEpisode;
50 UWorld *mWorld;
56 float mGenCam;
64
68
72 std::chrono::milliseconds mGenerationDelta0;
73
74 bool CheckTriggeringConditions(float DeltaSeconds);
75 bool CheckHeadingDelta(float DeltaSeconds);
76 bool CheckPositionDelta(float DeltaSeconds);
77 bool CheckSpeedDelta(float DeltaSeconds);
78 double GetFVectorAngle(const FVector &a, const FVector &b);
79 void GenerateCamMessage(float DeltaTime);
81
82 float GetHeading();
83 long GetVehicleRole();
84
85 /* Constant values for message*/
86 const long mProtocolVersion = 2;
90
91 carla::geom::Vector3D ComputeAccelerometer(const float DeltaTime);
92 const carla::geom::Vector3D ComputeAccelerometerNoise(const FVector &Accelerometer);
93 /// Standard deviation for acceleration settings.
94 FVector StdDevAccel;
95
96 /// Used to compute the acceleration
97 std::array<FVector, 2> PrevLocation;
98
99 /// Used to compute the acceleration
101
102 // GNSS reference position and heading
103 FVector GetReferencePosition();
109
114
115 // Velocity
116 float ComputeSpeed();
118
119 // Yaw rate
120 const float ComputeYawNoise(const FVector &Gyroscope);
121 float ComputeYawRate();
124
126 void CreateITSPduHeader(CAM_t &message);
127 void AddCooperativeAwarenessMessage(CAMContainer::CoopAwareness_t &CoopAwarenessMessage, float DeltaTime);
133
134 // random for noise
137};
Base class for CARLA wheeled vehicles.
float LongitudeBias
Definition CaService.h:111
void CreateITSPduHeader(CAM_t &message)
UWorld * mWorld
Definition CaService.h:50
const carla::geom::Vector3D ComputeAccelerometerNoise(const FVector &Accelerometer)
float AltitudeBias
Definition CaService.h:112
FVector GetReferencePosition()
void SetGNSSDeviation(const float noise_lat_stddev, const float noise_lon_stddev, const float noise_alt_stddev, const float noise_head_stddev, const float noise_lat_bias, const float noise_lon_bias, const float noise_alt_bias, const float noise_head_bias)
const long mMessageId
Definition CaService.h:87
UCarlaEpisode * mCarlaEpisode
Definition CaService.h:49
void SetVelDeviation(const float noise_vel_stddev_x)
float HeadingDeviation
Definition CaService.h:108
float LatitudeDeviation
Definition CaService.h:105
bool mDccRestriction
Definition CaService.h:59
float mGenerationInterval
Definition CaService.h:63
const long mProtocolVersion
Definition CaService.h:86
void SetOwner(UWorld *world, AActor *Owner)
Definition CaService.cpp:44
bool Trigger(float DeltaSeconds)
float YawrateDeviation
Definition CaService.h:122
void SetAccelerationStandardDeviation(const FVector &Vec)
float LongitudeDeviation
Definition CaService.h:106
FVector mLastCamPosition
Definition CaService.h:69
float mLastCamTimeStamp
Definition CaService.h:52
float VelocityDeviation
Definition CaService.h:117
float mGenCamMin
Definition CaService.h:54
CAM_t mCAMMessage
Definition CaService.h:132
void SetYawrateDeviation(const float noise_yawrate_stddev, const float noise_yawrate_bias)
unsigned int mGenCamLowDynamicsCounter
Definition CaService.h:61
bool mFixedRate
Definition CaService.h:60
float ComputeYawRate()
bool CheckHeadingDelta(float DeltaSeconds)
float mGenCam
Definition CaService.h:56
carla::geom::Vector3D ComputeAccelerometer(const float DeltaTime)
FVector mLastCamHeading
Definition CaService.h:71
ITSContainer::StationType_t GetStationType()
std::array< FVector, 2 > PrevLocation
Used to compute the acceleration
Definition CaService.h:97
long mStationId
Definition CaService.h:88
double mElapsedTime
Definition CaService.h:57
float LatitudeBias
Definition CaService.h:110
std::chrono::milliseconds mGenerationDelta0
Definition CaService.h:72
float mLastCamSpeed
Definition CaService.h:70
FVector StdDevAccel
Standard deviation for acceleration settings.
Definition CaService.h:94
CaService(URandomEngine *random_engine)
Definition CaService.cpp:33
long mStationType
Definition CaService.h:89
FCarlaActor * mCarlaActor
Definition CaService.h:48
unsigned int mGenCamLowDynamicsLimit
Definition CaService.h:62
float GetHeading()
carla::geom::GeoLocation CurrentGeoReference
Definition CaService.h:104
bool CheckPositionDelta(float DeltaSeconds)
void AddLowFrequencyContainer(CAMContainer::LowFrequencyContainer_t &lfc)
void AddBasicVehicleContainerHighFrequency(CAMContainer::HighFrequencyContainer_t &hfc, float DeltaTime)
float mGenCamMax
Definition CaService.h:55
float YawrateBias
Definition CaService.h:123
CAM_t GetCamMessage()
float mGenDeltaTimeMod
Definition CaService.h:58
URandomEngine * mRandomEngine
Definition CaService.h:135
float HeadingBias
Definition CaService.h:113
float VehicleSpeed
Definition CaService.h:65
ITSContainer::SpeedValue_t BuildSpeedValue(const float vel)
Definition CaService.cpp:15
long GetVehicleRole()
void GenerateCamMessage(float DeltaTime)
bool CheckSpeedDelta(float DeltaSeconds)
ACarlaWheeledVehicle * mVehicle
Definition CaService.h:51
const float ComputeYawNoise(const FVector &Gyroscope)
AActor * mActorOwner
Definition CaService.h:47
float PrevDeltaTime
Used to compute the acceleration
Definition CaService.h:100
float ComputeSpeed()
void SetParams(const float GenCamMin, const float GenCamMax, const bool FixedRate)
Definition CaService.cpp:90
void AddRSUContainerHighFrequency(CAMContainer::HighFrequencyContainer_t &hfc)
double GetFVectorAngle(const FVector &a, const FVector &b)
float AltitudeDeviation
Definition CaService.h:107
CAM_t CreateCooperativeAwarenessMessage(float DeltaTime)
FVector VehicleHeading
Definition CaService.h:67
bool CheckTriggeringConditions(float DeltaSeconds)
float mLastLowCamTimeStamp
Definition CaService.h:53
void AddCooperativeAwarenessMessage(CAMContainer::CoopAwareness_t &CoopAwarenessMessage, float DeltaTime)
FVector VehiclePosition
Definition CaService.h:66
void AddBasicContainer(CAMContainer::BasicContainer_t &BasicContainer)
查看一个参与者和它的属性
Definition CarlaActor.h:23
long StationType_t
Definition LibITS.h:242
long SpeedValue_t
Definition LibITS.h:317
@ messageID_cam
Definition LibITS.h:270
Definition LibITS.h:907