anticipation algorithm updated

This commit is contained in:
Joel Moriana 2022-10-17 16:13:32 +02:00 committed by bernat
parent f628f204b4
commit c5abee5e79
3 changed files with 4 additions and 41 deletions

View File

@ -120,10 +120,8 @@ static const float EPSILON_RELATIVE_SPEED = 0.001f;
static const float MAX_JUNCTION_BLOCK_DISTANCE = 1.0f * WaypointSelection::SAFE_DISTANCE_AFTER_JUNCTION;
static const float TWO_KM = 2000.0f;
static const uint16_t ATTEMPTS_TO_TELEPORT = 5u;
static const float LANDMARK_DETECTION_TIME = 2.5f;
static const float TL_GREEN_TARGET_VELOCITY = 20.0f / 3.6f;
static const float TL_RED_TARGET_VELOCITY = 15.0f / 3.6f;
static const float TL_UNKNOWN_TARGET_VELOCITY = TL_RED_TARGET_VELOCITY;
static const float LANDMARK_DETECTION_TIME = 3.5f;
static const float TL_TARGET_VELOCITY = 15.0f / 3.6f;
static const float STOP_TARGET_VELOCITY = 10.0f / 3.6f;
static const float YIELD_TARGET_VELOCITY = 10.0f / 3.6f;
static const float FRICTION = 0.6f;

View File

@ -58,16 +58,7 @@ MotionPlanStage::MotionPlanStage(
world(world),
output_array(output_array),
random_device(random_device),
local_map(local_map) {
// Adding structure to avoid retrieving traffic lights when checking for landmarks.
std::vector<SharedPtr<cc::Landmark>> traffic_lights = world.GetMap()->GetAllLandmarksOfType("1000001");
for (auto &tl : traffic_lights) {
std::string landmark_id = tl->GetId();
SharedPtr<cc::Actor> actor = world.GetTrafficLight(*tl);
tl_map.insert({landmark_id, actor});
}
}
local_map(local_map) {}
void MotionPlanStage::Update(const unsigned long index) {
const ActorId actor_id = vehicle_id_list.at(index);
@ -382,32 +373,7 @@ float MotionPlanStage::GetLandmarkTargetVelocity(const SimpleWaypoint& waypoint,
float minimum_velocity = max_target_velocity;
if (landmark_type == "1000001") { // Traffic light
auto landmark_id = landmark->GetId();
if (tl_map.find(landmark_id) != tl_map.end()) {
auto actor = tl_map.at(landmark_id);
if (actor != nullptr) {
cc::TrafficLight* tl = static_cast<cc::TrafficLight*>(actor.get());
auto state = tl->GetState();
if (state == carla::rpc::TrafficLightState::Green) {
minimum_velocity = TL_GREEN_TARGET_VELOCITY;
} else if (state == carla::rpc::TrafficLightState::Yellow || state == carla::rpc::TrafficLightState::Red){
minimum_velocity = TL_RED_TARGET_VELOCITY;
} else if (state == carla::rpc::TrafficLightState::Unknown){
minimum_velocity = TL_UNKNOWN_TARGET_VELOCITY;
} else {
// Traffic light is off
continue;
}
} else {
// It is a traffic light, but it's not present in our structure
minimum_velocity = TL_UNKNOWN_TARGET_VELOCITY;
}
} else {
// It is a traffic light, but it's not present in our structure
minimum_velocity = TL_UNKNOWN_TARGET_VELOCITY;
}
minimum_velocity = TL_TARGET_VELOCITY;
} else if (landmark_type == "206") { // Stop
minimum_velocity = STOP_TARGET_VELOCITY;
} else if (landmark_type == "205") { // Yield

View File

@ -44,7 +44,6 @@ private:
cc::Timestamp current_timestamp;
RandomGenerator &random_device;
const LocalMapPtr &local_map;
TLMap tl_map;
std::pair<bool, float> CollisionHandling(const CollisionHazardData &collision_hazard,
const bool tl_hazard,