CARLA
 
载入中...
搜索中...
未找到
BaseCarlaMovementComponent.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#include <carla/Logging.h>
14
16{
17 Super::BeginPlay();
18 ACarlaWheeledVehicle* Vehicle = Cast<ACarlaWheeledVehicle>(GetOwner());
19 if (Vehicle)
20 {
22 }
23 else
24 {
25 UE_LOG(LogCarla, Warning, TEXT("Error: Owner is not properly set for UBaseCarlaMovementComponent") );
26 }
27}
28
33
35{
36 if (CarlaVehicle)
37 {
38 return CarlaVehicle->AWheeledVehicle::GetVelocity();
39 }
40 return FVector();
41}
42
44{
45 return 0;
46}
47
49{
50 return 0.f;
51}
52
54{
55 if(!CarlaVehicle)
56 {
57 UE_LOG(LogCarla, Warning, TEXT("Error: Owner is not properly set for UCarSimManagerComponent") );
58 return;
59 }
60 CarlaVehicle->GetVehicleMovementComponent()->SetComponentTickEnabled(false);
61 CarlaVehicle->GetVehicleMovementComponent()->Deactivate();
62 CarlaVehicle->GetMesh()->PhysicsTransformUpdateMode = EPhysicsTransformUpdateMode::ComponentTransformIsKinematic;
63 auto * Bone = CarlaVehicle->GetMesh()->GetBodyInstance(NAME_None);
64 if (Bone)
65 {
66 Bone->SetInstanceSimulatePhysics(false);
67 }
68}
69
71{
72
73 FVector CurrentVelocity(0, 0, 0);
74 if (!bResetVelocity)
75 {
76 CurrentVelocity = GetVelocity();
77 }
78 CarlaVehicle->GetMesh()->SetPhysicsLinearVelocity(CurrentVelocity, false, "Vehicle_Base");
79 CarlaVehicle->GetVehicleMovementComponent()->SetComponentTickEnabled(true);
80 CarlaVehicle->GetVehicleMovementComponent()->Activate();
81 CarlaVehicle->GetMesh()->PhysicsTransformUpdateMode = EPhysicsTransformUpdateMode::SimulationUpatesComponentTransform;
82 auto * Bone = CarlaVehicle->GetMesh()->GetBodyInstance(NAME_None);
83 if (Bone)
84 {
85 Bone->SetInstanceSimulatePhysics(true);
86 }
87 else
88 {
89 carla::log_warning("No bone with name");
90 }
91 CarlaVehicle->GetMesh()->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block);
92 CarlaVehicle->GetMesh()->SetCollisionProfileName("Vehicle");
94}
Base class for CARLA wheeled vehicles.
virtual void ProcessControl(FVehicleControl &Control)
void EnableUE4VehiclePhysics(bool bResetVelocity=true)
static void log_warning(Args &&... args)
Definition Logging.h:96