Skip to content

AirSim UE5 support #4672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix some pawn and wheel stuff
  • Loading branch information
alonfaraj committed Aug 25, 2022
commit d5455f7dfdb3769f6854516ad6fe8e416e5e4996
12 changes: 6 additions & 6 deletions Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <vector>
#include "common/common_utils/Utils.hpp"
#include "common/ClockFactory.hpp"
#include <ChaosVehicles/ChaosVehiclesCore/Public/TransmissionSystem.h>

#define LOCTEXT_NAMESPACE "VehiclePawn"

Expand Down Expand Up @@ -93,19 +92,19 @@ void ACarPawn::setupVehicleMovementComponent()
// Wheels/Tires
// Setup the wheels
movement->WheelSetups[0].WheelClass = UCarWheelFront::StaticClass();
movement->WheelSetups[0].BoneName = FName("PhysWheel_FL");
movement->WheelSetups[0].BoneName = FName("WheelFL");
movement->WheelSetups[0].AdditionalOffset = FVector(0.f, -8.f, 0.f);

movement->WheelSetups[1].WheelClass = UCarWheelFront::StaticClass();
movement->WheelSetups[1].BoneName = FName("PhysWheel_FR");
movement->WheelSetups[1].BoneName = FName("WheelFR");
movement->WheelSetups[1].AdditionalOffset = FVector(0.f, 8.f, 0.f);

movement->WheelSetups[2].WheelClass = UCarWheelRear::StaticClass();
movement->WheelSetups[2].BoneName = FName("PhysWheel_BL");
movement->WheelSetups[2].BoneName = FName("WheelBL");
movement->WheelSetups[2].AdditionalOffset = FVector(0.f, -8.f, 0.f);

movement->WheelSetups[3].WheelClass = UCarWheelRear::StaticClass();
movement->WheelSetups[3].BoneName = FName("PhysWheel_BR");
movement->WheelSetups[3].BoneName = FName("WheelBR");
movement->WheelSetups[3].AdditionalOffset = FVector(0.f, 8.f, 0.f);

// Adjust the tire loading
Expand Down Expand Up @@ -149,10 +148,11 @@ void ACarPawn::setupVehicleMovementComponent()
if (primitive) {
primitive->BodyInstance.COMNudge = FVector(8.0f, 0.0f, 0.0f);
}

movement->UpdatedPrimitive = primitive;
// Set the inertia scale. This controls how the mass of the vehicle is distributed.
movement->InertiaTensorScale = FVector(1.0f, 1.333f, 1.2f);
//movement->bDeprecatedSpringOffsetMode = true;
movement->bAutoRegisterUpdatedComponent = true;
}

void ACarPawn::NotifyHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation,
Expand Down
2 changes: 1 addition & 1 deletion Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void CarPawnApi::reset()
movement_->SetActive(true, true);
vehicle_api_->setCarControls(msr::airlib::CarApiBase::CarControls());
updateMovement(msr::airlib::CarApiBase::CarControls());

movement_->ResetVehicleState();
//auto pv = movement_->PVehicle;
//if (pv) {
// pv->mWheelsDynData.setToRestState();
Expand Down
1 change: 1 addition & 0 deletions Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ class CarPawnApi
ACarPawn* pawn_;
const msr::airlib::Kinematics::State* pawn_kinematics_;
msr::airlib::CarApiBase* vehicle_api_;
UChaosWheeledVehicleMovementComponent* movement_;
};
10 changes: 5 additions & 5 deletions Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelFront.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

UCarWheelFront::UCarWheelFront()
{
WheelRadius = 18.f;
WheelWidth = 15.0f;
WheelRadius = 38.f;
WheelWidth = 17.0f;
//WheelMass = 20.0f;
SuspensionDampingRatio = 0.25f;
bAffectedByHandbrake = false;
//SteerAngle = 40.f;
MaxSteerAngle = 50.f;
AxleType = EAxleType::Front;

// Setup suspension forces
SuspensionForceOffset = FVector(0.0f, 0.0f, 0.0f);
SuspensionMaxRaise = 10.0f;
SuspensionMaxDrop = 10.0f;
//SuspensionNaturalFrequency = 9.0f;
SuspensionDampingRatio = 1.05f;
SuspensionDampingRatio = 1.5f;

// Find the tire object and set the data for it
//static ConstructorHelpers::FObjectFinder<UTireConfig> TireData(TEXT("/AirSim/VehicleAdv/Vehicle/WheelData/Vehicle_FrontTireConfig.Vehicle_FrontTireConfig"));
Expand Down
9 changes: 5 additions & 4 deletions Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelRear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@

UCarWheelRear::UCarWheelRear()
{
WheelRadius = 18.f;
WheelWidth = 15.0f;
WheelRadius = 38.f;
WheelWidth = 17.0f;
bAffectedByHandbrake = true;
//SteerAngle = 0.f;
MaxSteerAngle = 0.f;
AxleType = EAxleType::Rear;

// Setup suspension forces
SuspensionForceOffset = FVector(0.0f, 0.0f, 0.0f);
SuspensionMaxRaise = 10.0f;
SuspensionMaxDrop = 10.0f;
//SuspensionNaturalFrequency = 9.0f;
SuspensionDampingRatio = 1.05f;
SuspensionDampingRatio = 1.5f;

// Find the tire object and set the data for it
//static ConstructorHelpers::FObjectFinder<UTireConfig> TireData(TEXT("/AirSim/VehicleAdv/Vehicle/WheelData/Vehicle_BackTireConfig.Vehicle_BackTireConfig"));
Expand Down