Implemented vehicle removal in OSM mode.
This commit is contained in:
parent
bc5871330a
commit
f3d357d7d0
|
@ -18,6 +18,7 @@ ALSM::ALSM(
|
||||||
AtomicActorSet ®istered_vehicles,
|
AtomicActorSet ®istered_vehicles,
|
||||||
BufferMap &buffer_map,
|
BufferMap &buffer_map,
|
||||||
TrackTraffic &track_traffic,
|
TrackTraffic &track_traffic,
|
||||||
|
std::vector<ActorId>& marked_for_removal,
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const cc::World &world,
|
const cc::World &world,
|
||||||
const LocalMapPtr &local_map,
|
const LocalMapPtr &local_map,
|
||||||
|
@ -29,6 +30,7 @@ ALSM::ALSM(
|
||||||
: registered_vehicles(registered_vehicles),
|
: registered_vehicles(registered_vehicles),
|
||||||
buffer_map(buffer_map),
|
buffer_map(buffer_map),
|
||||||
track_traffic(track_traffic),
|
track_traffic(track_traffic),
|
||||||
|
marked_for_removal(marked_for_removal),
|
||||||
parameters(parameters),
|
parameters(parameters),
|
||||||
world(world),
|
world(world),
|
||||||
local_map(local_map),
|
local_map(local_map),
|
||||||
|
@ -106,6 +108,15 @@ void ALSM::Update() {
|
||||||
elapsed_last_actor_destruction = current_timestamp.elapsed_seconds;
|
elapsed_last_actor_destruction = current_timestamp.elapsed_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Destorying vehicles for marked for removal by stages.
|
||||||
|
if (parameters.GetOSMMode()) {
|
||||||
|
for (const ActorId& actor_id: marked_for_removal) {
|
||||||
|
registered_vehicles.Destroy(actor_id);
|
||||||
|
RemoveActor(actor_id, true);
|
||||||
|
}
|
||||||
|
marked_for_removal.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Update dynamic state and static attributes for unregistered actors.
|
// Update dynamic state and static attributes for unregistered actors.
|
||||||
UpdateUnregisteredActorsData();
|
UpdateUnregisteredActorsData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ private:
|
||||||
// Structure containing vehicles with attribute role_name with value hero.
|
// Structure containing vehicles with attribute role_name with value hero.
|
||||||
ActorMap hero_actors;
|
ActorMap hero_actors;
|
||||||
TrackTraffic &track_traffic;
|
TrackTraffic &track_traffic;
|
||||||
|
// Array of vehicles marked by stages for removal.
|
||||||
|
std::vector<ActorId>& marked_for_removal;
|
||||||
const Parameters ¶meters;
|
const Parameters ¶meters;
|
||||||
const cc::World &world;
|
const cc::World &world;
|
||||||
const LocalMapPtr &local_map;
|
const LocalMapPtr &local_map;
|
||||||
|
@ -88,6 +90,7 @@ public:
|
||||||
ALSM(AtomicActorSet ®istered_vehicles,
|
ALSM(AtomicActorSet ®istered_vehicles,
|
||||||
BufferMap &buffer_map,
|
BufferMap &buffer_map,
|
||||||
TrackTraffic &track_traffic,
|
TrackTraffic &track_traffic,
|
||||||
|
std::vector<ActorId>& marked_for_removal,
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const cc::World &world,
|
const cc::World &world,
|
||||||
const LocalMapPtr &local_map,
|
const LocalMapPtr &local_map,
|
||||||
|
|
|
@ -17,6 +17,7 @@ LocalizationStage::LocalizationStage(
|
||||||
TrackTraffic &track_traffic,
|
TrackTraffic &track_traffic,
|
||||||
const LocalMapPtr &local_map,
|
const LocalMapPtr &local_map,
|
||||||
Parameters ¶meters,
|
Parameters ¶meters,
|
||||||
|
std::vector<ActorId>& marked_for_removal,
|
||||||
LocalizationFrame &output_array,
|
LocalizationFrame &output_array,
|
||||||
cc::DebugHelper &debug_helper)
|
cc::DebugHelper &debug_helper)
|
||||||
: vehicle_id_list(vehicle_id_list),
|
: vehicle_id_list(vehicle_id_list),
|
||||||
|
@ -25,6 +26,7 @@ LocalizationStage::LocalizationStage(
|
||||||
track_traffic(track_traffic),
|
track_traffic(track_traffic),
|
||||||
local_map(local_map),
|
local_map(local_map),
|
||||||
parameters(parameters),
|
parameters(parameters),
|
||||||
|
marked_for_removal(marked_for_removal),
|
||||||
output_array(output_array),
|
output_array(output_array),
|
||||||
debug_helper(debug_helper) {}
|
debug_helper(debug_helper) {}
|
||||||
|
|
||||||
|
@ -150,6 +152,13 @@ void LocalizationStage::Update(const unsigned long index) {
|
||||||
// Pseudo-randomized path selection if found more than one choice.
|
// Pseudo-randomized path selection if found more than one choice.
|
||||||
if (next_waypoints.size() > 1) {
|
if (next_waypoints.size() > 1) {
|
||||||
selection_index = static_cast<uint64_t>(pgen.next()) % next_waypoints.size();
|
selection_index = static_cast<uint64_t>(pgen.next()) % next_waypoints.size();
|
||||||
|
} else if (next_waypoints.size() == 0) {
|
||||||
|
if (parameters.GetOSMMode()) {
|
||||||
|
marked_for_removal.push_back(actor_id);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
throw std::invalid_argument("This is an OSM, please activate the set_open_street_map parameter");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SimpleWaypointPtr next_wp = next_waypoints.at(selection_index);
|
SimpleWaypointPtr next_wp = next_waypoints.at(selection_index);
|
||||||
if (next_wp == nullptr) {
|
if (next_wp == nullptr) {
|
||||||
|
|
|
@ -34,6 +34,8 @@ private:
|
||||||
TrackTraffic &track_traffic;
|
TrackTraffic &track_traffic;
|
||||||
const LocalMapPtr &local_map;
|
const LocalMapPtr &local_map;
|
||||||
Parameters ¶meters;
|
Parameters ¶meters;
|
||||||
|
// Array of vehicles marked by stages for removal.
|
||||||
|
std::vector<ActorId>& marked_for_removal;
|
||||||
LocalizationFrame &output_array;
|
LocalizationFrame &output_array;
|
||||||
cc::DebugHelper &debug_helper;
|
cc::DebugHelper &debug_helper;
|
||||||
LaneChangeLocationMap last_lane_change_location;
|
LaneChangeLocationMap last_lane_change_location;
|
||||||
|
@ -60,6 +62,7 @@ public:
|
||||||
TrackTraffic &track_traffic,
|
TrackTraffic &track_traffic,
|
||||||
const LocalMapPtr &local_map,
|
const LocalMapPtr &local_map,
|
||||||
Parameters ¶meters,
|
Parameters ¶meters,
|
||||||
|
std::vector<ActorId>& marked_for_removal,
|
||||||
LocalizationFrame &output_array,
|
LocalizationFrame &output_array,
|
||||||
cc::DebugHelper &debug_helper);
|
cc::DebugHelper &debug_helper);
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ bool Parameters::GetHybridPhysicsMode() const {
|
||||||
return hybrid_physics_mode.load();
|
return hybrid_physics_mode.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parameters::GetOSMMode() {
|
bool Parameters::GetOSMMode() const {
|
||||||
|
|
||||||
return osm_mode.load();
|
return osm_mode.load();
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ public:
|
||||||
bool GetHybridPhysicsMode() const;
|
bool GetHybridPhysicsMode() const;
|
||||||
|
|
||||||
/// Method to get Open Street Map mode.
|
/// Method to get Open Street Map mode.
|
||||||
bool GetOSMMode();
|
bool GetOSMMode() const;
|
||||||
|
|
||||||
/// Synchronous mode time out variable.
|
/// Synchronous mode time out variable.
|
||||||
std::chrono::duration<double, std::milli> synchronous_time_out;
|
std::chrono::duration<double, std::milli> synchronous_time_out;
|
||||||
|
|
|
@ -37,6 +37,7 @@ TrafficManagerLocal::TrafficManagerLocal(
|
||||||
track_traffic,
|
track_traffic,
|
||||||
local_map,
|
local_map,
|
||||||
parameters,
|
parameters,
|
||||||
|
marked_for_removal,
|
||||||
localization_frame,
|
localization_frame,
|
||||||
debug_helper)),
|
debug_helper)),
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ TrafficManagerLocal::TrafficManagerLocal(
|
||||||
alsm(ALSM(registered_vehicles,
|
alsm(ALSM(registered_vehicles,
|
||||||
buffer_map,
|
buffer_map,
|
||||||
track_traffic,
|
track_traffic,
|
||||||
|
marked_for_removal,
|
||||||
parameters,
|
parameters,
|
||||||
world,
|
world,
|
||||||
local_map,
|
local_map,
|
||||||
|
|
|
@ -109,6 +109,7 @@ private:
|
||||||
std::condition_variable step_end_trigger;
|
std::condition_variable step_end_trigger;
|
||||||
/// Single worker thread for sequential execution of sub-components.
|
/// Single worker thread for sequential execution of sub-components.
|
||||||
std::unique_ptr<std::thread> worker_thread;
|
std::unique_ptr<std::thread> worker_thread;
|
||||||
|
std::vector<ActorId> marked_for_removal;
|
||||||
|
|
||||||
/// Method to check if all traffic lights are frozen in a group.
|
/// Method to check if all traffic lights are frozen in a group.
|
||||||
bool CheckAllFrozen(TLGroup tl_to_freeze);
|
bool CheckAllFrozen(TLGroup tl_to_freeze);
|
||||||
|
|
|
@ -84,6 +84,10 @@ def main():
|
||||||
'--hybrid',
|
'--hybrid',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Enanble')
|
help='Enanble')
|
||||||
|
argparser.add_argument(
|
||||||
|
'--osm',
|
||||||
|
action='store_true',
|
||||||
|
help='Open Street Map mode')
|
||||||
argparser.add_argument(
|
argparser.add_argument(
|
||||||
'--car-lights-on',
|
'--car-lights-on',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
@ -108,6 +112,9 @@ def main():
|
||||||
if args.hybrid:
|
if args.hybrid:
|
||||||
traffic_manager.set_hybrid_physics_mode(True)
|
traffic_manager.set_hybrid_physics_mode(True)
|
||||||
|
|
||||||
|
if args.osm:
|
||||||
|
traffic_manager.set_osm_mode(True)
|
||||||
|
|
||||||
if args.sync:
|
if args.sync:
|
||||||
settings = world.get_settings()
|
settings = world.get_settings()
|
||||||
traffic_manager.set_synchronous_mode(True)
|
traffic_manager.set_synchronous_mode(True)
|
||||||
|
|
Loading…
Reference in New Issue