CARLA
DefaultMovementComponent.cpp
Go to the documentation of this file.
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 }
void SetThrottleInput(float Value)
void ProcessControl(FVehicleControl &Control) override
const FVehicleControl & GetVehicleControl() const
Vehicle control currently applied to this vehicle.
int32 GetVehicleCurrentGear() const override
virtual void BeginPlay() override
float GetVehicleForwardSpeed() const override
Base class for CARLA wheeled vehicles.
static void CreateDefaultMovementComponent(ACarlaWheeledVehicle *Vehicle)
void SetCarlaMovementComponent(UBaseCarlaMovementComponent *MoementComponent)