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 {
261 case crp::CityObjectLabel::None:
263 break;
264 case crp::CityObjectLabel::Pedestrians:
266 break;
267 case crp::CityObjectLabel::Bicycle:
269 break;
270 case crp::CityObjectLabel::Motorcycle:
272 break;
273 case crp::CityObjectLabel::Car:
275 break;
276 case crp::CityObjectLabel::Bus:
277 stationType = ITSContainer::StationType_bus;
278 break;
279 // TODO Modify this in future is CARLA adds difference truck
280 case crp::CityObjectLabel::Truck:
282 break;
283 case crp::CityObjectLabel::Buildings:
284 case crp::CityObjectLabel::Walls:
285 case crp::CityObjectLabel::Fences:
286 case crp::CityObjectLabel::Poles:
287 case crp::CityObjectLabel::TrafficLight:
288 case crp::CityObjectLabel::TrafficSigns:
290 break;
291 case crp::CityObjectLabel::Train:
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 bvc.vehicleLength.vehicleLengthValue = std::round(length * 10.0); // 0.1 meter
527 bvc.vehicleWidth = std::round(width * 10.0); // 0.1 meter
528
529 // acceleration
531
532 const double lonAccelValue = Accel.x * 10.0; // m/s to 0.1 m/s
533 // limit changes
534 if (lonAccelValue >= -160.0 && lonAccelValue <= 161.0)
535 {
537 }
538 else
539 {
541 }
543
544 // curvature TODO
548
549 // yaw rate is in rad/s --> to centidegree per second
551 if (bvc.yawRate.yawRateValue < -32766 || bvc.yawRate.yawRateValue > 32766)
552 {
554 }
556
557 // optional lat and vertical accelerations
559 const double latAccelValue = Accel.y * 10.0; // m/s to 0.1 m/s
560 if (latAccelValue >= -160.0 && latAccelValue <= 161.0)
561 {
563 }
564 else
565 {
567 }
569
571 const double vertAccelValue = Accel.z * 10.0; // m/s to 0.1 m/s
572 if (vertAccelValue >= -160.0 && vertAccelValue <= 161.0)
573 {
575 }
576 else
577 {
579 }
581
582 // TODO
584 bvc.lanePositionAvailable = false;
585 bvc.steeringWheelAngleAvailable = false;
586 bvc.performanceClassAvailable = false;
587 bvc.cenDsrcTollingZoneAvailable = false;
588}
589
591 const FVector &Accelerometer)const
592{
593 // Normal (or Gaussian or Gauss) distribution will be used as noise function.
594 // A mean of 0.0 is used as a first parameter, the standard deviation is
595 // determined by the client
596 constexpr float Mean = 0.0f;
598 static_cast<float>(Accelerometer.X + mRandomEngine->GetNormalDistribution(Mean, StdDevAccel.X)),
599 static_cast<float>(Accelerometer.Y + mRandomEngine->GetNormalDistribution(Mean, StdDevAccel.Y)),
600 static_cast<float>(Accelerometer.Z + mRandomEngine->GetNormalDistribution(Mean, StdDevAccel.Z))};
601}
602
604 const float DeltaTime)
605{
606 carla::geom::Vector3D Accelerometer(0.,0.,0.);
607
608 if ( mVehicle != nullptr ) {
609 // Used to convert from UE4's cm to meters
610 constexpr float TO_METERS = 1e-2;
611 // Earth's gravitational acceleration is approximately 9.81 m/s^2
612 constexpr float GRAVITY = 9.81f;
613
614 // 2nd derivative of the polynomic (quadratic) interpolation
615 // using the point in current time and two previous steps:
616 // d2[i] = -2.0*(y1/(h1*h2)-y2/((h2+h1)*h2)-y0/(h1*(h2+h1)))
617 const FVector CurrentLocation = mVehicle->GetActorLocation();
618
619 const FVector Y2 = PrevLocation[0];
620 const FVector Y1 = PrevLocation[1];
621 const FVector Y0 = CurrentLocation;
622 const float H1 = DeltaTime;
623 const float H2 = PrevDeltaTime;
624
625 const float H1AndH2 = H2 + H1;
626 const FVector A = Y1 / (H1 * H2);
627 const FVector B = Y2 / (H2 * (H1AndH2));
628 const FVector C = Y0 / (H1 * (H1AndH2));
629 FVector FVectorAccelerometer = TO_METERS * -2.0f * (A - B - C);
630
631 // Update the previous locations
633 PrevLocation[1] = CurrentLocation;
634 PrevDeltaTime = DeltaTime;
635
636 // Add gravitational acceleration
637 FVectorAccelerometer.Z += GRAVITY;
638
639 FQuat ImuRotation = mActorOwner->GetRootComponent()->GetComponentTransform().GetRotation();
640 FVectorAccelerometer = ImuRotation.UnrotateVector(FVectorAccelerometer);
641
642 // Cast from FVector to our Vector3D to correctly send the data in m/s^2
643 // and apply the desired noise function, in this case a normal distribution
644 Accelerometer = ComputeAccelerometerNoise(FVectorAccelerometer);
645 }
646 return Accelerometer;
647}
648
650{
651 float speed = 0.;
652 if ( mVehicle != nullptr ) {
653 speed = mVehicle->GetVehicleForwardSpeed() / 100.0f;
654
655 // Normal (or Gaussian or Gauss) distribution and a bias will be used as
656 // noise function.
657 // A mean of 0.0 is used as a first parameter.The standard deviation and the
658 // bias are determined by the client
659 constexpr float Mean = 0.0f;
660 speed = boost::algorithm::clamp(speed + mRandomEngine->GetNormalDistribution(Mean, VelocityDeviation), 0.0f, std::numeric_limits<float>::max());
661 }
662 return speed;
663}
664
666{
667 check(mActorOwner != nullptr);
668 // Angular velocity of the owner in its local frame, in rad/s. Mirrors the
669 // computation in AInertialMeasurementUnit (whose helper is not exposed).
670 FVector AngularVelocity = FVector::ZeroVector;
671 if (const auto *RootComponent = Cast<UPrimitiveComponent>(mActorOwner->GetRootComponent()))
672 {
673 const FQuat ActorGlobalRotation = RootComponent->GetComponentTransform().GetRotation();
674 const FVector GlobalAngularVelocity = CarlaGetActorAngularVelocityInRadians(*mActorOwner);
675 AngularVelocity = ActorGlobalRotation.UnrotateVector(GlobalAngularVelocity);
676 }
677
678 const FQuat SensorLocalRotation =
679 mActorOwner->GetRootComponent()->GetRelativeTransform().GetRotation();
680
681 const FVector FVectorGyroscope =
682 SensorLocalRotation.RotateVector(AngularVelocity);
683
684 // Cast from FVector to our Vector3D to correctly send the data in rad/s
685 // and apply the desired noise function, in this case a normal distribution
686 float yawrate =
687 ComputeYawNoise(FVectorGyroscope);
688
689 return yawrate; // rad/s
690}
691
693 const FVector &Gyroscope)const
694{
695 // Normal (or Gaussian or Gauss) distribution and a bias will be used as
696 // noise function.
697 // A mean of 0.0 is used as a first parameter.The standard deviation and the
698 // bias are determined by the client
699 constexpr float Mean = 0.0f;
701}
702
704{
705 // Define the epoch time (2004-01-01T00:00:00.000Z)
706 std::tm epoch_time = {};
707 epoch_time = {0, 0, 0, 1, 0, 104}; // January 1, 2004
708
709 // Convert epoch time to a std::chrono::time_point
710 std::chrono::system_clock::time_point epoch = std::chrono::system_clock::from_time_t(std::mktime(&epoch_time));
711
712 // Get the current time
713 std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
714
715 // Calculate the duration since the epoch in milliseconds
716 std::chrono::milliseconds duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - epoch);
717
718 // Return the number of milliseconds as a long
719 return duration.count();
720}
721
723{
726 // TODO For future implementation ITSContainer::ProtectedCommunicationZonesRSU_t PCZR
727
728 uint8_t const ProtectedZoneDataLength = rsu.protectedCommunicationZonesRSU.data.size(); // Maximum number of elements in path history
730 for (uint8_t i = 0; i < ProtectedZoneDataLength; ++i)
731 {
734 PCZ.expiryTimeAvailable = false;
735 PCZ.protectedZoneLatitude = 50;
736 PCZ.protectedZoneLongitude = 50;
738 PCZ.protectedZoneIDAvailable = false;
741 }
742}
743
745{
746 if (mVehicle == nullptr) {
747 return;
748 }
749
752
753 /*Vehicle Role*/
755
756 /*Exterior Lights*/
757 uint8_t *buf = &bvc.exteriorLights;
759 if (LightStateData.LowBeam)
760 {
762 }
763 if (LightStateData.HighBeam)
764 {
766 }
767 if (LightStateData.LeftBlinker)
768 {
770 }
771 if (LightStateData.RightBlinker)
772 {
774 }
775 if (LightStateData.Reverse)
776 {
778 }
779 if (LightStateData.Fog)
780 {
781 buf[0] |= 1 << (7 - ITSContainer::ExteriorLights_fogLightOn);
782 }
783 if (LightStateData.Position)
784 {
786 }
788}
789
790bool CaService::CheckHeadingDelta(float DeltaSeconds)
791{
792 if ( mVehicle != nullptr ) {
793 // if heading diff is more than 4degree
796 if (HeadingDelta > 4.0)
797 {
798 return true;
799 }
800 }
801 return false;
802}
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
@ GenerationDeltaTime_oneMilliSec
Definition LibITS.h:657
@ 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
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
@ 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
@ SemiAxisLength_unavailable
Definition LibITS.h:54
@ Longitude_oneMicroDegreeEast
Definition LibITS.h:41
@ 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
@ 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 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
Definition LibITS.h:776
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.