CARLA
Loading...
Searching...
No Matches
VehicleAccelerationControl.h
Go to the documentation of this file.
1// Copyright (c) 2026 TIER IV, Inc.
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include <util/ue-header-guard-begin.h>
9#include "Components/ActorComponent.h"
10#include "Components/PrimitiveComponent.h"
11#include "CoreMinimal.h"
12#include <util/ue-header-guard-end.h>
13
14#include "VehicleAccelerationControl.generated.h"
15
16/// Component that controls the actor with a constant acceleration (directly applied,
17/// no pedal input). Similar to VehicleVelocityControl but for acceleration.
18UCLASS(Blueprintable, BlueprintType, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
19class CARLA_API UVehicleAccelerationControl : public UActorComponent
20{
21 GENERATED_BODY()
22
23 // ===========================================================================
24 /// @name Constructor and destructor
25 // ===========================================================================
26 /// @{
27public:
28 UVehicleAccelerationControl();
29
30 /// @}
31 // ===========================================================================
32 /// @name Get functions
33 // ===========================================================================
34 /// @{
35public:
36
37 void BeginPlay() override;
38
39 virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
40
41 // Activate the component setting the target acceleration
42 virtual void Activate(bool bReset=false) override;
43
44 // Activate the component setting the target acceleration (in vehicle local space, e.g. X=forward)
45 virtual void Activate(FVector Acceleration, bool bReset=false);
46
47 // Deactivate the component
48 virtual void Deactivate() override;
49
50private:
51 // Target acceleration in vehicle local space (e.g. X forward, Y right, Z up). Units: cm/s^2
52 UPROPERTY(Category = "Vehicle Acceleration Control", VisibleAnywhere)
53 FVector TargetAcceleration;
54
55 /// Integrated forward speed [cm/s] under our control; lateral component is left to physics for cornering
56 float ControlledForwardSpeed = 0.0f;
57
58 UPROPERTY(Transient, DuplicateTransient)
59 TObjectPtr<UPrimitiveComponent> PrimitiveComponent;
60
61 UPROPERTY(Transient, DuplicateTransient)
62 TObjectPtr<AActor> OwnerVehicle;
63
64};