CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Vehicle
MovementComponents
ChronoMovementComponent.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
// Copyright (c) 2019 Intel Corporation
4
//
5
// This work is licensed under the terms of the MIT license.
6
// For a copy, see <https://opensource.org/licenses/MIT>.
7
8
#pragma once
9
10
#include "
BaseCarlaMovementComponent.h
"
11
#include "
Carla/Vehicle/VehicleControl.h
"
12
13
#ifdef WITH_CHRONO
14
#include <
util/disable-ue4-macros.h
>
15
16
#if defined(__clang__)
17
# pragma clang diagnostic push
18
# pragma clang diagnostic ignored "-Wshadow"
19
#endif
20
21
#include "chrono/physics/ChSystemNSC.h"
22
#include "chrono_vehicle/ChVehicleModelData.h"
23
#include "chrono_vehicle/ChTerrain.h"
24
#include "chrono_vehicle/driver/ChDataDriver.h"
25
#include "chrono_vehicle/wheeled_vehicle/vehicle/WheeledVehicle.h"
26
27
#if defined(__clang__)
28
# pragma clang diagnostic pop
29
#endif
30
31
#include <
util/enable-ue4-macros.h
>
32
#endif
33
34
#include "ChronoMovementComponent.generated.h"
35
36
#ifdef WITH_CHRONO
37
class
UERayCastTerrain :
public
chrono::vehicle::ChTerrain
38
{
39
ACarlaWheeledVehicle* CarlaVehicle;
40
chrono::vehicle::ChVehicle* ChronoVehicle;
41
public
:
42
UERayCastTerrain(ACarlaWheeledVehicle* UEVehicle, chrono::vehicle::ChVehicle* ChrVehicle);
43
44
std::pair<bool, FHitResult> GetTerrainProperties(
const
FVector &Location)
const
;
45
virtual
double
GetHeight(
const
chrono::ChVector<>& loc)
const override
;
46
virtual
chrono::ChVector<> GetNormal(
const
chrono::ChVector<>& loc)
const override
;
47
virtual
float
GetCoefficientFriction(
const
chrono::ChVector<>& loc)
const override
;
48
};
49
#endif
50
51
UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent) )
52
class CARLA_API
UChronoMovementComponent
: public
UBaseCarlaMovementComponent
53
{
54
GENERATED_BODY()
55
56
#ifdef WITH_CHRONO
57
chrono::ChSystemNSC Sys;
58
std::shared_ptr<chrono::vehicle::WheeledVehicle>
Vehicle
;
59
std::shared_ptr<UERayCastTerrain> Terrain;
60
#endif
61
62
uint64_t
MaxSubsteps
= 10;
63
float
MaxSubstepDeltaTime
= 0.01;
64
FVehicleControl
VehicleControl
;
65
FString
VehicleJSON
=
"hmmwv/vehicle/HMMWV_Vehicle.json"
;
66
FString
PowertrainJSON
=
"hmmwv/powertrain/HMMWV_ShaftsPowertrain.json"
;
67
FString
TireJSON
=
"hmmwv/tire/HMMWV_Pac02Tire.json"
;
68
FString
BaseJSONPath
=
""
;
69
70
public
:
71
72
73
static
void
CreateChronoMovementComponent
(
74
ACarlaWheeledVehicle
*
Vehicle
,
75
uint64_t
MaxSubsteps
,
76
float
MaxSubstepDeltaTime
,
77
FString
VehicleJSON
=
""
,
78
FString
PowertrainJSON
=
""
,
79
FString
TireJSON
=
""
,
80
FString
BaseJSONPath
=
""
);
81
82
#ifdef WITH_CHRONO
83
virtual
void
BeginPlay
()
override
;
84
85
void
InitializeChronoVehicle();
86
87
void
ProcessControl
(
FVehicleControl
&Control)
override
;
88
89
void
TickComponent(
float
DeltaTime,
90
ELevelTick TickType,
91
FActorComponentTickFunction* ThisTickFunction)
override
;
92
93
void
AdvanceChronoSimulation(
float
StepSize);
94
95
virtual
FVector
GetVelocity
()
const override
;
96
97
virtual
int32
GetVehicleCurrentGear
()
const override
;
98
99
virtual
float
GetVehicleForwardSpeed
()
const override
;
100
101
virtual
void
EndPlay(
const
EEndPlayReason::Type EndPlayReason)
override
;
102
#endif
103
104
private
:
105
106
void
DisableChronoPhysics
();
107
108
UFUNCTION()
109
void
OnVehicleHit
(
AActor
*Actor,
110
AActor
*OtherActor,
111
FVector NormalImpulse,
112
const FHitResult &Hit);
113
114
// On car mesh overlap, only works when carsim is enabled
115
// (this event triggers when overlapping with static environment)
116
UFUNCTION()
117
void
OnVehicleOverlap
(UPrimitiveComponent* OverlappedComponent,
118
AActor
* OtherActor,
119
UPrimitiveComponent* OtherComp,
120
int32 OtherBodyIndex,
121
bool
bFromSweep,
122
const FHitResult & SweepResult);
123
};
BaseCarlaMovementComponent.h
Vehicle
@ Vehicle
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Util/EnvironmentObject.h:21
VehicleControl.h
AActor
ACarlaWheeledVehicle
Base class for CARLA wheeled vehicles.
Definition
CarlaWheeledVehicle.h:85
UBaseCarlaMovementComponent
Definition
BaseCarlaMovementComponent.h:22
UBaseCarlaMovementComponent::ProcessControl
virtual void ProcessControl(FVehicleControl &Control)
Definition
BaseCarlaMovementComponent.cpp:30
UBaseCarlaMovementComponent::BeginPlay
virtual void BeginPlay() override
Definition
BaseCarlaMovementComponent.cpp:16
UBaseCarlaMovementComponent::GetVehicleCurrentGear
virtual int32 GetVehicleCurrentGear() const
Definition
BaseCarlaMovementComponent.cpp:44
UBaseCarlaMovementComponent::GetVehicleForwardSpeed
virtual float GetVehicleForwardSpeed() const
Definition
BaseCarlaMovementComponent.cpp:49
UBaseCarlaMovementComponent::GetVelocity
virtual FVector GetVelocity() const
Definition
BaseCarlaMovementComponent.cpp:35
UChronoMovementComponent
Definition
ChronoMovementComponent.h:53
UChronoMovementComponent::VehicleJSON
FString VehicleJSON
Definition
ChronoMovementComponent.h:65
UChronoMovementComponent::BaseJSONPath
FString BaseJSONPath
Definition
ChronoMovementComponent.h:68
UChronoMovementComponent::MaxSubstepDeltaTime
float MaxSubstepDeltaTime
Definition
ChronoMovementComponent.h:63
UChronoMovementComponent::OnVehicleHit
void OnVehicleHit(AActor *Actor, AActor *OtherActor, FVector NormalImpulse, const FHitResult &Hit)
Definition
ChronoMovementComponent.cpp:364
UChronoMovementComponent::VehicleControl
FVehicleControl VehicleControl
Definition
ChronoMovementComponent.h:64
UChronoMovementComponent::CreateChronoMovementComponent
static void CreateChronoMovementComponent(ACarlaWheeledVehicle *Vehicle, uint64_t MaxSubsteps, float MaxSubstepDeltaTime, FString VehicleJSON="", FString PowertrainJSON="", FString TireJSON="", FString BaseJSONPath="")
Definition
ChronoMovementComponent.cpp:21
UChronoMovementComponent::MaxSubsteps
uint64_t MaxSubsteps
Definition
ChronoMovementComponent.h:62
UChronoMovementComponent::DisableChronoPhysics
void DisableChronoPhysics()
Definition
ChronoMovementComponent.cpp:351
UChronoMovementComponent::OnVehicleOverlap
void OnVehicleOverlap(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
Definition
ChronoMovementComponent.cpp:374
UChronoMovementComponent::TireJSON
FString TireJSON
Definition
ChronoMovementComponent.h:67
UChronoMovementComponent::PowertrainJSON
FString PowertrainJSON
Definition
ChronoMovementComponent.h:66
disable-ue4-macros.h
enable-ue4-macros.h
FVehicleControl
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Vehicle/VehicleControl.h:13
Generated by
1.18.0