Fixes a map change error when TM is in synchronous mode (#3288)
* Update build_windows.md Added info about command execution that toke me many time to find out * Update build_windows.md Updated as requested in pull request review * Running Carla when choosing a) deb Carla install This fixes a minor error in the documentation regarding running carla, if the deb installation was choosen. * Fix for traffic manager freezing upon map change * Remove manual unlock of mutex Co-authored-by: Néstor Sabater <web.nsabater@gmail.com> Co-authored-by: ll7 <32880741+ll7@users.noreply.github.com> Co-authored-by: Praveen Kumar <pravinblaze@hotmail.com> Co-authored-by: bernat <bernatx@gmail.com>
This commit is contained in:
parent
5bdd65ca0e
commit
4757ce4dcc
|
@ -237,7 +237,6 @@ private:
|
|||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
auto it = _tm_map.find(port);
|
||||
if (it != _tm_map.end()) {
|
||||
_mutex.unlock();
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
@ -123,7 +123,7 @@ void TrafficManagerLocal::Run() {
|
|||
// Wait for external trigger to initiate cycle in synchronous mode.
|
||||
if (synchronous_mode) {
|
||||
std::unique_lock<std::mutex> lock(step_execution_mutex);
|
||||
step_begin_trigger.wait(lock, [this]() {return step_begin.load();});
|
||||
step_begin_trigger.wait(lock, [this]() {return step_begin.load() || !run_traffic_manger.load();});
|
||||
step_begin.store(false);
|
||||
}
|
||||
|
||||
|
@ -218,6 +218,9 @@ bool TrafficManagerLocal::SynchronousTick() {
|
|||
void TrafficManagerLocal::Stop() {
|
||||
|
||||
run_traffic_manger.store(false);
|
||||
if (parameters.GetSynchronousMode()) {
|
||||
step_begin_trigger.notify_one();
|
||||
}
|
||||
|
||||
if (worker_thread) {
|
||||
if (worker_thread->joinable()) {
|
||||
|
@ -382,7 +385,12 @@ void TrafficManagerLocal::ResetAllTrafficLights() {
|
|||
}
|
||||
|
||||
void TrafficManagerLocal::SetSynchronousMode(bool mode) {
|
||||
const bool previous_mode = parameters.GetSynchronousMode();
|
||||
parameters.SetSynchronousMode(mode);
|
||||
if (previous_mode && !mode) {
|
||||
step_begin.store(true);
|
||||
step_begin_trigger.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
void TrafficManagerLocal::SetSynchronousModeTimeOutInMiliSecond(double time) {
|
||||
|
|
Loading…
Reference in New Issue