CARLA
Loading...
Searching...
No Matches
InertialMeasurementUnit.h
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#pragma once
8
10
13
15#include "carla/geom/Vector3D.h"
17
18#include <array>
19
20#include "InertialMeasurementUnit.generated.h"
21
22UCLASS()
23class CARLA_API AInertialMeasurementUnit : public ASensor
24{
25 GENERATED_BODY()
26
27public:
28
29 AInertialMeasurementUnit(const FObjectInitializer &ObjectInitializer);
30
31 static FActorDefinition GetSensorDefinition();
32
33 void Set(const FActorDescription &ActorDescription) override;
34
35 void SetOwner(AActor *Owner) override;
36
37 void GetMirrorState(carla::multigpu::SensorState &State) const override;
38
39 void SetMirrorState(const carla::multigpu::SensorState &State) override;
40
41 virtual void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTime) override;
42
43 const carla::geom::Vector3D ComputeAccelerometerNoise(
44 const FVector &Accelerometer);
45
46 const carla::geom::Vector3D ComputeGyroscopeNoise(
47 const FVector &Gyroscope);
48
49 /// Accelerometer: measures linear acceleration in m/s^2
50 carla::geom::Vector3D ComputeAccelerometer(const float DeltaTime);
51
52 /// Gyroscope: measures angular velocity in rad/sec
53 carla::geom::Vector3D ComputeGyroscope();
54
55 /// Magnetometer: orientation with respect to the North in rad
56 float ComputeCompass();
57
58 void SetAccelerationStandardDeviation(const FVector &Vec);
59
60 void SetGyroscopeStandardDeviation(const FVector &Vec);
61
62 void SetGyroscopeBias(const FVector &Vec);
63
64 const FVector &GetAccelerationStandardDeviation() const;
65
66 const FVector &GetGyroscopeStandardDeviation() const;
67
68 const FVector &GetGyroscopeBias() const;
69
70 const carla::geom::Vector3D& GetAccelerometerValue() const;
71
72 const carla::geom::Vector3D& GetGyroscopeValue() const;
73
74 float GetCompassValue() const;
75
76 /// Based on OpenDRIVE's lon and lat, North is in (0.0f, -1.0f, 0.0f)
77 static const FVector CarlaNorthVector;
78
79private:
80
81 void BeginPlay() override;
82
83 /// Standard deviation for acceleration settings.
84 FVector StdDevAccel;
85
86 /// Standard deviation for gyroscope settings.
87 FVector StdDevGyro;
88
89 /// Bias for gyroscope settings.
90 FVector BiasGyro;
91
92 /// Used to compute the acceleration
93 std::array<FVector, 2> PrevLocation;
94
95 /// Used to compute the acceleration
97
98 /// Multi-GPU secondary: the primary IMU's rotation relative to its parent.
99 TOptional<FQuat> MirroredLocalRotation;
100
101 /// Accelerometer value calculated after each PostPhysTick
103
104 /// Gyroscope value calculated after each PostPhysTick
106
107 /// Magnetometer value calculated after each PostPhysTick
109
110};
carla::geom::Vector3D GyroscopeValue
Gyroscope value calculated after each PostPhysTick.
carla::geom::Vector3D AccelerometerValue
Accelerometer value calculated after each PostPhysTick.
float CompassValue
Magnetometer value calculated after each PostPhysTick.
FVector StdDevAccel
Standard deviation for acceleration settings.
static const FVector CarlaNorthVector
Based on OpenDRIVE's lon and lat, North is in (0.0f, -1.0f, 0.0f)
FVector BiasGyro
Bias for gyroscope settings.
FVector StdDevGyro
Standard deviation for gyroscope settings.
TOptional< FQuat > MirroredLocalRotation
Multi-GPU secondary: the primary IMU's rotation relative to its parent.
float PrevDeltaTime
Used to compute the acceleration.
std::array< FVector, 2 > PrevLocation
Used to compute the acceleration.
A definition of a Carla Actor with all the variation and attributes.
A description of a Carla Actor with all its variation.
One record of frame data packet 27: the runtime state a sensor of the primary starts this frame's tic...
Definition sensorSync.h:87