Added release compile mode for chrono library.
This commit is contained in:
parent
f45e0d7c08
commit
bf8e160622
|
@ -143,7 +143,7 @@ void export_actor() {
|
|||
.def("get_traffic_light", &cc::Vehicle::GetTrafficLight)
|
||||
.def("enable_carsim", &cc::Vehicle::EnableCarSim, (arg("simfile_path") = ""))
|
||||
.def("use_carsim_road", &cc::Vehicle::UseCarSimRoad, (arg("enabled")))
|
||||
.def("enable_chrono_physics", &cc::Vehicle::EnableChronoPhysics, (arg("max_substeps")=10, arg("max_substep_delta_time")=0.01))
|
||||
.def("enable_chrono_physics", &cc::Vehicle::EnableChronoPhysics, (arg("max_substeps")=30, arg("max_substep_delta_time")=0.002))
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ public class Carla : ModuleRules
|
|||
UsingChrono = true;
|
||||
PublicDefinitions.Add("WITH_CHRONO");
|
||||
PrivateDefinitions.Add("WITH_CHRONO");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add public include paths required here ...
|
||||
|
@ -167,16 +167,18 @@ public class Carla : ModuleRules
|
|||
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("carla_server")));
|
||||
}
|
||||
if (UsingChrono)
|
||||
{
|
||||
{
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("ChronoEngine")));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("ChronoEngine_vehicle")));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("ChronoModels_vehicle")));
|
||||
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "dll", "ChronoEngine.dll"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "dll", "ChronoEngine_vehicle.dll"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "dll", "ChronoModels_vehicle.dll"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "dll", "ChronoModels_robot.dll"));
|
||||
PublicDelayLoadDLLs.Add(Path.Combine(LibCarlaInstallPath, "dll", "ChronoEngine.dll"));
|
||||
PublicDelayLoadDLLs.Add(Path.Combine(LibCarlaInstallPath, "dll", "ChronoEngine_vehicle.dll"));
|
||||
PublicDelayLoadDLLs.Add(Path.Combine(LibCarlaInstallPath, "dll", "ChronoModels_vehicle.dll"));
|
||||
PublicDelayLoadDLLs.Add(Path.Combine(LibCarlaInstallPath, "dll", "ChronoModels_robot.dll"));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -195,9 +197,11 @@ public class Carla : ModuleRules
|
|||
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib/libChronoEngine.so"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib/libChronoEngine_vehicle.so"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib/libChronoModels_vehicle.so"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib/libChronoModels_robot.so"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "lib/libChronoEngine.so"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "lib/libChronoEngine_vehicle.so"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "lib/libChronoModels_vehicle.so"));
|
||||
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "lib/libChronoModels_robot.so"));
|
||||
bUseRTTI = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ void FCarlaModule::LoadChronoDll()
|
|||
FString ChronoEngineDll = FPaths::Combine(*PluginDir, TEXT("ChronoEngine.dll"));
|
||||
FString ChronoVehicleDll = FPaths::Combine(*PluginDir, TEXT("ChronoEngine_vehicle.dll"));
|
||||
FString ChronoModelsDll = FPaths::Combine(*PluginDir, TEXT("ChronoModels_vehicle.dll"));
|
||||
FString ChronoRobotDll = FPaths::Combine(*PluginDir, TEXT("ChronoModels_robot.dll"));
|
||||
auto ChronoEngineHandle = FPlatformProcess::GetDllHandle(*ChronoEngineDll);
|
||||
if (ChronoEngineHandle)
|
||||
{
|
||||
|
@ -40,6 +41,11 @@ void FCarlaModule::LoadChronoDll()
|
|||
{
|
||||
UE_LOG(LogCarla, Warning, TEXT("Error: ChronoModels_vehicle.dll could not be loaded"));
|
||||
}
|
||||
auto ChronoRobotHandle = FPlatformProcess::GetDllHandle(*ChronoRobotDll);
|
||||
if (ChronoRobotHandle)
|
||||
{
|
||||
UE_LOG(LogCarla, Warning, TEXT("Error: ChronoModels_robot.dll could not be loaded"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "ChronoMovementComponent.h"
|
||||
#include "Carla/Util/RayTracer.h"
|
||||
|
||||
#ifdef WITH_CHRONO
|
||||
using namespace chrono;
|
||||
|
@ -32,29 +33,65 @@ void UChronoMovementComponent::CreateChronoMovementComponent(
|
|||
constexpr double CMTOM = 0.01;
|
||||
ChVector<> UE4LocationToChrono(const FVector& Location)
|
||||
{
|
||||
return CMTOM*ChVector<>(Location.Y, Location.Z, -Location.X);
|
||||
return CMTOM*ChVector<>(Location.Y, Location.X, Location.Z);
|
||||
}
|
||||
constexpr double MTOCM = 100;
|
||||
FVector ChronoToUE4Location(const ChVector<>& position)
|
||||
{
|
||||
return MTOCM*FVector(-position.z(), position.x(), position.y());
|
||||
return MTOCM*FVector(position.y(), position.x(), position.z());
|
||||
}
|
||||
|
||||
UERayCastTerrain::UERayCastTerrain(UWorld* World, ChVehicle* Vehicle)
|
||||
: UEWorld(World), ChronoVehicle(Vehicle) {}
|
||||
UERayCastTerrain::UERayCastTerrain(
|
||||
ACarlaWheeledVehicle* UEVehicle,
|
||||
chrono::vehicle::ChVehicle* ChrVehicle)
|
||||
: CarlaVehicle(UEVehicle), ChronoVehicle(ChrVehicle) {}
|
||||
|
||||
double UERayCastTerrain::GetHeight(double x, double y) const
|
||||
std::pair<bool, FHitResult>
|
||||
UERayCastTerrain::GetTerrainProperties(const FVector &Location) const
|
||||
{
|
||||
double z = ChronoVehicle->GetVehiclePos().z();
|
||||
FVector Location = ChronoToUE4Location({x, y, z});
|
||||
carla::log_warning("GetHeight:", x, y, z);
|
||||
return 0;
|
||||
const double MaxDistance = 1000000;
|
||||
FVector StartLocation = Location;
|
||||
FVector EndLocation = Location + FVector(0,0,-1)*MaxDistance; // search downwards
|
||||
FHitResult Hit;
|
||||
FCollisionQueryParams CollisionQueryParams;
|
||||
CollisionQueryParams.AddIgnoredActor(CarlaVehicle);
|
||||
bool bDidHit = CarlaVehicle->GetWorld()->LineTraceSingleByChannel(
|
||||
Hit,
|
||||
StartLocation,
|
||||
EndLocation,
|
||||
ECC_GameTraceChannel2, // camera (any collision)
|
||||
CollisionQueryParams,
|
||||
FCollisionResponseParams()
|
||||
);
|
||||
return std::make_pair(bDidHit, Hit);
|
||||
}
|
||||
ChVector<> UERayCastTerrain::GetNormal(double x, double y) const
|
||||
|
||||
double UERayCastTerrain::GetHeight(const ChVector<>& loc) const
|
||||
{
|
||||
return ChVector<>(0,1,0);
|
||||
FVector Location = ChronoToUE4Location(loc);
|
||||
carla::log_warning("Get Height at", Location.X, Location.Y, Location.Z);
|
||||
auto point_pair = GetTerrainProperties(Location);
|
||||
if (point_pair.first)
|
||||
{
|
||||
double Height = CMTOM*point_pair.second.Location.Z;
|
||||
carla::log_warning("(",loc.x(),loc.y(),loc.z(),") Height:",Height);
|
||||
return Height;
|
||||
}
|
||||
return -1000000.0;
|
||||
}
|
||||
float UERayCastTerrain::GetCoefficientFriction(double x, double y) const
|
||||
ChVector<> UERayCastTerrain::GetNormal(const ChVector<>& loc) const
|
||||
{
|
||||
FVector Location = ChronoToUE4Location(loc);
|
||||
auto point_pair = GetTerrainProperties(Location);
|
||||
if (point_pair.first)
|
||||
{
|
||||
FVector Normal = point_pair.second.Normal;
|
||||
carla::log_warning("(",loc.x(),loc.y(),loc.z(),") Normal:",Normal.X,Normal.Y, Normal.Z);
|
||||
return UE4LocationToChrono(Normal);
|
||||
}
|
||||
return UE4LocationToChrono(FVector(0,1,0));
|
||||
}
|
||||
float UERayCastTerrain::GetCoefficientFriction(const ChVector<>& loc) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -66,7 +103,7 @@ void UChronoMovementComponent::BeginPlay()
|
|||
DisableUE4VehiclePhysics();
|
||||
|
||||
// // // Chrono system
|
||||
sys.Set_G_acc(ChVector<>(0, -9.8, 0));
|
||||
// sys.Set_G_acc(ChVector<>(0, 0, -9.81));
|
||||
sys.SetSolverType(ChSolver::Type::BARZILAIBORWEIN);
|
||||
sys.SetSolverMaxIterations(150);
|
||||
sys.SetMaxPenetrationRecoverySpeed(4.0);
|
||||
|
@ -74,7 +111,7 @@ void UChronoMovementComponent::BeginPlay()
|
|||
// // Create the HMMWV vehicle, set parameters, and initialize.
|
||||
// // Typical aerodynamic drag for HMMWV: Cd = 0.5 and area ~5 m2
|
||||
my_hmmwv = HMMWV_Full(&sys);
|
||||
my_hmmwv.SetContactMethod(ChMaterialSurface::NSC);
|
||||
my_hmmwv.SetContactMethod(ChContactMethod::NSC);
|
||||
my_hmmwv.SetChassisFixed(false);
|
||||
// Missing axis transformations to UE coordinate system
|
||||
FVector VehicleLocation = CarlaVehicle->GetActorLocation();
|
||||
|
@ -82,12 +119,12 @@ void UChronoMovementComponent::BeginPlay()
|
|||
my_hmmwv.SetPowertrainType(PowertrainModelType::SHAFTS);
|
||||
my_hmmwv.SetDriveType(DrivelineType::FWD);
|
||||
my_hmmwv.SetTireType(TireModelType::PAC02);
|
||||
my_hmmwv.SetTireStepSize(0.001);
|
||||
my_hmmwv.SetTireStepSize(MaxSubstepDeltaTime);
|
||||
my_hmmwv.SetAerodynamicDrag(0.5, 5.0, 1.2);
|
||||
my_hmmwv.Initialize();
|
||||
|
||||
// Create the terrain
|
||||
terrain = chrono_types::make_shared<UERayCastTerrain>(GetWorld(), &my_hmmwv.GetVehicle());
|
||||
terrain = chrono_types::make_shared<UERayCastTerrain>(CarlaVehicle, &my_hmmwv.GetVehicle());
|
||||
|
||||
carla::log_warning("ChronoBeginPlay");
|
||||
}
|
||||
|
|
|
@ -27,14 +27,15 @@
|
|||
#ifdef WITH_CHRONO
|
||||
class UERayCastTerrain : public chrono::vehicle::ChTerrain
|
||||
{
|
||||
UWorld* UEWorld;
|
||||
ACarlaWheeledVehicle* CarlaVehicle;
|
||||
chrono::vehicle::ChVehicle* ChronoVehicle;
|
||||
public:
|
||||
UERayCastTerrain(UWorld* World, chrono::vehicle::ChVehicle* Vehicle);
|
||||
UERayCastTerrain(ACarlaWheeledVehicle* UEVehicle, chrono::vehicle::ChVehicle* ChrVehicle);
|
||||
|
||||
double GetHeight(double x, double y) const override;
|
||||
chrono::ChVector<> GetNormal(double x, double y) const override;
|
||||
float GetCoefficientFriction(double x, double y) const;
|
||||
std::pair<bool, FHitResult> GetTerrainProperties(const FVector &Location) const;
|
||||
double GetHeight(const chrono::ChVector<>& loc) const override;
|
||||
chrono::ChVector<> GetNormal(const chrono::ChVector<>& loc) const override;
|
||||
float GetCoefficientFriction(const chrono::ChVector<>& loc) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -504,7 +504,8 @@ if ${USE_CHRONO} ; then
|
|||
# -- Get Chrono and compile it with libc++ -------------------------------------
|
||||
# ==============================================================================
|
||||
|
||||
CHRONO_TAG=5.0.1
|
||||
# CHRONO_TAG=5.0.1
|
||||
CHRONO_TAG=develop
|
||||
CHRONO_REPO=https://github.com/projectchrono/chrono.git
|
||||
|
||||
CHRONO_SRC_DIR=chrono-source
|
||||
|
@ -524,6 +525,7 @@ if ${USE_CHRONO} ; then
|
|||
-DCMAKE_CXX_FLAGS="-fPIC -std=c++14 -stdlib=libc++ -I${LLVM_INCLUDE} -L${LLVM_LIBPATH} -Wno-unused-command-line-argument" \
|
||||
-DEIGEN3_INCLUDE_DIR="../../${EIGEN_INCLUDE}" \
|
||||
-DCMAKE_INSTALL_PREFIX="../../${CHRONO_INSTALL_DIR}" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DENABLE_MODULE_VEHICLE=ON \
|
||||
..
|
||||
ninja
|
||||
|
|
Loading…
Reference in New Issue