CARLA
Loading...
Searching...
No Matches
CaService.cpp
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#include "CaService.h"
8
9#include "Carla.h"
12#include "Carla/Game/Tagger.h"
14#include "carla/rpc/String.h"
15
16#include "Components/PrimitiveComponent.h"
17
18#include <boost/algorithm/clamp.hpp>
19#include <chrono>
20#include <limits>
21static const float scLowFrequencyContainerInterval = 0.5;
22
24{
25 static const float lower = 0.0; // meter_per_second
26 static const float upper = 163.82; // meter_per_second
27
29 if (vel >= upper)
30 {
31 speed = 16382; // see CDD A.74 (TS 102 894 v1.2.1)
32 }
33 else if (vel >= lower)
34 {
35 // to cm per second
36 speed = std::round(vel * 100.0) * static_cast<double>(ITSContainer::SpeedValue_oneCentimeterPerSec);
37 }
38 return speed;
39}
40
42{
43 mRandomEngine = random_engine;
44 // The starting point now
45 std::chrono::system_clock::time_point start_Point = std::chrono::system_clock::now();
46 // the reference point for ETSI (2004-01-01T00:00:00:000Z)
47 std::chrono::system_clock::time_point ref_point = std::chrono::system_clock::from_time_t(1072915200); // Unix time for 2004-01-01
48
49 mGenerationDelta0 = std::chrono::duration_cast<std::chrono::milliseconds>(start_Point - ref_point);
50}
51
52void CaService::SetActor(UWorld *world, AActor *Owner)
53{
54 mWorld = world;
55 mActorOwner = Owner;
56 mCarlaEpisode = (world != nullptr) ? UCarlaStatics::GetCurrentEpisode(world) : nullptr;
57
58 // The episode is unavailable during world teardown (e.g. when the sensor is
59 // destroyed and UE clears its owner via SetOwner(nullptr)) or before the
60 // simulation is ready. Defer initialization: CarlaActorInitialized() stays
61 // false and PrePhysTick retries on a later tick.
62 if (mCarlaEpisode == nullptr)
63 {
64 mCarlaActor = nullptr;
65 mVehicle = nullptr;
66 return;
67 }
68
70
72
73 mVehicle = nullptr;
74 if (mCarlaActor != nullptr)
75 {
77 {
78 mVehicle = Cast<ACarlaWheeledVehicle>(Owner);
79 UE_LOG(LogCarla, Verbose, TEXT("CaService:Initialize Vehicle type"));
80
83 // Can add logic for this later
84 mDccRestriction = false;
85
86 mElapsedTime = 0;
87 VehicleSpeed = 0;
88 VehiclePosition = {0, 0, 0};
89 VehicleHeading = {0, 0, 0};
90 mLastCamSpeed = 0;
91 mLastCamPosition = {0, 0, 0};
92 mLastCamHeading = {0, 0, 0};
93
94 // Seed the acceleration history so the first ComputeAccelerometer call
95 // does not read uninitialized FVector components or divide by a zero
96 // PrevDeltaTime. Mirrors AInertialMeasurementUnit: a max() previous
97 // delta time drives the first acceleration estimate to ~0.
98 PrevLocation = {FVector::ZeroVector, FVector::ZeroVector};
99 PrevDeltaTime = std::numeric_limits<float>::max();
100 }
104 {
107 UE_LOG(LogCarla, Verbose, TEXT("CaService:Initialize RSU type"));
108 }
109
110 mStationId = static_cast<long>(mCarlaActor->GetActorId());
111 }
113 UE_LOG(LogCarla, Verbose, TEXT("CaService:Initialize station type %i"), mStationType);
114}
115
116void CaService::SetParams(const float GenCamMin, const float GenCamMax, const bool FixedRate)
117{
118 UE_LOG(LogCarla, Verbose, TEXT("CaService:SetParams function called"));
119 // Max and Min for generation rate
120
121 mGenCamMin = GenCamMin; // in second
122 mGenCamMax = GenCamMax; // in second
124 // If we want set a fix interval make this as true
125 mFixedRate = FixedRate;
126}
127
128/*
129 * Function to check trigger condition for RSU
130 */
131bool CaService::Trigger(float DeltaSeconds)
132{
133
135 bool Trigger = false;
137 {
139 {
140 Trigger = true;
143 }
144 }
145 else
146 {
147 Trigger = CheckTriggeringConditions(DeltaSeconds);
148 }
149 return Trigger;
150}
151
152/*
153 * Function to provide CAM message to other objects if necessary
154 */
156{
157 return mCAMMessage;
158}
159
160/*
161 * Check the trigger condition in case of vehicles and if trigger is true request
162 * to generate CAM message
163 */
165{
166 float &T_GenCam = mGenCam;
167 const float T_GenCamMin = mGenCamMin;
168 const float T_GenCamMax = mGenCamMax;
169 const float T_GenCamDcc = mDccRestriction ? 0 : T_GenCamMin;
170 const float T_elapsed = mElapsedTime - mLastCamTimeStamp;
171 if (T_elapsed >= T_GenCamDcc)
172 {
173 // If message need to be generated every sim tick then set this to true.
174 if (mFixedRate)
175 {
176 GenerateCamMessage(DeltaSeconds);
177 return true;
178 }
179
180 else if (CheckHeadingDelta(DeltaSeconds) || CheckPositionDelta(DeltaSeconds) || CheckSpeedDelta(DeltaSeconds))
181 {
182 GenerateCamMessage(DeltaSeconds);
183 T_GenCam = std::min(T_elapsed, T_GenCamMax);
185 return true;
186 }
187 else if (T_elapsed >= T_GenCam)
188 {
189 GenerateCamMessage(DeltaSeconds);
191 {
192 T_GenCam = T_GenCamMax;
193 }
194 return true;
195 }
196 }
197 return false;
198}
199
200bool CaService::CheckPositionDelta(float DeltaSeconds)
201{
202 if ( mVehicle != nullptr ) {
203 // If position change is more the 4m
204 VehiclePosition = mVehicle->GetActorLocation();
205 double Distance = FVector::Distance(VehiclePosition, mLastCamPosition) / 100.0f; // From cm to m
206 if (Distance > 4.0f)
207 {
208 return true;
209 }
210 }
211 return false;
212}
213
214bool CaService::CheckSpeedDelta(float DeltaSeconds)
215{
216 if ( mVehicle != nullptr ) {
217 VehicleSpeed = mVehicle->GetVehicleForwardSpeed() / 100.0f; // From cm/s to m/s
218 float DeltaSpeed = std::abs(VehicleSpeed - mLastCamSpeed);
219
220 // Speed difference is greater than 0.5m/s
221 if (DeltaSpeed > 0.5)
222 {
223 return true;
224 }
225 }
226 return false;
227}
228
229double CaService::GetFVectorAngle(const FVector &a, const FVector &b)const
230{
231 double Dot = a.X * b.X + a.Y * b.Y + a.Z * b.Z;
232 return std::acos(Dot / (a.Size() * b.Size()));
233}
234
235void CaService::GenerateCamMessage(float DeltaTime)
236{
237 UE_LOG(LogCarla, VeryVerbose, TEXT("V2XSensor: generating cam message"));
238
244}
245
246// Function to get the station type
248{
250 // return unknown if carla actor is gone
251 if (mCarlaActor == nullptr)
252 {
253 return static_cast<long>(stationType);
254 }
255
256 if ( mVehicle!= nullptr ) {
257 auto Tag = ATagger::GetTagOfTaggedComponent(*mVehicle->GetMesh());
258
259 switch (Tag)
260 {
263 break;
266 break;
269 break;
272 break;
275 break;
277 stationType = ITSContainer::StationType_bus;
278 break;
279 // TODO Modify this in future is CARLA adds difference truck
282 break;
290 break;
292 stationType = ITSContainer::StationType_tram;
293 break;
294 default:
296 }
297
298 // Can improve this later for different special vehicles once carla implements it
301 {
302 if (mCarlaActor->GetActorInfo()->Description.Variations.Contains("special_type"))
303 {
304 std::string special_type = carla::rpc::FromFString(*mCarlaActor->GetActorInfo()->Description.Variations["special_type"].Value);
305 if (special_type.compare("emergency") == 0)
306 {
308 }
309 }
310 }
311 }
312 else {
313 // not a vehicle => RSU
315 }
316
317 return static_cast<long>(stationType);
318}
319
321{
322 FVector RefPos;
323 carla::geom::Location ActorLocation = mActorOwner->GetActorLocation();
325 if (LargeMap)
326 {
327 ActorLocation = LargeMap->LocalToGlobalLocation(ActorLocation);
328 }
329 carla::geom::Location Location = ActorLocation;
331
332 // Compute the noise for the sensor
333 const float LatError = mRandomEngine->GetNormalDistribution(0.0f, LatitudeDeviation);
334 const float LonError = mRandomEngine->GetNormalDistribution(0.0f, LongitudeDeviation);
335 const float AltError = mRandomEngine->GetNormalDistribution(0.0f, AltitudeDeviation);
336
337 // Apply the noise to the sensor
338 double Latitude = CurrentLocation.latitude + LatitudeBias + LatError;
339 double Longitude = CurrentLocation.longitude + LongitudeBias + LonError;
340 double Altitude = CurrentLocation.altitude + AltitudeBias + AltError;
341
342 RefPos.X = Latitude;
343 RefPos.Y = Longitude;
344 RefPos.Z = Altitude;
345 return RefPos;
346}
347
349{
350 // Magnetometer: orientation with respect to the North in rad
351 const FVector CarlaNorthVector = FVector(0.0f, -1.0f, 0.0f);
352 const FVector ForwVect = mActorOwner->GetActorForwardVector().GetSafeNormal2D();
353 const float DotProd = FVector::DotProduct(CarlaNorthVector, ForwVect);
354
355 // We check if the dot product is higher than 1.0 due to numerical error
356 if (DotProd >= 1.00f)
357 return 0.0f;
358
359 float Heading = std::acos(DotProd);
360 // Keep the angle between [0, 2pi)
361 if (FVector::CrossProduct(CarlaNorthVector, ForwVect).Z < 0.0f)
362 Heading = carla::geom::Math::Pi2<float>() - Heading;
363
364 const double HeadingDegree = carla::geom::Math::ToDegrees(Heading);
365
366 // Compute the noise for the sensor
367 const float HeadingError = mRandomEngine->GetNormalDistribution(0.0f, HeadingDeviation);
368
369 // add errors
370 return HeadingDegree + HeadingBias + HeadingError;
371}
372
373// Function to get the vehicle role
375{
376 long VehicleRole = ITSContainer::VehicleRole_default;
377 switch (mStationType)
378 {
383 break;
387 break;
390 break;
391 default:
393 break;
394 }
395 return VehicleRole;
396}
397
399{
400 CAM_t message = CAM_t();
401
402 CreateITSPduHeader(message);
403 AddCooperativeAwarenessMessage(message.cam, DeltaTime);
404
405 return message;
406}
407
409{
410 ITSContainer::ItsPduHeader_t &header = message.header;
412 header.messageID = mMessageId;
413 header.stationID = mStationId;
414}
415
417{
418
419 /* GenerationDeltaTime */
420 auto genDeltaTime = mGenerationDelta0 + std::chrono::milliseconds(static_cast<long long>(mCarlaEpisode->GetElapsedGameTime() * 1000));
421 CoopAwarenessMessage.generationDeltaTime = genDeltaTime.count() % 65536 * CAMContainer::GenerationDeltaTime_oneMilliSec; // TODOCheck this logic
422 AddBasicContainer(CoopAwarenessMessage.camParameters.basicContainer);
424 {
425 // TODO Future Implementation
427 }
429 {
430 // TODO no container available for Pedestrains
431 }
433 {
434 // BasicVehicleContainer
436
438 {
441 }
442 else
443 {
444 // Store nothing if not used
446 }
447 /*
448 *TODO Add Special container if it a special vehicle
449 */
450 }
451}
452
467
469{
470 StdDevAccel = Vec;
471}
472
473void CaService::SetGNSSDeviation(const float noise_lat_stddev,
474 const float noise_lon_stddev,
475 const float noise_alt_stddev,
476 const float noise_head_stddev,
477 const float noise_lat_bias,
478 const float noise_lon_bias,
479 const float noise_alt_bias,
480 const float noise_head_bias)
481{
482 LatitudeDeviation = noise_lat_stddev;
483 LongitudeDeviation = noise_lon_stddev;
484 AltitudeDeviation = noise_alt_stddev;
485 HeadingDeviation = noise_head_stddev;
486 LatitudeBias = noise_lat_bias;
487 LongitudeBias = noise_lon_bias;
488 AltitudeBias = noise_alt_bias;
489 HeadingBias = noise_head_bias;
490}
491
492void CaService::SetVelDeviation(const float noise_vel_stddev_x)
493{
494 VelocityDeviation = noise_vel_stddev_x;
495}
496
497void CaService::SetYawrateDeviation(const float noise_yawrate_stddev, const float noise_yawrate_bias)
498{
499 YawrateDeviation = noise_yawrate_stddev;
500 YawrateBias = noise_yawrate_bias;
501}
502
504{
505 if ( mVehicle == nullptr ) {
506 return;
507 }
508
511 // heading
512 bvc.heading.headingValue = std::round(GetHeading() * 10.0);
514 // speed
515 // speed with noise
518 // direction
520 // length and width
522 float length = bb.Extent.X * 2.0; // half box
523 float width = bb.Extent.Y * 2.0; // half box
524
525 // cm -> 0.1 m units, clamped to the ETSI range (outOfRange marks anything larger)
526 bvc.vehicleLength.vehicleLengthValue = FMath::Clamp<long>(std::lround(length / 10.0),
529 bvc.vehicleWidth = FMath::Clamp<long>(std::lround(width / 10.0),
531
532 // acceleration
534
535 const double lonAccelValue = Accel.x * 10.0; // m/s to 0.1 m/s
536 // limit changes
537 if (lonAccelValue >= -160.0 && lonAccelValue <= 161.0)
538 {
540 }
541 else
542 {
544 }
546
547 // curvature TODO
551
552 // yaw rate is in rad/s --> to centidegree per second
554 if (bvc.yawRate.yawRateValue < -32766 || bvc.yawRate.yawRateValue > 32766)
555 {
557 }
559
560 // optional lat and vertical accelerations
562 const double latAccelValue = Accel.y * 10.0; // m/s to 0.1 m/s
563 if (latAccelValue >= -160.0 && latAccelValue <= 161.0)
564 {
566 }
567 else
568 {
570 }
572
574 const double vertAccelValue = Accel.z * 10.0; // m/s to 0.1 m/s
575 if (vertAccelValue >= -160.0 && vertAccelValue <= 161.0)
576 {
578 }
579 else
580 {
582 }
584
585 // TODO
587 bvc.lanePositionAvailable = false;
588 bvc.steeringWheelAngleAvailable = false;
589 bvc.performanceClassAvailable = false;
590 bvc.cenDsrcTollingZoneAvailable = false;
591}
592
594 const FVector &Accelerometer)const
595{
596 // Normal (or Gaussian or Gauss) distribution will be used as noise function.
597 // A mean of 0.0 is used as a first parameter, the standard deviation is
598 // determined by the client
599 constexpr float Mean = 0.0f;
601 static_cast<float>(Accelerometer.X + mRandomEngine->GetNormalDistribution(Mean, StdDevAccel.X)),
602 static_cast<float>(Accelerometer.Y + mRandomEngine->GetNormalDistribution(Mean, StdDevAccel.Y)),
603 static_cast<float>(Accelerometer.Z + mRandomEngine->GetNormalDistribution(Mean, StdDevAccel.Z))};
604}
605
607 const float DeltaTime)
608{
609 carla::geom::Vector3D Accelerometer(0.,0.,0.);
610
611 if ( mVehicle != nullptr ) {
612 // Used to convert from UE4's cm to meters
613 constexpr float TO_METERS = 1e-2;
614 // Earth's gravitational acceleration is approximately 9.81 m/s^2
615 constexpr float GRAVITY = 9.81f;
616
617 // 2nd derivative of the polynomic (quadratic) interpolation
618 // using the point in current time and two previous steps:
619 // d2[i] = -2.0*(y1/(h1*h2)-y2/((h2+h1)*h2)-y0/(h1*(h2+h1)))
620 const FVector CurrentLocation = mVehicle->GetActorLocation();
621
622 const FVector Y2 = PrevLocation[0];
623 const FVector Y1 = PrevLocation[1];
624 const FVector Y0 = CurrentLocation;
625 const float H1 = DeltaTime;
626 const float H2 = PrevDeltaTime;
627
628 const float H1AndH2 = H2 + H1;
629 const FVector A = Y1 / (H1 * H2);
630 const FVector B = Y2 / (H2 * (H1AndH2));
631 const FVector C = Y0 / (H1 * (H1AndH2));
632 FVector FVectorAccelerometer = TO_METERS * -2.0f * (A - B - C);
633
634 // Update the previous locations
636 PrevLocation[1] = CurrentLocation;
637 PrevDeltaTime = DeltaTime;
638
639 // Add gravitational acceleration
640 FVectorAccelerometer.Z += GRAVITY;
641
642 FQuat ImuRotation = mActorOwner->GetRootComponent()->GetComponentTransform().GetRotation();
643 FVectorAccelerometer = ImuRotation.UnrotateVector(FVectorAccelerometer);
644
645 // Cast from FVector to our Vector3D to correctly send the data in m/s^2
646 // and apply the desired noise function, in this case a normal distribution
647 Accelerometer = ComputeAccelerometerNoise(FVectorAccelerometer);
648 }
649 return Accelerometer;
650}
651
653{
654 float speed = 0.;
655 if ( mVehicle != nullptr ) {
656 speed = mVehicle->GetVehicleForwardSpeed() / 100.0f;
657
658 // Normal (or Gaussian or Gauss) distribution and a bias will be used as
659 // noise function.
660 // A mean of 0.0 is used as a first parameter.The standard deviation and the
661 // bias are determined by the client
662 constexpr float Mean = 0.0f;
663 speed = boost::algorithm::clamp(speed + mRandomEngine->GetNormalDistribution(Mean, VelocityDeviation), 0.0f, std::numeric_limits<float>::max());
664 }
665 return speed;
666}
667
669{
670 check(mActorOwner != nullptr);
671 // Angular velocity of the owner in its local frame, in rad/s. Mirrors the
672 // computation in AInertialMeasurementUnit (whose helper is not exposed).
673 FVector AngularVelocity = FVector::ZeroVector;
674 if (const auto *RootComponent = Cast<UPrimitiveComponent>(mActorOwner->GetRootComponent()))
675 {
676 const FQuat ActorGlobalRotation = RootComponent->GetComponentTransform().GetRotation();
677 const FVector GlobalAngularVelocity = CarlaGetActorAngularVelocityInRadians(*mActorOwner);
678 AngularVelocity = ActorGlobalRotation.UnrotateVector(GlobalAngularVelocity);
679 }
680
681 const FQuat SensorLocalRotation =
682 mActorOwner->GetRootComponent()->GetRelativeTransform().GetRotation();
683
684 const FVector FVectorGyroscope =
685 SensorLocalRotation.RotateVector(AngularVelocity);
686
687 // Cast from FVector to our Vector3D to correctly send the data in rad/s
688 // and apply the desired noise function, in this case a normal distribution
689 float yawrate =
690 ComputeYawNoise(FVectorGyroscope);
691
692 return yawrate; // rad/s
693}
694
696 const FVector &Gyroscope)const
697{
698 // Normal (or Gaussian or Gauss) distribution and a bias will be used as
699 // noise function.
700 // A mean of 0.0 is used as a first parameter.The standard deviation and the
701 // bias are determined by the client
702 constexpr float Mean = 0.0f;
704}
705
707{
708 // Define the epoch time (2004-01-01T00:00:00.000Z)
709 std::tm epoch_time = {};
710 epoch_time = {0, 0, 0, 1, 0, 104}; // January 1, 2004
711
712 // Convert epoch time to a std::chrono::time_point
713 std::chrono::system_clock::time_point epoch = std::chrono::system_clock::from_time_t(std::mktime(&epoch_time));
714
715 // Get the current time
716 std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
717
718 // Calculate the duration since the epoch in milliseconds
719 std::chrono::milliseconds duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - epoch);
720
721 // Return the number of milliseconds as a long
722 return duration.count();
723}
724
726{
729 // TODO For future implementation ITSContainer::ProtectedCommunicationZonesRSU_t PCZR
730
731 uint8_t const ProtectedZoneDataLength = rsu.protectedCommunicationZonesRSU.data.size(); // Maximum number of elements in path history
733 for (uint8_t i = 0; i < ProtectedZoneDataLength; ++i)
734 {
737 PCZ.expiryTimeAvailable = false;
738 PCZ.protectedZoneLatitude = 50;
739 PCZ.protectedZoneLongitude = 50;
741 PCZ.protectedZoneIDAvailable = false;
744 }
745}
746
748{
749 if (mVehicle == nullptr) {
750 return;
751 }
752
755
756 /*Vehicle Role*/
758
759 /*Exterior Lights*/
760 uint8_t *buf = &bvc.exteriorLights;
762 if (LightStateData.LowBeam)
763 {
765 }
766 if (LightStateData.HighBeam)
767 {
769 }
770 if (LightStateData.LeftBlinker)
771 {
773 }
774 if (LightStateData.RightBlinker)
775 {
777 }
778 if (LightStateData.Reverse)
779 {
781 }
782 if (LightStateData.Fog)
783 {
784 buf[0] |= 1 << (7 - ITSContainer::ExteriorLights_fogLightOn);
785 }
786 if (LightStateData.Position)
787 {
789 }
791}
792
793bool CaService::CheckHeadingDelta(float DeltaSeconds)
794{
795 if ( mVehicle != nullptr ) {
796 // if heading diff is more than 4degree
799 if (HeadingDelta > 4.0)
800 {
801 return true;
802 }
803 }
804 return false;
805}
static const float scLowFrequencyContainerInterval
Definition CaService.cpp:21
long millisecondsSince2004()
FVector CarlaGetActorAngularVelocityInRadians(const AActor &Actor)
Angular velocity of Actor in the world frame, in rad/s: on a Multi-GPU secondary the primary's (a mir...
struct CAM CAM_t
FVehicleLightState GetVehicleLightState() const
FVector GetVehicleOrientation() const
Orientation vector of the vehicle, pointing forward.
float GetVehicleForwardSpeed() const
Forward speed in cm/s. Might be negative if goes backwards.
FVector LocalToGlobalLocation(const FVector &InLocation) const
static crp::CityObjectLabel GetTagOfTaggedComponent(const UPrimitiveComponent &Component)
Retrieve the tag of an already tagged component.
Definition Tagger.cpp:213
struct CAMContainer::RSUContainerHighFrequency RSUContainerHighFrequency_t
@ GenerationDeltaTime_oneMilliSec
Definition LibITS.h:657
struct CAMContainer::BasicVehicleContainerLowFrequency BasicVehicleContainerLowFrequency_t
@ HighFrequencyContainer_PR_basicVehicleContainerHighFrequency
Definition LibITS.h:674
@ HighFrequencyContainer_PR_rsuContainerHighFrequency
Definition LibITS.h:675
@ LowFrequencyContainer_PR_basicVehicleContainerLowFrequency
Definition LibITS.h:736
@ LowFrequencyContainer_PR_NOTHING
Definition LibITS.h:735
struct CAMContainer::CoopAwareness CoopAwareness_t
struct CAMContainer::LowFrequencyContainer LowFrequencyContainer_t
struct CAMContainer::BasicVehicleContainerHighFrequency BasicVehicleContainerHighFrequency_t
struct CAMContainer::HighFrequencyContainer HighFrequencyContainer_t
struct CAMContainer::BasicContainer BasicContainer_t
float LongitudeBias
Definition CaService.h:107
void CreateITSPduHeader(CAM_t &message)
UWorld * mWorld
Definition CaService.h:46
float GetHeading() const
carla::geom::GeoProjection CurrentGeoProjection
Definition CaService.h:100
float AltitudeBias
Definition CaService.h:108
float ComputeSpeed() const
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:83
UCarlaEpisode * mCarlaEpisode
Definition CaService.h:45
void SetVelDeviation(const float noise_vel_stddev_x)
float HeadingDeviation
Definition CaService.h:104
float LatitudeDeviation
Definition CaService.h:101
bool mDccRestriction
Definition CaService.h:55
long GetVehicleRole() const
float mGenerationInterval
Definition CaService.h:59
ITSContainer::SpeedValue_t BuildSpeedValue(const float vel) const
Definition CaService.cpp:23
const long mProtocolVersion
Definition CaService.h:82
bool Trigger(float DeltaSeconds)
float YawrateDeviation
Definition CaService.h:118
void SetAccelerationStandardDeviation(const FVector &Vec)
float LongitudeDeviation
Definition CaService.h:102
const carla::geom::Vector3D ComputeAccelerometerNoise(const FVector &Accelerometer) const
FVector mLastCamPosition
Definition CaService.h:65
float ComputeYawRate() const
float mLastCamTimeStamp
Definition CaService.h:48
float VelocityDeviation
Definition CaService.h:113
float mGenCamMin
Definition CaService.h:50
CAM_t mCAMMessage
Definition CaService.h:128
void SetYawrateDeviation(const float noise_yawrate_stddev, const float noise_yawrate_bias)
unsigned int mGenCamLowDynamicsCounter
Definition CaService.h:57
bool mFixedRate
Definition CaService.h:56
bool CheckHeadingDelta(float DeltaSeconds)
float mGenCam
Definition CaService.h:52
void SetActor(UWorld *world, AActor *Owner)
Definition CaService.cpp:52
carla::geom::Vector3D ComputeAccelerometer(const float DeltaTime)
FVector mLastCamHeading
Definition CaService.h:67
std::array< FVector, 2 > PrevLocation
Used to compute the acceleration.
Definition CaService.h:93
CAM_t GetCamMessage() const
long mStationId
Definition CaService.h:84
double mElapsedTime
Definition CaService.h:53
float LatitudeBias
Definition CaService.h:106
std::chrono::milliseconds mGenerationDelta0
Definition CaService.h:68
float mLastCamSpeed
Definition CaService.h:66
FVector StdDevAccel
Standard deviation for acceleration settings.
Definition CaService.h:90
CaService(URandomEngine *random_engine)
Definition CaService.cpp:41
long mStationType
Definition CaService.h:85
FCarlaActor * mCarlaActor
Definition CaService.h:44
unsigned int mGenCamLowDynamicsLimit
Definition CaService.h:58
const float ComputeYawNoise(const FVector &Gyroscope) const
bool CheckPositionDelta(float DeltaSeconds)
void AddLowFrequencyContainer(CAMContainer::LowFrequencyContainer_t &lfc)
double GetFVectorAngle(const FVector &a, const FVector &b) const
ITSContainer::StationType_t GetStationType() const
void AddBasicVehicleContainerHighFrequency(CAMContainer::HighFrequencyContainer_t &hfc, float DeltaTime)
float mGenCamMax
Definition CaService.h:51
float YawrateBias
Definition CaService.h:119
URandomEngine * mRandomEngine
Definition CaService.h:131
FVector GetReferencePosition() const
float HeadingBias
Definition CaService.h:109
float VehicleSpeed
Definition CaService.h:61
void GenerateCamMessage(float DeltaTime)
bool CheckSpeedDelta(float DeltaSeconds)
ACarlaWheeledVehicle * mVehicle
Definition CaService.h:47
AActor * mActorOwner
Definition CaService.h:43
float PrevDeltaTime
Used to compute the acceleration.
Definition CaService.h:96
void SetParams(const float GenCamMin, const float GenCamMax, const bool FixedRate)
void AddRSUContainerHighFrequency(CAMContainer::HighFrequencyContainer_t &hfc)
float AltitudeDeviation
Definition CaService.h:103
CAM_t CreateCooperativeAwarenessMessage(float DeltaTime)
FVector VehicleHeading
Definition CaService.h:63
bool CheckTriggeringConditions(float DeltaSeconds)
float mLastLowCamTimeStamp
Definition CaService.h:49
void AddCooperativeAwarenessMessage(CAMContainer::CoopAwareness_t &CoopAwarenessMessage, float DeltaTime)
FVector VehiclePosition
Definition CaService.h:62
void AddBasicContainer(CAMContainer::BasicContainer_t &BasicContainer)
ActorType GetActorType() const
Definition CarlaActor.h:86
const FActorInfo * GetActorInfo() const
Definition CarlaActor.h:101
IdType GetActorId() const
Definition CarlaActor.h:81
@ YawRateConfidence_unavailable
Definition LibITS.h:380
@ ProtectedZoneType_cenDsrcTolling
Definition LibITS.h:506
@ LateralAccelerationValue_unavailable
Definition LibITS.h:450
@ LateralAccelerationValue_pointOneMeterPerSecSquaredToLeft
Definition LibITS.h:449
@ AltitudeConfidence_unavailable
Definition LibITS.h:121
@ LongitudinalAccelerationValue_pointOneMeterPerSecSquaredForward
Definition LibITS.h:286
@ LongitudinalAccelerationValue_unavailable
Definition LibITS.h:288
struct ITSContainer::ProtectedCommunicationZone ProtectedCommunicationZone_t
@ AltitudeValue_oneCentimeter
Definition LibITS.h:96
@ YawRateValue_unavailable
Definition LibITS.h:364
@ YawRateValue_degSec_000_01ToLeft
Definition LibITS.h:363
@ DriveDirection_forward
Definition LibITS.h:233
@ DriveDirection_backward
Definition LibITS.h:234
long StationType_t
Definition LibITS.h:162
@ VehicleLengthValue_tenCentimeters
Definition LibITS.h:244
@ VehicleLengthValue_outOfRange
Definition LibITS.h:245
@ SemiAxisLength_unavailable
Definition LibITS.h:54
@ Longitude_oneMicroDegreeEast
Definition LibITS.h:41
@ VehicleWidth_tenCentimeters
Definition LibITS.h:275
@ VehicleWidth_outOfRange
Definition LibITS.h:276
@ Latitude_oneMicroDegreeNorth
Definition LibITS.h:30
long SpeedValue_t
Definition LibITS.h:209
@ StationType_passengerCar
Definition LibITS.h:151
@ StationType_moped
Definition LibITS.h:149
@ StationType_lightTruck
Definition LibITS.h:153
@ StationType_specialVehicles
Definition LibITS.h:156
@ StationType_tram
Definition LibITS.h:157
@ StationType_motorcycle
Definition LibITS.h:150
@ StationType_unknown
Definition LibITS.h:146
@ StationType_cyclist
Definition LibITS.h:148
@ StationType_roadSideUnit
Definition LibITS.h:158
@ StationType_bus
Definition LibITS.h:152
@ StationType_pedestrian
Definition LibITS.h:147
@ ExteriorLights_reverseLightOn
Definition LibITS.h:581
@ ExteriorLights_highBeamHeadlightsOn
Definition LibITS.h:577
@ ExteriorLights_lowBeamHeadlightsOn
Definition LibITS.h:576
@ ExteriorLights_leftTurnSignalOn
Definition LibITS.h:578
@ ExteriorLights_rightTurnSignalOn
Definition LibITS.h:579
@ ExteriorLights_parkingLightsOn
Definition LibITS.h:583
@ ExteriorLights_fogLightOn
Definition LibITS.h:582
@ CurvatureCalculationMode_yarRateUsed
Definition LibITS.h:350
@ VehicleRole_publicTransport
Definition LibITS.h:554
@ VehicleRole_default
Definition LibITS.h:553
@ VehicleRole_emergency
Definition LibITS.h:559
@ CurvatureValue_unavailable
Definition LibITS.h:318
@ VerticalAccelerationValue_unavailable
Definition LibITS.h:467
@ VerticalAccelerationValue_pointOneMeterPerSecSquaredUp
Definition LibITS.h:465
@ AccelerationConfidence_unavailable
Definition LibITS.h:299
@ VehicleLengthConfidenceIndication_unavailable
Definition LibITS.h:259
@ HeadingValue_unavailable
Definition LibITS.h:67
@ HeadingConfidence_equalOrWithinOneDegree
Definition LibITS.h:76
struct ITSContainer::ItsPduHeader ItsPduHeader_t
@ SpeedValue_unavailable
Definition LibITS.h:205
@ SpeedValue_oneCentimeterPerSec
Definition LibITS.h:204
@ SpeedConfidence_equalOrWithInOneCentimerterPerSec
Definition LibITS.h:214
@ CurvatureConfidence_unavailable
Definition LibITS.h:334
static FBoundingBox GetActorBoundingBox(const AActor *Actor, uint8 InTagQueried=0xFF)
Compute the bounding box of the given Carla actor.
FCarlaActor * FindCarlaActor(FCarlaActor::IdType ActorId)
Find a Carla actor by id.
double GetElapsedGameTime() const
Game seconds since the start of this episode.
const carla::geom::GeoProjection & GetGeoProjection() const
Return the geo projection of the map loaded.
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
static UCarlaEpisode * GetCurrentEpisode(const UObject *WorldContextObject)
float GetNormalDistribution(float Mean, float StandardDeviation)
static constexpr T Pi2()
Definition Math.h:31
static constexpr T ToDegrees(T rad)
Definition Math.h:37
ITSContainer::ReferencePosition_t referencePosition
Definition LibITS.h:667
ITSContainer::StationType_t stationType
Definition LibITS.h:666
ITSContainer::VehicleLength_t vehicleLength
Definition LibITS.h:686
ITSContainer::LateralAcceleration_t lateralAcceleration
Definition LibITS.h:703
ITSContainer::VehicleWidth_t vehicleWidth
Definition LibITS.h:687
OptionalStructAvailable_t lateralAccelerationAvailable
Definition LibITS.h:702
ITSContainer::CurvatureCalculationMode_t curvatureCalculationMode
Definition LibITS.h:690
OptionalStructAvailable_t verticalAccelerationAvailable
Definition LibITS.h:705
OptionalStructAvailable_t performanceClassAvailable
Definition LibITS.h:708
OptionalStructAvailable_t lanePositionAvailable
Definition LibITS.h:696
ITSContainer::DriveDirection_t driveDirection
Definition LibITS.h:685
OptionalStructAvailable_t accelerationControlAvailable
Definition LibITS.h:693
OptionalStructAvailable_t steeringWheelAngleAvailable
Definition LibITS.h:699
ITSContainer::VerticalAcceleration_t verticalAcceleration
Definition LibITS.h:706
OptionalStructAvailable_t cenDsrcTollingZoneAvailable
Definition LibITS.h:711
ITSContainer::LongitudinalAcceleration_t longitudinalAcceleration
Definition LibITS.h:688
ITSContainer::ExteriorLights_t exteriorLights
Definition LibITS.h:744
ITSContainer::PathHistory_t pathHistory
Definition LibITS.h:745
ITSContainer::VehicleRole_t vehicleRole
Definition LibITS.h:743
HighFrequencyContainer_t highFrequencyContainer
Definition LibITS.h:761
BasicContainer_t basicContainer
Definition LibITS.h:760
LowFrequencyContainer_t lowFrequencyContainer
Definition LibITS.h:762
GenerationDeltaTime_t generationDeltaTime
Definition LibITS.h:769
CamParameters_t camParameters
Definition LibITS.h:770
RSUContainerHighFrequency_t rsuContainerHighFrequency
Definition LibITS.h:728
BasicVehicleContainerHighFrequency_t basicVehicleContainerHighFrequency
Definition LibITS.h:727
HighFrequencyContainer_PR present
Definition LibITS.h:725
BasicVehicleContainerLowFrequency_t basicVehicleContainerLowFrequency
Definition LibITS.h:753
LowFrequencyContainer_PR present
Definition LibITS.h:751
ITSContainer::ProtectedCommunicationZonesRSU_t protectedCommunicationZonesRSU
Definition LibITS.h:719
CAMContainer::CoopAwareness_t cam
Definition LibITS.h:778
ITSContainer::ItsPduHeader_t header
Definition LibITS.h:777
TMap< FString, FActorAttribute > Variations
User selected variations of the actor.
FActorDescription Description
Definition ActorInfo.h:21
AltitudeValue_t altitudeValue
Definition LibITS.h:130
AltitudeConfidence_t altitudeConfidence
Definition LibITS.h:131
CurvatureValue_t curvatureValue
Definition LibITS.h:343
CurvatureConfidence_t curvatureConfidence
Definition LibITS.h:344
HeadingValue_t headingValue
Definition LibITS.h:196
HeadingConfidence_t headingConfidence
Definition LibITS.h:197
LateralAccelerationValue_t lateralAccelerationValue
Definition LibITS.h:459
AccelerationConfidence_t lateralAccelerationConfidence
Definition LibITS.h:460
LongitudinalAccelerationValue_t longitudinalAccelerationValue
Definition LibITS.h:308
AccelerationConfidence_t longitudinalAccelerationConfidence
Definition LibITS.h:309
SemiAxisLength_t semiMinorConfidence
Definition LibITS.h:88
HeadingValue_t semiMajorOrientation
Definition LibITS.h:89
SemiAxisLength_t semiMajorConfidence
Definition LibITS.h:87
OptionalValueAvailable_t protectedZoneRadiusAvailable
Definition LibITS.h:540
OptionalValueAvailable_t protectedZoneIDAvailable
Definition LibITS.h:542
ProtectedZoneType_t protectedZoneType
Definition LibITS.h:534
OptionalValueAvailable_t expiryTimeAvailable
Definition LibITS.h:536
std::array< ProtectedCommunicationZone_t, 16u > data
Definition LibITS.h:548
PosConfidenceEllipse_t positionConfidenceEllipse
Definition LibITS.h:139
VehicleLengthConfidenceIndication_t vehicleLengthConfidenceIndication
Definition LibITS.h:269
VehicleLengthValue_t vehicleLengthValue
Definition LibITS.h:268
VerticalAccelerationValue_t verticalAccelerationValue
Definition LibITS.h:476
AccelerationConfidence_t verticalAccelerationConfidence
Definition LibITS.h:477
YawRateConfidence_t yawRateConfidence
Definition LibITS.h:390
YawRateValue_t yawRateValue
Definition LibITS.h:389
SpeedConfidence_t speedConfidence
Definition LibITS.h:227
SpeedValue_t speedValue
Definition LibITS.h:226
GeoLocation TransformToGeoLocation(const Location &location) const
Transform the given geo location to a location.