diff --git a/CHANGELOG.md b/CHANGELOG.md index f936e6883..15638f1c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Latest + * Bugfix about recorder query system + * Fixed problem when vehicles enable autopilot after a replayer, now it works better. * Vulkan support: Changed project settings to make vulkan default on linux and updated make script to allow user to select opengl * Add ability to set motion blur settings for rgb camera in sensor python blueprint * Improved visual quality of the screen capture for the rgb sensor diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaRecorderQuery.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaRecorderQuery.cpp index 1dd190a6d..47edc1ed9 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaRecorderQuery.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaRecorderQuery.cpp @@ -268,8 +268,6 @@ std::string CarlaRecorderQuery::QueryInfo(std::string Filename, bool bShowAll) break; default: - // skip packet - Info << "Unknown packet id: " << Header.Id << " at offset " << File.tellg() << std::endl; SkipPacket(); break; } @@ -441,8 +439,6 @@ std::string CarlaRecorderQuery::QueryCollisions(std::string Filename, char Categ break; default: - // skip packet - Info << "Unknown packet id: " << Header.Id << " at offset " << File.tellg() << std::endl; SkipPacket(); break; } @@ -520,7 +516,7 @@ std::string CarlaRecorderQuery::QueryBlocked(std::string Filename, double MinTim { // add EventAdd.Read(File); - Actors[EventAdd.DatabaseId] = ReplayerActorInfo { EventAdd.Type, EventAdd.Description.Id }; + Actors[EventAdd.DatabaseId] = ReplayerActorInfo { EventAdd.Type, EventAdd.Description.Id, FVector(0, 0, 0), 0.0, 0.0 }; } break; @@ -590,8 +586,6 @@ std::string CarlaRecorderQuery::QueryBlocked(std::string Filename, double MinTim break; default: - // skip packet - Info << "Unknown packet id: " << Header.Id << " at offset " << File.tellg() << std::endl; SkipPacket(); break; } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayer.cpp index 963f96a7b..7647b40cc 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayer.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayer.cpp @@ -359,16 +359,8 @@ void CarlaReplayer::ProcessToTime(double Time, bool IsFirstTime) // stop replay? if (CurrentTime >= TimeToStop) { - // check if we need to stop the replayer and let it continue in simulation - // mode - if (TimeToStop < TotalTime) - { - Stop(true); // keep actors in scene so they continue with AI - } - else - { - Stop(); - } + // keep actors in scene and let them continue with autopilot + Stop(true); } } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayer.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayer.h index 39316e007..d60e56267 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayer.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayer.h @@ -136,5 +136,4 @@ private: void UpdatePositions(double Per, double DeltaTime); void InterpolatePosition(const CarlaRecorderPosition &Start, const CarlaRecorderPosition &End, double Per, double DeltaTime); - }; diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayerHelper.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayerHelper.cpp index 193d89ee4..e9f97ea05 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayerHelper.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayerHelper.cpp @@ -128,7 +128,7 @@ bool CarlaReplayerHelper::SetActorSimulatePhysics(FActorView &ActorView, bool bE } // enable / disable autopilot for an actor -bool CarlaReplayerHelper::SetActorAutopilot(FActorView &ActorView, bool bEnabled) +bool CarlaReplayerHelper::SetActorAutopilot(FActorView &ActorView, bool bEnabled, bool bKeepState) { if (!ActorView.IsValid()) { @@ -144,7 +144,7 @@ bool CarlaReplayerHelper::SetActorAutopilot(FActorView &ActorView, bool bEnabled { return false; } - Controller->SetAutopilot(bEnabled); + Controller->SetAutopilot(bEnabled, bKeepState); return true; } @@ -181,7 +181,7 @@ std::pair CarlaReplayerHelper::ProcessReplayerEventAdd( // disable physics SetActorSimulatePhysics(result.second, false); // disable autopilot - SetActorAutopilot(result.second, false); + SetActorAutopilot(result.second, false, false); } } @@ -351,9 +351,10 @@ bool CarlaReplayerHelper::ProcessReplayerFinish(bool bApplyAutopilot) SetActorSimulatePhysics(ActorView, true); // autopilot if (bApplyAutopilot) - SetActorAutopilot(ActorView, true); + SetActorAutopilot(ActorView, true, true); } } return true; } + diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayerHelper.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayerHelper.h index a974df5c3..c6663340b 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayerHelper.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Recorder/CarlaReplayerHelper.h @@ -67,5 +67,5 @@ private: // enable / disable physics for an actor bool SetActorSimulatePhysics(FActorView &ActorView, bool bEnabled); // enable / disable autopilot for an actor - bool SetActorAutopilot(FActorView &ActorView, bool bEnabled); + bool SetActorAutopilot(FActorView &ActorView, bool bEnabled, bool bKeepState = false); }; diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.cpp index 93982eea0..2bebae936 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.cpp @@ -151,21 +151,25 @@ void AWheeledVehicleAIController::Tick(const float DeltaTime) // -- Autopilot ---------------------------------------------------------------- // ============================================================================= -void AWheeledVehicleAIController::ConfigureAutopilot(const bool Enable) +void AWheeledVehicleAIController::ConfigureAutopilot(const bool Enable, const bool KeepState) { bAutopilotEnabled = Enable; - // Reset state. - Vehicle->SetSteeringInput(0.0f); - Vehicle->SetThrottleInput(0.0f); - Vehicle->SetBrakeInput(0.0f); - Vehicle->SetReverse(false); - Vehicle->SetHandbrakeInput(false); + if (!KeepState) + { + // Reset state. + Vehicle->SetSteeringInput(0.0f); + Vehicle->SetThrottleInput(0.0f); + Vehicle->SetBrakeInput(0.0f); + Vehicle->SetReverse(false); + Vehicle->SetHandbrakeInput(false); + ClearQueue(TargetLocations); + Vehicle->SetAIVehicleState( + bAutopilotEnabled ? + ECarlaWheeledVehicleState::FreeDriving : + ECarlaWheeledVehicleState::AutopilotOff); + } + TrafficLightState = ETrafficLightState::Green; - ClearQueue(TargetLocations); - Vehicle->SetAIVehicleState( - bAutopilotEnabled ? - ECarlaWheeledVehicleState::FreeDriving : - ECarlaWheeledVehicleState::AutopilotOff); /// @todo Workaround for a race condition between client and server when /// enabling autopilot right after initializing a vehicle. diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.h index 20e34ef6e..505fb0fbb 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/WheeledVehicleAIController.h @@ -137,11 +137,11 @@ public: } UFUNCTION(Category = "Wheeled Vehicle Controller", BlueprintCallable) - void SetAutopilot(bool Enable) + void SetAutopilot(bool Enable, bool KeepState = false) { if (IsAutopilotEnabled() != Enable) { - ConfigureAutopilot(Enable); + ConfigureAutopilot(Enable, KeepState); } } @@ -153,7 +153,7 @@ public: private: - void ConfigureAutopilot(bool Enable); + void ConfigureAutopilot(const bool Enable, const bool KeepState = false); /// @} // ===========================================================================