Implemented vehicle removal in OSM mode.
This commit is contained in:
parent
bc5871330a
commit
f3d357d7d0
|
@ -18,6 +18,7 @@ ALSM::ALSM(
|
|||
AtomicActorSet ®istered_vehicles,
|
||||
BufferMap &buffer_map,
|
||||
TrackTraffic &track_traffic,
|
||||
std::vector<ActorId>& marked_for_removal,
|
||||
const Parameters ¶meters,
|
||||
const cc::World &world,
|
||||
const LocalMapPtr &local_map,
|
||||
|
@ -29,6 +30,7 @@ ALSM::ALSM(
|
|||
: registered_vehicles(registered_vehicles),
|
||||
buffer_map(buffer_map),
|
||||
track_traffic(track_traffic),
|
||||
marked_for_removal(marked_for_removal),
|
||||
parameters(parameters),
|
||||
world(world),
|
||||
local_map(local_map),
|
||||
|
@ -106,6 +108,15 @@ void ALSM::Update() {
|
|||
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.
|
||||
UpdateUnregisteredActorsData();
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ private:
|
|||
// Structure containing vehicles with attribute role_name with value hero.
|
||||
ActorMap hero_actors;
|
||||
TrackTraffic &track_traffic;
|
||||
// Array of vehicles marked by stages for removal.
|
||||
std::vector<ActorId>& marked_for_removal;
|
||||
const Parameters ¶meters;
|
||||
const cc::World &world;
|
||||
const LocalMapPtr &local_map;
|
||||
|
@ -88,6 +90,7 @@ public:
|
|||
ALSM(AtomicActorSet ®istered_vehicles,
|
||||
BufferMap &buffer_map,
|
||||
TrackTraffic &track_traffic,
|
||||
std::vector<ActorId>& marked_for_removal,
|
||||
const Parameters ¶meters,
|
||||
const cc::World &world,
|
||||
const LocalMapPtr &local_map,
|
||||
|
|
|
@ -17,6 +17,7 @@ LocalizationStage::LocalizationStage(
|
|||
TrackTraffic &track_traffic,
|
||||
const LocalMapPtr &local_map,
|
||||
Parameters ¶meters,
|
||||
std::vector<ActorId>& marked_for_removal,
|
||||
LocalizationFrame &output_array,
|
||||
cc::DebugHelper &debug_helper)
|
||||
: vehicle_id_list(vehicle_id_list),
|
||||
|
@ -25,6 +26,7 @@ LocalizationStage::LocalizationStage(
|
|||
track_traffic(track_traffic),
|
||||
local_map(local_map),
|
||||
parameters(parameters),
|
||||
marked_for_removal(marked_for_removal),
|
||||
output_array(output_array),
|
||||
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.
|
||||
if (next_waypoints.size() > 1) {
|
||||
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);
|
||||
if (next_wp == nullptr) {
|
||||
|
|
|
@ -34,6 +34,8 @@ private:
|
|||
TrackTraffic &track_traffic;
|
||||
const LocalMapPtr &local_map;
|
||||
Parameters ¶meters;
|
||||
// Array of vehicles marked by stages for removal.
|
||||
std::vector<ActorId>& marked_for_removal;
|
||||
LocalizationFrame &output_array;
|
||||
cc::DebugHelper &debug_helper;
|
||||
LaneChangeLocationMap last_lane_change_location;
|
||||
|
@ -60,6 +62,7 @@ public:
|
|||
TrackTraffic &track_traffic,
|
||||
const LocalMapPtr &local_map,
|
||||
Parameters ¶meters,
|
||||
std::vector<ActorId>& marked_for_removal,
|
||||
LocalizationFrame &output_array,
|
||||
cc::DebugHelper &debug_helper);
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ bool Parameters::GetHybridPhysicsMode() const {
|
|||
return hybrid_physics_mode.load();
|
||||
}
|
||||
|
||||
bool Parameters::GetOSMMode() {
|
||||
bool Parameters::GetOSMMode() const {
|
||||
|
||||
return osm_mode.load();
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ public:
|
|||
bool GetHybridPhysicsMode() const;
|
||||
|
||||
/// Method to get Open Street Map mode.
|
||||
bool GetOSMMode();
|
||||
bool GetOSMMode() const;
|
||||
|
||||
/// Synchronous mode time out variable.
|
||||
std::chrono::duration<double, std::milli> synchronous_time_out;
|
||||
|
|
|
@ -37,6 +37,7 @@ TrafficManagerLocal::TrafficManagerLocal(
|
|||
track_traffic,
|
||||
local_map,
|
||||
parameters,
|
||||
marked_for_removal,
|
||||
localization_frame,
|
||||
debug_helper)),
|
||||
|
||||
|
@ -71,6 +72,7 @@ TrafficManagerLocal::TrafficManagerLocal(
|
|||
alsm(ALSM(registered_vehicles,
|
||||
buffer_map,
|
||||
track_traffic,
|
||||
marked_for_removal,
|
||||
parameters,
|
||||
world,
|
||||
local_map,
|
||||
|
|
|
@ -109,6 +109,7 @@ private:
|
|||
std::condition_variable step_end_trigger;
|
||||
/// Single worker thread for sequential execution of sub-components.
|
||||
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.
|
||||
bool CheckAllFrozen(TLGroup tl_to_freeze);
|
||||
|
|
|
@ -84,6 +84,10 @@ def main():
|
|||
'--hybrid',
|
||||
action='store_true',
|
||||
help='Enanble')
|
||||
argparser.add_argument(
|
||||
'--osm',
|
||||
action='store_true',
|
||||
help='Open Street Map mode')
|
||||
argparser.add_argument(
|
||||
'--car-lights-on',
|
||||
action='store_true',
|
||||
|
@ -108,6 +112,9 @@ def main():
|
|||
if args.hybrid:
|
||||
traffic_manager.set_hybrid_physics_mode(True)
|
||||
|
||||
if args.osm:
|
||||
traffic_manager.set_osm_mode(True)
|
||||
|
||||
if args.sync:
|
||||
settings = world.get_settings()
|
||||
traffic_manager.set_synchronous_mode(True)
|
||||
|
|
Loading…
Reference in New Issue