Skip to content

Commit

Permalink
More Linux issues fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Jul 14, 2017
1 parent 77bcff8 commit 34808f7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AirLib/src/controllers/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ std::string FileSystem::createDirectory(std::string fullPath) {
}
#else
int success = mkdir(fullPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (success != 0)
if (success != 0 && errno != EEXIST)
throw std::ios_base::failure(Utils::stringf("mkdir failed for path %s with errorno %i and message %s", fullPath.c_str(), errno, strerror(errno)).c_str());
#endif
return fullPath;
Expand Down
7 changes: 5 additions & 2 deletions Unreal/Plugins/AirSim/Source/AirSim.Build.4.16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ private void SetupCompileMode(CompileMode mode, ReadOnlyTargetRules Target)

public AirSim(ReadOnlyTargetRules Target) : base(Target)
{
bEnforceIWYU = false;
//UEBuildConfiguration.bForceEnableExceptions = true;
bEnforceIWYU = false; //to support 4.16
//below is no longer supported in 4.16
bEnableExceptions = true;

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "RenderCore", "RHI" });
PrivateDependencyModuleNames.AddRange(new string[] { "UMG", "Slate", "SlateCore" });

Expand Down Expand Up @@ -119,6 +121,7 @@ private bool AddLibDependency(string LibName, string LibPath, string LibFileName

PublicAdditionalLibraries.Add(Path.Combine(LibPath, PlatformString, ConfigurationString, LibFileName + ".lib"));
} else if (Target.Platform == UnrealTargetPlatform.Linux || Target.Platform == UnrealTargetPlatform.Mac) {
isLibrarySupported = true;
PublicAdditionalLibraries.Add(Path.Combine(LibPath, "lib" + LibFileName + ".a"));
}

Expand Down
2 changes: 1 addition & 1 deletion Unreal/Plugins/AirSim/Source/AirSimGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ void AAirSimGameMode::initializeSettings()
}
}
catch (std::exception& ex) {
UAirBlueprintLib::LogMessage(FString("Error loading settings from ~/Documents/AirSim/settings.json"), FString(ex.what(), LogDebugLevel::Failure, 30);
UAirBlueprintLib::LogMessage(FString("Error loading settings from ~/Documents/AirSim/settings.json"), FString(ex.what()), LogDebugLevel::Failure, 30);
}
}
35 changes: 28 additions & 7 deletions Unreal/Plugins/AirSim/Source/Recording/RecordingFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,39 @@ RecordingFile::~RecordingFile()
closeFile();
}

std::string RecordingFile::getLogFileFullPath()
{
try {
return common_utils::FileSystem::getLogFileNamePath(record_filename, "", ".txt", true);
}
catch(std::exception& ex) {
UAirBlueprintLib::LogMessageString(std::string("getLogFileFullPath failed: "), ex.what(), LogDebugLevel::Failure);
return "";
}
}

void RecordingFile::startRecording()
{
std::string fullPath = common_utils::FileSystem::getLogFileNamePath(record_filename, "", ".txt", true);
createFile(fullPath);
try {
std::string fullPath = getLogFileFullPath();
if (fullPath != "")
createFile(fullPath);
else {
UAirBlueprintLib::LogMessageString("Cannot start recording because path for log file is not available", "", LogDebugLevel::Failure);
return;
}

if (isFileOpen()) {
is_recording_ = true;
if (isFileOpen()) {
is_recording_ = true;

UAirBlueprintLib::LogMessage(TEXT("Recording"), TEXT("Started"), LogDebugLevel::Success);
UAirBlueprintLib::LogMessage(TEXT("Recording"), TEXT("Started"), LogDebugLevel::Success);
}
else
UAirBlueprintLib::LogMessageString("Error creating log file", fullPath.c_str(), LogDebugLevel::Failure);
}
catch(...) {
UAirBlueprintLib::LogMessageString("Error in startRecording", "", LogDebugLevel::Failure);
}
else
UAirBlueprintLib::LogMessage("Error creating log file", fullPath.c_str(), LogDebugLevel::Failure);
}

void RecordingFile::stopRecording()
Expand Down
3 changes: 2 additions & 1 deletion Unreal/Plugins/AirSim/Source/Recording/RecordingFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class RecordingFile {
void closeFile();
void writeString(const std::string& line);
bool isFileOpen();
std::string getLogFileFullPath();


private:
std::string record_filename = "airsim_rec";
std::string record_filename = "airsim_rec";
unsigned int images_saved_ = 0;
FString image_path_;
bool is_recording_;
Expand Down
7 changes: 3 additions & 4 deletions Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ void ASimHUD::BeginPlay()
//avoid motion blur so capture images don't get
GetWorld()->GetGameViewport()->GetEngineShowFlags()->SetMotionBlur(false);

//Equivalent to enabling Custom Stencil in Project > Settings > Rendering > Postprocessing
UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), FString("r.CustomDepth 3"));

//above is not working so below is alternate method
//use two different methods to set console var because sometime it doesn't seem to work
static const auto custom_depth_var = IConsoleManager::Get().FindConsoleVariable(TEXT("r.CustomDepth"));
custom_depth_var->Set(3);
//Equivalent to enabling Custom Stencil in Project > Settings > Rendering > Postprocessing
UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), FString("r.CustomDepth 3"));

//create main widget
if (widget_class_ != nullptr) {
Expand Down

0 comments on commit 34808f7

Please sign in to comment.