CARLA
Loading...
Searching...
No Matches
CarlaVehicleAnimationInstance.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
9#include <util/ue-header-guard-begin.h>
10#include "VehicleAnimationInstance.h"
11#include <util/ue-header-guard-end.h>
12
13#include "CarlaVehicleAnimationInstance.generated.h"
14
16
17/// Parent class of the vehicle animation blueprints. Draws the vehicle's
18/// overridden wheel poses, and otherwise, while Chaos is not simulating the
19/// vehicle, which is when the engine leaves the wheels frozen, rolls them by
20/// the distance they travel.
21UCLASS(transient)
23{
24 GENERATED_BODY()
25
26public:
27
28 virtual void NativeUpdateAnimation(float DeltaSeconds) override;
29
30 /// The pose last written for a wheel, or nullptr if there is no such wheel.
31 const FWheelAnimationData *GetWheelPose(int32 WheelIndex) const;
32
33private:
34
35 /// cm/s. A wheel moving faster than this was teleported, and is not turned.
36 UPROPERTY(EditDefaultsOnly, Category = "CARLA Wheeled Vehicle")
37 float MaxTravelSpeed = 15000.0f;
38
39 struct FWheel
40 {
41 /// Reference pose, component space.
42 FVector RestLocation = FVector::ZeroVector;
43
44 /// World space, previous update.
45 FVector LastLocation = FVector::ZeroVector;
46
47 /// Degrees.
48 float SpinAngle = 0.0f;
49 };
50
51 bool ShouldRollWheels(const ACarlaWheeledVehicle &Vehicle) const;
52
53 void InitWheels();
54
55 /// World locations of the wheels, kept while not rolling.
56 void TrackWheelLocations();
57
58 void BeginRolling();
59
60 void RollWheels(const ACarlaWheeledVehicle &Vehicle, float DeltaSeconds);
61
62 void UpdateWheelAnimationOverride(const ACarlaWheeledVehicle &Vehicle);
63
64 TArray<FWheelAnimationData> &GetWheelPoses();
65
66 TArray<FWheel> Wheels;
67
68 bool bRollingWheels = false;
69
70 bool bWasWheelAnimationOverridden = false;
71};
Base class for CARLA wheeled vehicles.
FWheelAnimationData GetWheelPose(int32 WheelIndex) const
The pose shown for a wheel: the overridden one, otherwise Chaos's, otherwise the one last drawn.
TArray< FWheelAnimationData > GetWheelPoses() const
GetWheelPose for every wheel.
Parent class of the vehicle animation blueprints.