CARLA
Loading...
Searching...
No Matches
WalkerController.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
12
16
17#include <util/ue-header-guard-begin.h>
18#include "CoreMinimal.h"
19#include "AIController.h"
20#include <util/ue-header-guard-end.h>
21
22#include "WalkerController.generated.h"
23
24/// Possesses every walker pawn. Historically a plain AController that only
25/// relayed the client-computed FWalkerControl into the character movement;
26/// it is now an AAIController with a UCrowdFollowingComponent so the server
27/// can also path-follow on the engine navmesh (server-side pedestrian
28/// navigation on World Partition maps). Manual FWalkerControl input and
29/// navmesh following are mutually exclusive: applying a manual control
30/// aborts any active navigation request.
31UCLASS()
32class CARLA_API AWalkerController : public AAIController
33{
34 GENERATED_BODY()
35
36public:
37
38 AWalkerController(const FObjectInitializer &ObjectInitializer);
39
40 void OnPossess(APawn *InPawn) override;
41
42 void Tick(float DeltaSeconds) override;
43
44 /// Maximum walk speed allowed in centimetres per second.
45 UFUNCTION(BlueprintCallable)
46 float GetMaximumWalkSpeed() const
47 {
48 return 4096.0f; // ~147 km/h
49 }
50
51 UFUNCTION(BlueprintCallable)
52 void ApplyWalkerControl(const FWalkerControl &InControl);
53
54 UFUNCTION(BlueprintCallable)
56 {
57 return Control;
58 }
59
60 UFUNCTION(BlueprintCallable)
61 void GetBonesTransform(FWalkerBoneControlOut &WalkerBones);
62
63 UFUNCTION(BlueprintCallable)
64 void SetBonesTransform(const FWalkerBoneControlIn &WalkerBones);
65
66 UFUNCTION(BlueprintCallable)
67 void BlendPose(float Blend);
68
69 UFUNCTION(BlueprintCallable)
70 void GetPoseFromAnimation();
71
72 /// -- Server-side navmesh navigation ---------------------------------------
73
74 /// Enter navigation mode (idempotent). Returns false if no walker pawn is
75 /// possessed. The manual control input is suppressed while navigating.
76 /// @a bIsCrosser selects the query filter: crossers may traverse
77 /// road/crosswalk nav areas (drawn once per walker by the episode with
78 /// probability pedestrians_cross_factor); the flag is ignored when
79 /// navigation is already active, so repeated Start calls cannot re-draw.
80 bool StartNavigation(bool bIsCrosser = false);
81
82 /// Path-follow to @a WorldLocation (world-local centimeters) on the navmesh
83 /// through the crowd following component. Implies StartNavigation().
84 bool GoToNavLocation(const FVector &WorldLocation);
85
86 /// Walking speed used while navigating, in cm/s. The manual control path
87 /// scales its input against GetMaximumWalkSpeed(), so the character's
88 /// MaxWalkSpeed is only lowered to this value while navigation is active
89 /// and restored when it stops.
90 bool SetNavMaxSpeed(float SpeedCmPerSec);
91
92 /// Abort any navigation request and return to manual control.
93 bool StopNavigation();
94
95 bool IsNavigationActive() const
96 {
97 return bNavigationActive;
98 }
99
100private:
101
102 void SetNavigationActive(bool bActive);
103
105
106 /// Walking speed applied while navigating, cm/s (defaults to the usual
107 /// pedestrian speed the Python clients use, 1.39 m/s).
108 float NavMaxSpeed = 139.0f;
109
110 bool bNavigationActive = false;
111
112 /// Whether this walker may traverse road/crosswalk nav areas. Drawn once
113 /// per walker when its navigation starts.
114 bool bNavCrosser = false;
115};
bool bNavCrosser
Whether this walker may traverse road/crosswalk nav areas.
void Tick(float DeltaSeconds) override
bool IsNavigationActive() const
float GetMaximumWalkSpeed() const
Maximum walk speed allowed in centimetres per second.
FWalkerControl Control
float NavMaxSpeed
Walking speed applied while navigating, cm/s (defaults to the usual pedestrian speed the Python clien...
AWalkerController(const FObjectInitializer &ObjectInitializer)
void OnPossess(APawn *InPawn) override
const FWalkerControl GetWalkerControl() const