Added parameter set_percentage_keep_right_rule
This commit is contained in:
parent
8e14666bdf
commit
48fb019be6
|
@ -66,6 +66,12 @@ void Parameters::SetForceLaneChange(const ActorPtr &actor, const bool direction)
|
||||||
force_lane_change.AddEntry(entry);
|
force_lane_change.AddEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Parameters::SetKeepRightPercentage(const ActorPtr &actor, const float percentage) {
|
||||||
|
|
||||||
|
const auto entry = std::make_pair(actor->GetId(), percentage);
|
||||||
|
perc_keep_right.AddEntry(entry);
|
||||||
|
}
|
||||||
|
|
||||||
void Parameters::SetAutoLaneChange(const ActorPtr &actor, const bool enable) {
|
void Parameters::SetAutoLaneChange(const ActorPtr &actor, const bool enable) {
|
||||||
|
|
||||||
const auto entry = std::make_pair(actor->GetId(), enable);
|
const auto entry = std::make_pair(actor->GetId(), enable);
|
||||||
|
@ -137,6 +143,20 @@ ChangeLaneInfo Parameters::GetForceLaneChange(const ActorPtr &actor) {
|
||||||
return change_lane_info;
|
return change_lane_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Parameters::GetKeepRightPercentage(const ActorPtr &actor) {
|
||||||
|
|
||||||
|
const ActorId actor_id = actor->GetId();
|
||||||
|
float percentage = -1.0f;
|
||||||
|
|
||||||
|
if (perc_keep_right.Contains(actor_id)) {
|
||||||
|
percentage = perc_keep_right.GetValue(actor_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
perc_keep_right.RemoveEntry(actor_id);
|
||||||
|
|
||||||
|
return percentage;
|
||||||
|
}
|
||||||
|
|
||||||
bool Parameters::GetAutoLaneChange(const ActorPtr &actor) {
|
bool Parameters::GetAutoLaneChange(const ActorPtr &actor) {
|
||||||
|
|
||||||
const ActorId actor_id = actor->GetId();
|
const ActorId actor_id = actor->GetId();
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace traffic_manager {
|
||||||
AtomicMap<ActorId, float> perc_ignore_walkers;
|
AtomicMap<ActorId, float> perc_ignore_walkers;
|
||||||
/// Map containing % of ignoring vehicles.
|
/// Map containing % of ignoring vehicles.
|
||||||
AtomicMap<ActorId, float> perc_ignore_vehicles;
|
AtomicMap<ActorId, float> perc_ignore_vehicles;
|
||||||
|
/// Map containing % of keep right rule.
|
||||||
|
AtomicMap<ActorId, float> perc_keep_right;
|
||||||
/// Synchronous mode switch.
|
/// Synchronous mode switch.
|
||||||
std::atomic<bool> synchronous_mode;
|
std::atomic<bool> synchronous_mode;
|
||||||
/// Distance Margin
|
/// Distance Margin
|
||||||
|
@ -97,6 +99,9 @@ namespace traffic_manager {
|
||||||
/// Method to query lane change command for a vehicle.
|
/// Method to query lane change command for a vehicle.
|
||||||
ChangeLaneInfo GetForceLaneChange(const ActorPtr &actor);
|
ChangeLaneInfo GetForceLaneChange(const ActorPtr &actor);
|
||||||
|
|
||||||
|
/// Method to query percentage probability of keep right rule for a vehicle.
|
||||||
|
float GetKeepRightPercentage(const ActorPtr &actor);
|
||||||
|
|
||||||
/// Method to query auto lane change rule for a vehicle.
|
/// Method to query auto lane change rule for a vehicle.
|
||||||
bool GetAutoLaneChange(const ActorPtr &actor);
|
bool GetAutoLaneChange(const ActorPtr &actor);
|
||||||
|
|
||||||
|
@ -130,6 +135,9 @@ namespace traffic_manager {
|
||||||
/// Method to set % to ignore any vehicle.
|
/// Method to set % to ignore any vehicle.
|
||||||
void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc);
|
void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc);
|
||||||
|
|
||||||
|
/// Method to set probabilistic preference to keep on the right lane.
|
||||||
|
void SetKeepRightPercentage(const ActorPtr &actor,const float percentage);
|
||||||
|
|
||||||
/// Method to get synchronous mode.
|
/// Method to get synchronous mode.
|
||||||
bool GetSynchronousMode();
|
bool GetSynchronousMode();
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,14 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Method to set probabilistic preference to keep on the right lane.
|
||||||
|
void SetKeepRightPercentage(const ActorPtr &actor, const float percentage) {
|
||||||
|
TrafficManagerBase* tm_ptr = GetTM(_port);
|
||||||
|
if(tm_ptr != nullptr){
|
||||||
|
tm_ptr->SetKeepRightPercentage(actor, percentage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void CreateTrafficManagerServer(
|
void CreateTrafficManagerServer(
|
||||||
|
|
|
@ -100,6 +100,9 @@ public:
|
||||||
/// Method to set Global Distance to Leading Vehicle.
|
/// Method to set Global Distance to Leading Vehicle.
|
||||||
virtual void SetGlobalDistanceToLeadingVehicle(const float dist) = 0;
|
virtual void SetGlobalDistanceToLeadingVehicle(const float dist) = 0;
|
||||||
|
|
||||||
|
/// Method to set probabilistic preference to keep on the right lane.
|
||||||
|
virtual void SetKeepRightPercentage(const ActorPtr &actor,const float percentage) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -173,6 +173,11 @@ public:
|
||||||
_client->call("set_global_distance_to_leading_vehicle",distance);
|
_client->call("set_global_distance_to_leading_vehicle",distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Method to set probabilistic preference to keep on the right lane.
|
||||||
|
void SetKeepRightPercentage(const carla::rpc::Actor &actor, const float percentage) {
|
||||||
|
DEBUG_ASSERT(_client != nullptr);
|
||||||
|
_client->call("set_percentage_keep_right_rule", actor, percentage);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -197,6 +197,10 @@ void TrafficManagerLocal::SetPercentageRunningSign(const ActorPtr &actor, const
|
||||||
parameters.SetPercentageRunningSign(actor, perc);
|
parameters.SetPercentageRunningSign(actor, perc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrafficManagerLocal::SetKeepRightPercentage(const ActorPtr &actor, const float percentage) {
|
||||||
|
parameters.SetKeepRightPercentage(actor, percentage);
|
||||||
|
}
|
||||||
|
|
||||||
bool TrafficManagerLocal::CheckAllFrozen(TLGroup tl_to_freeze) {
|
bool TrafficManagerLocal::CheckAllFrozen(TLGroup tl_to_freeze) {
|
||||||
for (auto& elem : tl_to_freeze) {
|
for (auto& elem : tl_to_freeze) {
|
||||||
if (!elem->IsFrozen() || elem->GetState() != TLS::Red) {
|
if (!elem->IsFrozen() || elem->GetState() != TLS::Red) {
|
||||||
|
|
|
@ -181,6 +181,9 @@ namespace traffic_manager {
|
||||||
/// Method to specify how much distance a vehicle should maintain to
|
/// Method to specify how much distance a vehicle should maintain to
|
||||||
/// the Global leading vehicle.
|
/// the Global leading vehicle.
|
||||||
void SetGlobalDistanceToLeadingVehicle(const float distance);
|
void SetGlobalDistanceToLeadingVehicle(const float distance);
|
||||||
|
|
||||||
|
/// Method to set probabilistic preference to keep on the right lane.
|
||||||
|
void SetKeepRightPercentage(const ActorPtr &actor, const float percentage);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace traffic_manager
|
} // namespace traffic_manager
|
||||||
|
|
|
@ -170,6 +170,12 @@ void TrafficManagerRemote::SetPercentageRunningSign(const ActorPtr &_actor, cons
|
||||||
client.SetPercentageRunningSign(actor, percentage);
|
client.SetPercentageRunningSign(actor, percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrafficManagerRemote::SetKeepRightPercentage(const ActorPtr &_actor, const float percentage) {
|
||||||
|
carla::rpc::Actor actor(_actor->Serialize());
|
||||||
|
|
||||||
|
client.SetKeepRightPercentage(actor, percentage);
|
||||||
|
}
|
||||||
|
|
||||||
void TrafficManagerRemote::ResetAllTrafficLights() {
|
void TrafficManagerRemote::ResetAllTrafficLights() {
|
||||||
client.ResetAllTrafficLights();
|
client.ResetAllTrafficLights();
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,9 @@ public:
|
||||||
/// Method to set Tick timeout for synchronous execution.
|
/// Method to set Tick timeout for synchronous execution.
|
||||||
void SetSynchronousModeTimeOutInMiliSecond(double time);
|
void SetSynchronousModeTimeOutInMiliSecond(double time);
|
||||||
|
|
||||||
|
/// Method to set probabilistic preference to keep on the right lane.
|
||||||
|
void SetKeepRightPercentage(const ActorPtr &actor, const float percentage);
|
||||||
|
|
||||||
/// Method to provide synchronous tick
|
/// Method to provide synchronous tick
|
||||||
bool SynchronousTick();
|
bool SynchronousTick();
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,11 @@ public:
|
||||||
tm->SetPercentageIgnoreVehicles(carla::client::detail::ActorVariant(actor).Get(tm->GetEpisodeProxy()), percentage);
|
tm->SetPercentageIgnoreVehicles(carla::client::detail::ActorVariant(actor).Get(tm->GetEpisodeProxy()), percentage);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// Method to specify the % chance of ignoring collisions with any vehicle.
|
||||||
|
server->bind("set_percentage_keep_right_rule", [=](carla::rpc::Actor actor, const float percentage) {
|
||||||
|
tm->SetKeepRightPercentage(carla::client::detail::ActorVariant(actor).Get(tm->GetEpisodeProxy()), percentage);
|
||||||
|
});
|
||||||
|
|
||||||
/// Method to set synchronous mode.
|
/// Method to set synchronous mode.
|
||||||
server->bind("set_synchronous_mode", [=](const bool mode) {
|
server->bind("set_synchronous_mode", [=](const bool mode) {
|
||||||
tm->SetSynchronousMode(mode);
|
tm->SetSynchronousMode(mode);
|
||||||
|
|
|
@ -28,5 +28,6 @@ void export_trafficmanager() {
|
||||||
.def("ignore_vehicles_percentage", &carla::traffic_manager::TrafficManager::SetPercentageIgnoreVehicles)
|
.def("ignore_vehicles_percentage", &carla::traffic_manager::TrafficManager::SetPercentageIgnoreVehicles)
|
||||||
.def("ignore_lights_percentage", &carla::traffic_manager::TrafficManager::SetPercentageRunningLight)
|
.def("ignore_lights_percentage", &carla::traffic_manager::TrafficManager::SetPercentageRunningLight)
|
||||||
.def("ignore_signs_percentage", &carla::traffic_manager::TrafficManager::SetPercentageRunningSign)
|
.def("ignore_signs_percentage", &carla::traffic_manager::TrafficManager::SetPercentageRunningSign)
|
||||||
.def("set_global_distance_to_leading_vehicle", &carla::traffic_manager::TrafficManager::SetGlobalDistanceToLeadingVehicle);
|
.def("set_global_distance_to_leading_vehicle", &carla::traffic_manager::TrafficManager::SetGlobalDistanceToLeadingVehicle)
|
||||||
|
.def("set_percentage_keep_right_rule", &carla::traffic_manager::TrafficManager::SetKeepRightPercentage);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue