Fix crash when spawn car while recording

This commit is contained in:
Blyron 2024-09-30 17:08:01 +02:00 committed by Blyron
parent b8b1d3495f
commit b4b064beb3
2 changed files with 53 additions and 7 deletions

View File

@ -118,7 +118,7 @@ void ACarlaRecorder::Ticking(float DeltaSeconds)
AddActorPosition(View);
AddVehicleAnimation(View);
AddVehicleLight(View);
AddVehicleWheelsAnimation(View);
//AddVehicleWheelsAnimation(View);
if (bAdditionalData)
{
AddActorKinematics(View);
@ -308,11 +308,15 @@ void ACarlaRecorder::AddVehicleLight(FCarlaActor *CarlaActor)
void ACarlaRecorder::AddVehicleDoor(const ACarlaWheeledVehicle &Vehicle, const EVehicleDoor SDoors, bool bIsOpen)
{
CarlaRecorderDoorVehicle DoorVehicle;
DoorVehicle.DatabaseId = Episode->GetActorRegistry().FindCarlaActor(&Vehicle)->GetActorId();
DoorVehicle.Doors = static_cast<CarlaRecorderDoorVehicle::VehicleDoorType>(SDoors);
DoorVehicle.bIsOpen = bIsOpen;
AddDoorVehicle(DoorVehicle);
const FCarlaActor* LocalCarlaActor = Episode->GetActorRegistry().FindCarlaActor(&Vehicle);
if (LocalCarlaActor != nullptr)
{
CarlaRecorderDoorVehicle DoorVehicle;
DoorVehicle.DatabaseId = LocalCarlaActor->GetActorId();
DoorVehicle.Doors = static_cast<CarlaRecorderDoorVehicle::VehicleDoorType>(SDoors);
DoorVehicle.bIsOpen = bIsOpen;
AddDoorVehicle(DoorVehicle);
}
}
void ACarlaRecorder::AddActorKinematics(FCarlaActor *CarlaActor)
@ -431,7 +435,7 @@ std::string ACarlaRecorder::Start(std::string Name, FString MapName, bool Additi
std::string Filename = GetRecorderFilename(Name);
// binary file
File.open(Filename, std::ios::binary);
File.open(Filename, std::ios::out);
if (!File.is_open())
{
return "";

View File

@ -13,6 +13,48 @@ struct CARLA_API FWheelPhysicsControl
{
GENERATED_BODY()
FWheelPhysicsControl() :
AxleType(EAxleType::Undefined),
Offset(FVector(0.0f, 0.0f, 0.0f)),
WheelRadius(1.0f),
WheelWidth(1.0f),
WheelMass(1),
CorneringStiffness(1.0f),
FrictionForceMultiplier(1.0f),
SideSlipModifier(0.5f),
SlipThreshold(1.0f),
SkidThreshold(1.0f),
MaxSteerAngle(60.0f),
bAffectedBySteering(true),
bAffectedByBrake(true),
bAffectedByHandbrake(true),
bAffectedByEngine(true),
bABSEnabled(true),
bTractionControlEnabled(true),
MaxWheelspinRotation(1.0f),
ExternalTorqueCombineMethod(ETorqueCombineMethod::None),
LateralSlipGraph(FRichCurve()),
SuspensionAxis(FVector(0.0f, 0.0f, 1.0f)),
SuspensionForceOffset(1.0f),
SuspensionMaxRaise(1.0f),
SuspensionMaxDrop(1.0f),
SuspensionDampingRatio(0.5f),
WheelLoadRatio(0.5f),
SpringRate(1.0f),
SpringPreload(1.0f),
SuspensionSmoothing(5.0f),
RollbarScaling(0.0f),
SweepShape(ESweepShape::Spherecast),
SweepType(ESweepType::ComplexSweep),
MaxBrakeTorque(1.0f),
MaxHandBrakeTorque(1.0f),
WheelIndex(0),
Location(FVector(0.0f, 0.0f, 0.0f)),
OldLocation(FVector(0.0f, 0.0f, 0.0f)),
Velocity(FVector(0.0f, 0.0f, 0.0f))
{
}
/** If left undefined then the bAffectedByEngine value is used, if defined then bAffectedByEngine is ignored and the differential setup on the vehicle defines which wheels get power from the engine */
UPROPERTY(EditAnywhere, Category = Wheel)
EAxleType AxleType;