New struct FVehicleControl
This commit is contained in:
parent
986a3764de
commit
0f087e396a
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VehicleControl.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct CARLA_API FVehicleControl
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(Category = "Vehicle Control", EditAnywhere)
|
||||
float Throttle = 0.0f;
|
||||
|
||||
UPROPERTY(Category = "Vehicle Control", EditAnywhere)
|
||||
float Steer = 0.0f;
|
||||
|
||||
UPROPERTY(Category = "Vehicle Control", EditAnywhere)
|
||||
float Brake = 0.0f;
|
||||
|
||||
UPROPERTY(Category = "Vehicle Control", EditAnywhere)
|
||||
bool bHandBrake = false;
|
||||
};
|
|
@ -107,9 +107,7 @@ void AWheeledVehicleAIController::Tick(const float DeltaTime)
|
|||
TickAutopilotController();
|
||||
|
||||
if (bAutopilotEnabled) {
|
||||
Vehicle->SetThrottleInput(AutopilotControl.Throttle);
|
||||
Vehicle->SetSteeringInput(AutopilotControl.Steer);
|
||||
Vehicle->SetBrakeInput(AutopilotControl.Brake);
|
||||
Vehicle->ApplyVehicleControl(AutopilotControl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "TrafficLightState.h"
|
||||
#include "VehicleControl.h"
|
||||
#include "WheeledVehicleAIController.generated.h"
|
||||
|
||||
class ACarlaWheeledVehicle;
|
||||
|
@ -182,14 +183,7 @@ public:
|
|||
/// @{
|
||||
protected:
|
||||
|
||||
struct FAutopilotControl {
|
||||
float Throttle = 0.0f;
|
||||
float Steer = 0.0f;
|
||||
float Brake = 0.0f;
|
||||
bool bHandBrake = false;
|
||||
};
|
||||
|
||||
const FAutopilotControl &GetAutopilotControl() const
|
||||
const FVehicleControl &GetAutopilotControl() const
|
||||
{
|
||||
return AutopilotControl;
|
||||
}
|
||||
|
@ -237,7 +231,7 @@ private:
|
|||
UPROPERTY(VisibleAnywhere)
|
||||
float MaximumSteerAngle = -1.0f;
|
||||
|
||||
FAutopilotControl AutopilotControl;
|
||||
FVehicleControl AutopilotControl;
|
||||
|
||||
std::queue<FVector> TargetLocations;
|
||||
};
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "Carla.h"
|
||||
#include "CarlaWheeledVehicle.h"
|
||||
|
||||
#include "AI/VehicleControl.h"
|
||||
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Engine/CollisionProfile.h"
|
||||
|
||||
|
@ -64,6 +66,14 @@ float ACarlaWheeledVehicle::GetMaximumSteerAngle() const
|
|||
// -- Set functions ------------------------------------------------------------
|
||||
// =============================================================================
|
||||
|
||||
void ACarlaWheeledVehicle::ApplyVehicleControl(const FVehicleControl &VehicleControl)
|
||||
{
|
||||
SetThrottleInput(VehicleControl.Throttle);
|
||||
SetSteeringInput(VehicleControl.Steer);
|
||||
SetBrakeInput(VehicleControl.Brake);
|
||||
SetHandbrakeInput(VehicleControl.bHandBrake);
|
||||
}
|
||||
|
||||
void ACarlaWheeledVehicle::SetThrottleInput(const float Value)
|
||||
{
|
||||
GetVehicleMovementComponent()->SetThrottleInput(Value);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "WheeledVehicle.h"
|
||||
#include "CarlaWheeledVehicle.generated.h"
|
||||
|
||||
class FVehicleControl;
|
||||
class UBoxComponent;
|
||||
|
||||
/// Base class for CARLA wheeled vehicles.
|
||||
|
@ -63,6 +64,9 @@ public:
|
|||
/// @{
|
||||
public:
|
||||
|
||||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||
void ApplyVehicleControl(const FVehicleControl &VehicleControl);
|
||||
|
||||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||
void SetThrottleInput(float Value);
|
||||
|
||||
|
|
Loading…
Reference in New Issue