Skip to content

Remove SimMode and support different vehicle types #4340

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 121 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
a4b40b9
first commit
alonfaraj Feb 1, 2022
cd41fd5
update python client ports
alonfaraj Feb 2, 2022
20dc6f1
create default sensors for car and multirotor and choose dynamiclly
alonfaraj Feb 2, 2022
eb07b46
update rpc ports in hpp files
alonfaraj Feb 2, 2022
e4ad6de
remove simmode from ASimHud
alonfaraj Feb 3, 2022
f4c3b7f
fix crash when selet vehicle from yes/no
alonfaraj Feb 3, 2022
5899db8
fix camera director override
alonfaraj Feb 3, 2022
d9f6f51
fix crash in sub window when select vehicle from yes/no gui
alonfaraj Feb 3, 2022
1e0b667
clang
alonfaraj Feb 3, 2022
59d06a1
clang
alonfaraj Feb 3, 2022
9a0dc3e
change isCar/Multirotor/CV to public
alonfaraj Feb 4, 2022
91d735c
fix recording for each simmode
alonfaraj Feb 4, 2022
f7f3c39
save all logs and imagesin same folder
alonfaraj Feb 4, 2022
68d166c
cleanup
alonfaraj Feb 4, 2022
eeb21c2
remove static member ASimModeBase::SIMMODE
alonfaraj Feb 4, 2022
259ecbb
cleanup
alonfaraj Feb 4, 2022
b82b37d
enable debug report for all modes
alonfaraj Feb 4, 2022
38fe8ed
clang
alonfaraj Feb 4, 2022
272df02
fix crash after last commit
alonfaraj Feb 4, 2022
969bf59
make camera director default according to the first vehicle
alonfaraj Feb 4, 2022
f130e60
update json.hpp to support ordered_json
alonfaraj Feb 5, 2022
06f42e3
laod json as ordered_json
alonfaraj Feb 5, 2022
86e068c
fix init order to supress warnings
alonfaraj Feb 5, 2022
a5963e4
load correct viewmode according to the first vehicle
alonfaraj Feb 5, 2022
f510fd8
check if simmode has default vehicle before start recording
alonfaraj Feb 5, 2022
d5faf95
revert json.hpp
alonfaraj Feb 6, 2022
70094d7
revert settings.hpp
alonfaraj Feb 6, 2022
bad7348
fix viewmode and camera director to take the first unorderd vehicle
alonfaraj Feb 6, 2022
d6a02d8
don't initialize camera director for vehicle which is not the first i…
alonfaraj Feb 6, 2022
3bcd0eb
cleanup
alonfaraj Feb 6, 2022
3f23fd7
remove simmode constrain
alonfaraj Feb 6, 2022
032ba58
remove get_simmode()
alonfaraj Feb 6, 2022
2d4d8d1
clang
alonfaraj Feb 6, 2022
0cacaf6
revert
alonfaraj Feb 6, 2022
ff0d6b7
remove unised simmode
alonfaraj Feb 6, 2022
03c85e4
Merge branch 'remove-simmode' of https://github.com/alonfaraj/AirSim …
alonfaraj Feb 6, 2022
8246931
rename vehicle_type to vehicle_type_
alonfaraj Feb 7, 2022
22a88aa
Merge branch 'remove-simmode' of github.com:alonfaraj/AirSim into rem…
alonfaraj Feb 7, 2022
cf30fac
remove unused simmode_name
alonfaraj Feb 7, 2022
e4ccd9c
Merge branch 'remove-simmode' of https://github.com/alonfaraj/AirSim …
alonfaraj Feb 7, 2022
602b916
pass vehicle_type to lidar and distance sensors and remove the depend…
alonfaraj Feb 7, 2022
8bc3c99
add cpp files to last commit
alonfaraj Feb 7, 2022
6f0d0ba
remove AirSimSettings::simmode_name
alonfaraj Feb 7, 2022
bf08d9a
remove AirSimSettings::singleton().simmode
alonfaraj Feb 7, 2022
233cc2f
clang
alonfaraj Feb 7, 2022
c8735aa
revert delete of msr.airlib.AirSimSettings.simmode_name
alonfaraj Feb 7, 2022
c895536
update initializeFromSettings usage
alonfaraj Feb 7, 2022
7743908
Merge branch 'remove-simmode' of github.com:alonfaraj/AirSim into rem…
alonfaraj Feb 7, 2022
a752479
update unity signatures
alonfaraj Feb 7, 2022
f0038db
Merge branch 'remove-simmode' of https://github.com/alonfaraj/AirSim …
alonfaraj Feb 7, 2022
7a7497e
add unused to silent error
alonfaraj Feb 7, 2022
81549af
fix signature
alonfaraj Feb 7, 2022
0d784c8
fix UnityDistanceSensor
alonfaraj Feb 7, 2022
8357b8b
fix unity build
alonfaraj Feb 7, 2022
ff31af4
skip computer vision vehicle
alonfaraj Feb 7, 2022
21a1abc
pass vehicle type to initializeFromSettings()
alonfaraj Feb 7, 2022
182724d
Merge branch 'remove-simmode' of https://github.com/alonfaraj/AirSim …
alonfaraj Feb 7, 2022
2913c69
update ros to support different vehicle types
alonfaraj Feb 7, 2022
117fe19
fix ros build
alonfaraj Feb 7, 2022
5781357
add get_client_by_vehicle_type() to header
alonfaraj Feb 7, 2022
8c63b34
fix ros build
alonfaraj Feb 7, 2022
a8fd173
fix vehicle_name_ to vehicle_name
alonfaraj Feb 7, 2022
fd1e51f
change sensor_defaults_* member to static
alonfaraj Feb 16, 2022
c9f691f
fix clock default settings
alonfaraj Feb 16, 2022
818e4c6
move port numbers to vars
alonfaraj Feb 16, 2022
55ce8c7
change rpc ports to static constexpr
alonfaraj Feb 16, 2022
aa18729
change port to uint16_t
alonfaraj Feb 20, 2022
7514c7a
change GetDefaultSensors to helper function
alonfaraj Feb 20, 2022
d80dff5
- change createSimMode() -> createAllSimModes()
alonfaraj Feb 20, 2022
b2a1f59
clang
alonfaraj Feb 20, 2022
ed647b4
change subwindows default to choose the first AirSim car
alonfaraj Feb 20, 2022
84b60eb
clang
alonfaraj Feb 20, 2022
2408ec5
move RecordingThread.h include
alonfaraj Feb 20, 2022
0f39922
add using SensorSettingsMap
alonfaraj Feb 20, 2022
a282519
remove kSimModeType*
alonfaraj Feb 20, 2022
ee51c78
multiple fixes for ros2
alonfaraj Feb 20, 2022
ff58f40
Merge branch 'remove-simmode' of github.com:alonfaraj/AirSim into rem…
alonfaraj Feb 20, 2022
ec5c0f3
clang
alonfaraj Feb 20, 2022
b8801f5
multiple fixes for ros1
alonfaraj Feb 20, 2022
21b5a10
typo
alonfaraj Feb 20, 2022
cf79b81
change get_client_by_vehicle_type() to get_client()
alonfaraj Feb 20, 2022
88e0f82
change shared_ptr to make_shared
alonfaraj Feb 20, 2022
a60c5f1
Merge branch 'remove-simmode' of https://github.com/alonfaraj/AirSim …
alonfaraj Feb 20, 2022
ffd6175
avoid listVehicles() api when has gimbal cmd
alonfaraj Feb 22, 2022
2caf476
update logic when has_gimbal_cmd
alonfaraj Feb 22, 2022
78df805
typo variable
alonfaraj Feb 22, 2022
399b682
- fix GetDefaultSensors for CV vehicle
alonfaraj Feb 24, 2022
9cbba72
rename key to vehicle_name
alonfaraj Feb 24, 2022
6bd6746
update loadClockSettings() to use SteppableClock as default for any v…
alonfaraj Feb 24, 2022
2f57f1b
add const to SensorSettingsMap&
alonfaraj Feb 24, 2022
7be0a72
cleanup
alonfaraj Feb 24, 2022
afa5cb6
remove const ref for simmode*
alonfaraj Feb 24, 2022
e3494aa
add AirSimSettings::getFirstVehicleSetting() to simplify usage
alonfaraj Feb 24, 2022
5e95dde
add AirsimROSWrapper::get_settings()
alonfaraj Feb 24, 2022
703ee6b
change map iteration
alonfaraj Feb 24, 2022
63bb295
Merge branch 'master' into remove-simmode
alonfaraj Feb 24, 2022
9f37a9c
clang
alonfaraj Feb 24, 2022
fd3fbc3
change FRecordingThread to use unique_ptr
alonfaraj Feb 27, 2022
65a6a56
remove default vehicle type in createSensorsFromSettings()
alonfaraj Feb 27, 2022
5b72257
Merge branch 'remove-simmode' of https://github.com/alonfaraj/AirSim …
alonfaraj Feb 27, 2022
2bb5489
simplify loadClockSettings()
alonfaraj Feb 27, 2022
f412da1
cleanup
alonfaraj Feb 27, 2022
f410b7f
add const iterator
alonfaraj Feb 27, 2022
e1289a3
remove default arguments from sensors *Simple ctor
alonfaraj Feb 27, 2022
f9aaf81
Merge branch 'remove-simmode' of https://github.com/alonfaraj/AirSim …
alonfaraj Feb 27, 2022
8020a3e
fix unity build
alonfaraj Feb 27, 2022
504209b
undo commits which caused some errors:
alonfaraj Feb 27, 2022
faf63c0
fix recording thread
alonfaraj Feb 27, 2022
acefa95
fix windows CI
alonfaraj Mar 6, 2022
60455b6
fix examples build
alonfaraj Mar 6, 2022
5494ea6
typo
alonfaraj Mar 6, 2022
ab037bf
fix examples build
alonfaraj Mar 6, 2022
00c9f2d
fix BP_LoadLevel_Button
alonfaraj Mar 7, 2022
53fdc02
update sensors ctor's
alonfaraj Mar 7, 2022
ba7b547
Merge branch 'microsoft:master' into remove-simmode
alonfaraj Mar 7, 2022
0030654
fix last merge
alonfaraj Mar 7, 2022
3736c7f
fix initializeSubWindows in case vehcile name is not the default
alonfaraj Mar 7, 2022
039e4e6
fix multiple SetNewWorldOrigin() calls
alonfaraj Mar 8, 2022
d112c6a
fix crash when auto start recording in case on vehicle exists
alonfaraj Mar 15, 2022
dcf7267
move check against zero-vehicles to FRecordingThread::startRecording
alonfaraj Mar 20, 2022
87aefac
remove new on throw exception
alonfaraj Mar 20, 2022
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 recording for each simmode
  • Loading branch information
alonfaraj committed Feb 4, 2022
commit 91d735c3696dd3b059c715b78866902b3ee29295
14 changes: 13 additions & 1 deletion Unreal/Plugins/AirSim/Source/Recording/RecordingFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,21 @@ RecordingFile::~RecordingFile()
void RecordingFile::startRecording(msr::airlib::VehicleSimApiBase* vehicle_sim_api, const std::string& folder)
{
try {
std::string vehicle_type_str;
const auto& vehicle_type = vehicle_sim_api->getVehicleSetting()->vehicle_type;
if (msr::airlib::AirSimSettings::isComputerVision(vehicle_type)) {
vehicle_type_str = "cv";
}
else if (msr::airlib::AirSimSettings::isCar(vehicle_type)) {
vehicle_type_str = "car";
}
else if (msr::airlib::AirSimSettings::isMultirotor(vehicle_type)) {
vehicle_type_str = "multirotor";
}

std::string log_folderpath = common_utils::FileSystem::getLogFolderPath(true, folder);
image_path_ = common_utils::FileSystem::ensureFolder(log_folderpath, "images");
std::string log_filepath = common_utils::FileSystem::getLogFileNamePath(log_folderpath, record_filename, "", ".txt", false);
std::string log_filepath = common_utils::FileSystem::getLogFileNamePath(log_folderpath, record_filename + vehicle_type_str, "", ".txt", false);
if (log_filepath != "")
createFile(log_filepath, vehicle_sim_api->getRecordFileLine(true));
else {
Expand Down
2 changes: 1 addition & 1 deletion Unreal/Plugins/AirSim/Source/Recording/RecordingFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RecordingFile
bool isFileOpen() const;

private:
std::string record_filename = "airsim_rec";
std::string record_filename = "airsim_rec_";
std::string image_path_;
bool is_recording_ = false;
IFileHandle* log_file_handle_ = nullptr;
Expand Down
10 changes: 5 additions & 5 deletions Unreal/Plugins/AirSim/Source/Recording/RecordingThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#include "RenderRequest.h"
#include "PIPCamera.h"

std::unique_ptr<FRecordingThread> FRecordingThread::running_instance_;
std::unique_ptr<FRecordingThread> FRecordingThread::finishing_instance_;
msr::airlib::WorkerThreadSignal FRecordingThread::finishing_signal_;
bool FRecordingThread::first_ = true;
//std::unique_ptr<FRecordingThread> FRecordingThread::running_instance_;
//std::unique_ptr<FRecordingThread> FRecordingThread::finishing_instance_;
//msr::airlib::WorkerThreadSignal FRecordingThread::finishing_signal_;
//bool FRecordingThread::first_ = true;

FRecordingThread::FRecordingThread()
: stop_task_counter_(0), recording_file_(nullptr), is_ready_(false)
: stop_task_counter_(0), recording_file_(nullptr), first_(true), is_ready_(false)
{
thread_.reset(FRunnableThread::Create(this, TEXT("FRecordingThread"), 0, TPri_BelowNormal)); // Windows default, possible to specify more priority
}
Expand Down
20 changes: 10 additions & 10 deletions Unreal/Plugins/AirSim/Source/Recording/RecordingThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class FRecordingThread : public FRunnable
FRecordingThread();
virtual ~FRecordingThread();

static void init();
static void startRecording(const RecordingSetting& settings,
const common_utils::UniqueValueMap<std::string, VehicleSimApiBase*>& vehicle_sim_apis);
static void stopRecording();
static void killRecording();
static bool isRecording();
void init();
void startRecording(const RecordingSetting& settings,
const common_utils::UniqueValueMap<std::string, VehicleSimApiBase*>& vehicle_sim_apis);
void stopRecording();
void killRecording();
bool isRecording();

protected:
virtual bool Init() override;
Expand All @@ -39,10 +39,10 @@ class FRecordingThread : public FRunnable
private:
FThreadSafeCounter stop_task_counter_;

static std::unique_ptr<FRecordingThread> running_instance_;
static std::unique_ptr<FRecordingThread> finishing_instance_;
static msr::airlib::WorkerThreadSignal finishing_signal_;
static bool first_;
std::unique_ptr<FRecordingThread> running_instance_;
std::unique_ptr<FRecordingThread> finishing_instance_;
msr::airlib::WorkerThreadSignal finishing_signal_;
bool first_;

static std::unique_ptr<FRecordingThread> instance_;

Expand Down
8 changes: 4 additions & 4 deletions Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ void ASimHUD::EndPlay(const EEndPlayReason::Type EndPlayReason)
void ASimHUD::toggleRecordHandler()
{
// ToDo - alon differnet rec files, not default
//for (const auto& simmode : simmode_) {
// simmode->toggleRecording();
//}
simmode_[0]->toggleRecording();
for (const auto& simmode : simmode_) {
simmode->toggleRecording();
}
//simmode_[0]->toggleRecording();
}

void ASimHUD::inputEventToggleRecording()
Expand Down
14 changes: 8 additions & 6 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ ASimModeBase::ASimModeBase()
if (domain_rand_mat_finder.Succeeded()) {
domain_rand_material_ = domain_rand_mat_finder.Object;
}

recording_thread_ = new FRecordingThread();
}

void ASimModeBase::toggleLoadingScreen(bool is_visible)
Expand Down Expand Up @@ -141,7 +143,7 @@ void ASimModeBase::BeginPlay()
UAirBlueprintLib::LogMessage(TEXT("Press F1 to see help"), TEXT(""), LogDebugLevel::Informational);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to add comment above this line, but just to point out whether the setTimeOfDay & advanceTimeOfDay (in ASimModeBase::Tick) should only be called once...


setupVehiclesAndCamera();
FRecordingThread::init();
recording_thread_->init();

if (getSettings().recording_setting.enabled)
startRecording();
Expand Down Expand Up @@ -191,8 +193,8 @@ void ASimModeBase::setStencilIDs()

void ASimModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
FRecordingThread::stopRecording();
FRecordingThread::killRecording();
recording_thread_->stopRecording();
recording_thread_->killRecording();
world_sim_api_.reset();
api_provider_.reset();
api_server_.reset();
Expand Down Expand Up @@ -500,17 +502,17 @@ bool ASimModeBase::toggleRecording()

void ASimModeBase::stopRecording()
{
FRecordingThread::stopRecording();
recording_thread_->stopRecording();
}

void ASimModeBase::startRecording()
{
FRecordingThread::startRecording(getSettings().recording_setting, getApiProvider()->getVehicleSimApis());
recording_thread_->startRecording(getSettings().recording_setting, getApiProvider()->getVehicleSimApis());
}

bool ASimModeBase::isRecording() const
{
return FRecordingThread::isRecording();
return recording_thread_->isRecording();
}

void ASimModeBase::toggleTraceAll()
Expand Down
4 changes: 4 additions & 0 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "UnrealImageCapture.h"
#include "SimModeBase.generated.h"

class FRecordingThread;

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLevelLoaded);

UCLASS()
Expand Down Expand Up @@ -214,6 +216,8 @@ class AIRSIM_API ASimModeBase : public AActor
bool lidar_draw_debug_points_ = false;
static ASimModeBase* SIMMODE;

FRecordingThread* recording_thread_;

private:
void setStencilIDs();
void initializeTimeOfDay();
Expand Down