CARLA
 
载入中...
搜索中...
未找到
DefaultMovementComponent.cpp
浏览该文件的文档.
1// Copyright (c) 2021 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
10
12{
13 UDefaultMovementComponent* DefaultMovementComponent = NewObject<UDefaultMovementComponent>(Vehicle);
14 Vehicle->SetCarlaMovementComponent(DefaultMovementComponent);
15 DefaultMovementComponent->RegisterComponent();
16}
17
19{
20 Super::BeginPlay();
21}
22
24{
25 auto *MovementComponent = CarlaVehicle->GetVehicleMovementComponent();
26 MovementComponent->SetThrottleInput(Control.Throttle);
27 MovementComponent->SetSteeringInput(Control.Steer);
28 MovementComponent->SetBrakeInput(Control.Brake);
29 MovementComponent->SetHandbrakeInput(Control.bHandBrake);
31 {
32 MovementComponent->SetUseAutoGears(!Control.bReverse);
33 MovementComponent->SetTargetGear(Control.bReverse ? -1 : 1, true);
34 }
35 else
36 {
37 MovementComponent->SetUseAutoGears(!Control.bManualGearShift);
38 if (Control.bManualGearShift)
39 {
40 MovementComponent->SetTargetGear(Control.Gear, true);
41 }
42 }
43 Control.Gear = MovementComponent->GetCurrentGear();
44}
45
46// FVector GetVelocity() const override;
47
49{
50 return CarlaVehicle->GetVehicleMovementComponent()->GetCurrentGear();
51}
52
54{
55 return CarlaVehicle->GetVehicleMovementComponent()->GetForwardSpeed();
56}
Base class for CARLA wheeled vehicles.
void SetThrottleInput(float Value)
const FVehicleControl & GetVehicleControl() const
Vehicle control currently applied to this vehicle.
float GetVehicleForwardSpeed() const override
int32 GetVehicleCurrentGear() const override
void ProcessControl(FVehicleControl &Control) override
static void CreateDefaultMovementComponent(ACarlaWheeledVehicle *Vehicle)