diff --git a/AirLib/include/common/AirSimSettings.hpp b/AirLib/include/common/AirSimSettings.hpp index 694351f04b..921da43417 100644 --- a/AirLib/include/common/AirSimSettings.hpp +++ b/AirLib/include/common/AirSimSettings.hpp @@ -66,7 +66,7 @@ struct AirSimSettings { { } - RecordingSetting(bool record_on_move_val, float record_interval_val, std::string folder_val, bool enabled_val) + RecordingSetting(bool record_on_move_val, float record_interval_val, const std::string& folder_val, bool enabled_val) : record_on_move(record_on_move_val), record_interval(record_interval_val), folder(folder_val), enabled(enabled_val) { @@ -124,7 +124,6 @@ struct AirSimSettings { // ShowFlag.VisualizeHDR 1. //to replicate camera settings_json to SceneCapture2D //TODO: should we use UAirBlueprintLib::GetDisplayGamma()? - typedef msr::airlib::Utils Utils; static constexpr float kSceneTargetGamma = 1.4f; int image_type = 0; @@ -621,7 +620,6 @@ struct AirSimSettings { // Map contains a default vehicle if vehicles haven't been specified std::string default_vehicle_name = vehicles.begin()->first; - for (size_t child_index = 0; child_index < req_cameras_settings.size(); ++child_index) { Settings req_camera_settings; diff --git a/Unreal/Plugins/AirSim/Source/Recording/RecordingFile.cpp b/Unreal/Plugins/AirSim/Source/Recording/RecordingFile.cpp index 3cad043b16..9e158ff9f0 100644 --- a/Unreal/Plugins/AirSim/Source/Recording/RecordingFile.cpp +++ b/Unreal/Plugins/AirSim/Source/Recording/RecordingFile.cpp @@ -7,16 +7,17 @@ #include "common/common_utils/FileSystem.hpp" -void RecordingFile::appendRecord(const std::vector& responses, msr::airlib::VehicleSimApiBase* vehicle_sim_api) +void RecordingFile::appendRecord(const std::vector& responses, + msr::airlib::VehicleSimApiBase* vehicle_sim_api) const { bool save_success = false; - std::stringstream image_file_names; + std::ostringstream image_file_names; for (auto i = 0; i < responses.size(); ++i) { const auto& response = responses.at(i); //build image file name - std::stringstream image_file_name; + std::ostringstream image_file_name; image_file_name << "img_" << vehicle_sim_api->getVehicleName() << "_" << response.camera_name << "_" << @@ -69,7 +70,6 @@ void RecordingFile::appendRecord(const std::vectorgetRecordFileLine(false).append(image_file_names.str()).append("\n")); //UAirBlueprintLib::LogMessage(TEXT("Screenshot saved to:"), filePath, LogDebugLevel::Success); - images_saved_++; } } @@ -92,7 +92,7 @@ void RecordingFile::createFile(const std::string& file_path, const std::string& } } -bool RecordingFile::isFileOpen() +bool RecordingFile::isFileOpen() const { return log_file_handle_ != nullptr; } @@ -105,11 +105,11 @@ void RecordingFile::closeFile() log_file_handle_ = nullptr; } -void RecordingFile::writeString(const std::string& str) +void RecordingFile::writeString(const std::string& str) const { try { if (log_file_handle_) { - FString line_f = FString(str.c_str()); + FString line_f(str.c_str()); log_file_handle_->Write((const uint8*)TCHAR_TO_ANSI(*line_f), line_f.Len()); } else @@ -167,7 +167,7 @@ void RecordingFile::stopRecording(bool ignore_if_stopped) UAirBlueprintLib::LogMessage(TEXT("Data saved to: "), FString(image_path_.c_str()), LogDebugLevel::Success); } -bool RecordingFile::isRecording() +bool RecordingFile::isRecording() const { return is_recording_; } diff --git a/Unreal/Plugins/AirSim/Source/Recording/RecordingFile.h b/Unreal/Plugins/AirSim/Source/Recording/RecordingFile.h index a5f82265b9..e094b07006 100644 --- a/Unreal/Plugins/AirSim/Source/Recording/RecordingFile.h +++ b/Unreal/Plugins/AirSim/Source/Recording/RecordingFile.h @@ -12,21 +12,20 @@ class RecordingFile { public: ~RecordingFile(); - void appendRecord(const std::vector& responses, msr::airlib::VehicleSimApiBase* vehicle_sim_api); + void appendRecord(const std::vector& responses, msr::airlib::VehicleSimApiBase* vehicle_sim_api) const; void appendColumnHeader(const std::string& header_columns); void startRecording(msr::airlib::VehicleSimApiBase* vehicle_sim_api, const std::string& folder=""); void stopRecording(bool ignore_if_stopped); - bool isRecording(); + bool isRecording() const; private: void createFile(const std::string& file_path, const std::string& header_columns); void closeFile(); - void writeString(const std::string& line); - bool isFileOpen(); + void writeString(const std::string& line) const; + bool isFileOpen() const; private: - std::string record_filename = "airsim_rec"; - unsigned int images_saved_ = 0; + std::string record_filename = "airsim_rec"; std::string image_path_; bool is_recording_ = false; IFileHandle* log_file_handle_ = nullptr;