Changing several constant variables

Removing sorting in LocalizationStage.cpp
This commit is contained in:
Jacopo Bartiromo 2021-05-03 10:32:40 +02:00 committed by Jacopo Bartiromo
parent ae0ba81b9f
commit 341571c762
5 changed files with 21 additions and 38 deletions

View File

@ -347,10 +347,10 @@ std::pair<bool, float> CollisionStage::NegotiateCollision(const ActorId referenc
GeometryComparison geometry_comparison = GetGeometryBetweenActors(reference_vehicle_id, other_actor_id);
// Conditions for collision negotiation.
bool geodesic_path_bbox_touching = geometry_comparison.inter_geodesic_distance < 0.1;
bool vehicle_bbox_touching = geometry_comparison.inter_bbox_distance < 0.1;
bool ego_path_clear = geometry_comparison.other_vehicle_to_reference_geodesic > 0.1;
bool other_path_clear = geometry_comparison.reference_vehicle_to_other_geodesic > 0.1;
bool geodesic_path_bbox_touching = geometry_comparison.inter_geodesic_distance < OVERLAP_THERESHOLD;
bool vehicle_bbox_touching = geometry_comparison.inter_bbox_distance < OVERLAP_THERESHOLD;
bool ego_path_clear = geometry_comparison.other_vehicle_to_reference_geodesic > OVERLAP_THERESHOLD;
bool other_path_clear = geometry_comparison.reference_vehicle_to_other_geodesic > OVERLAP_THERESHOLD;
bool ego_path_priority = geometry_comparison.reference_vehicle_to_other_geodesic < geometry_comparison.other_vehicle_to_reference_geodesic;
bool other_path_priority = geometry_comparison.reference_vehicle_to_other_geodesic > geometry_comparison.other_vehicle_to_reference_geodesic;
bool ego_angular_priority = reference_heading_to_other_dot< cg::Math::Dot(other_heading, other_to_reference);
@ -366,7 +366,7 @@ std::pair<bool, float> CollisionStage::NegotiateCollision(const ActorId referenc
hazard = true;
const float reference_lead_distance = parameters.GetDistanceToLeadingVehicle(reference_vehicle_id);
const float specific_distance_margin = std::max(reference_lead_distance, BOUNDARY_EXTENSION_MINIMUM);
const float specific_distance_margin = std::max(reference_lead_distance, MIN_REFERENCE_DISTANCE);
available_distance_margin = static_cast<float>(std::max(geometry_comparison.reference_vehicle_to_other_geodesic
- static_cast<double>(specific_distance_margin), 0.0));
@ -381,7 +381,7 @@ std::pair<bool, float> CollisionStage::NegotiateCollision(const ActorId referenc
// Check if the same vehicle is under lock.
if (other_actor_id == lock.lead_vehicle_id) {
// If the body of the lead vehicle is touching the reference vehicle bounding box.
if (geometry_comparison.other_vehicle_to_reference_geodesic < 0.1) {
if (geometry_comparison.other_vehicle_to_reference_geodesic < OVERLAP_THERESHOLD) {
// Distance between the bodies of the vehicles.
lock.distance_to_lead_vehicle = geometry_comparison.inter_bbox_distance;
} else {

View File

@ -21,7 +21,6 @@ namespace Networking {
static const uint64_t MIN_TRY_COUNT = 20u;
static const unsigned short TM_DEFAULT_PORT = 8000u;
static const int64_t TM_TIMEOUT = 2000; // ms
const int64_t TM_WAIT_FOR_TICK_TIMEOUT = 1000;
} // namespace Networking
namespace VehicleRemoval {
@ -46,9 +45,9 @@ static const float INITIAL_PERCENTAGE_SPEED_DIFFERENCE = 30.0f;
} // namespace SpeedThreshold
namespace PathBufferUpdate {
static const float MAX_START_DISTANCE = 30.0f;
static const float MINIMUM_HORIZON_LENGTH = 30.0f;
static const float MAXIMUM_HORIZON_LENGTH = 60.0f;
static const float MAX_START_DISTANCE = 20.0f;
static const float MINIMUM_HORIZON_LENGTH = 20.0f;
static const float MAXIMUM_HORIZON_LENGTH = 40.0f;
static const float HORIZON_RATE = RATE(MAXIMUM_HORIZON_LENGTH,
MINIMUM_HORIZON_LENGTH,
SpeedThreshold::ARBITRARY_MAX_SPEED);
@ -71,20 +70,21 @@ static const float INTER_LANE_CHANGE_DISTANCE = 10.0f;
} // namespace LaneChange
namespace Collision {
static const float BOUNDARY_EXTENSION_MAXIMUM = 50.0f;
static const float BOUNDARY_EXTENSION_MAXIMUM = 40.0f;
static const float BOUNDARY_EXTENSION_MINIMUM = 2.0f;
static const float BOUNDARY_EXTENSION_RATE = RATE(BOUNDARY_EXTENSION_MAXIMUM,
BOUNDARY_EXTENSION_MINIMUM,
SpeedThreshold::ARBITRARY_MAX_SPEED);
static const float COS_10_DEGREES = 0.9848f;
static const float EPSILON_VELOCITY = 0.1f;
static const float OVERLAP_THERESHOLD = 0.1f;
static const float LOCKING_DISTANCE_PADDING = 4.0f;
static const float MAX_COLLISION_RADIUS = 100.0f;
static const float MAX_COLLISION_RADIUS = 30.0f;
static const float MAX_LOCKING_EXTENSION = 10.0f;
static const float WALKER_TIME_EXTENSION = 1.5f;
static const float SQUARE_ROOT_OF_TWO = 1.414f;
static const float VERTICAL_OVERLAP_THRESHOLD = 4.0f;
static const float EPSILON = 2.0f * std::numeric_limits<float>::epsilon();
static const float MIN_REFERENCE_DISTANCE = 1.0f;
} // namespace Collision
namespace FrameMemory {
@ -95,11 +95,9 @@ static const float INV_GROWTH_STEP_SIZE = 1.0f / static_cast<float>(GROWTH_STEP_
namespace Map {
static const float INFINITE_DISTANCE = std::numeric_limits<float>::max();
static const float GRID_SIZE = 4.0f;
static const float PED_GRID_SIZE = 10.0f;
static const float MAX_GEODESIC_GRID_LENGTH = 20.0f;
static const double MAP_RESOLUTION = 0.1;
static const float INV_MAP_RESOLUTION = 10.0f;
static const double MAP_RESOLUTION = 5.0;
static const float INV_MAP_RESOLUTION = 0.2f;
} // namespace Map
namespace TrafficLight {
@ -134,8 +132,8 @@ static const std::vector<float> LATERAL_HIGHWAY_PARAM = {7.0f, 0.02f, 1.0f};
} // namespace PID
namespace TrackTraffic {
static const uint64_t BUFFER_STEP_THROUGH = 10;
static const float INV_BUFFER_STEP_THROUGH = 0.1f;
static const uint64_t BUFFER_STEP_THROUGH = 5;
static const float INV_BUFFER_STEP_THROUGH = 0.2f;
} // namespace TrackTraffic
} // namespace constants

View File

@ -13,6 +13,7 @@
#include "boost/geometry.hpp"
#include "boost/geometry/geometries/point.hpp"
#include "boost/geometry/index/rtree.hpp"
#include "carla/client/DebugHelper.h"
#include "carla/client/Map.h"
#include "carla/client/Waypoint.h"
@ -58,10 +59,7 @@ namespace bgi = boost::geometry::index;
/// sparse topology.
NodeList dense_topology;
/// Spatial quadratic R-tree for indexing and querying waypoints.
bgi::rtree<SpatialTreeEntry, bgi::quadratic<32>> rtree;
/// Geodesic grid topology.
std::unordered_map<GeoGridId, cg::Location> geodesic_grid_center;
bgi::rtree<SpatialTreeEntry, bgi::rstar<16>> rtree;
public:

View File

@ -47,7 +47,6 @@ void LocalizationStage::Update(const unsigned long index) {
if (buffer_map.find(actor_id) == buffer_map.end()) {
buffer_map.insert({actor_id, Buffer()});
}
Buffer &waypoint_buffer = buffer_map.at(actor_id);
// Clear buffer if vehicle is too far from the first waypoint in the buffer.
@ -154,20 +153,8 @@ void LocalizationStage::Update(const unsigned long index) {
uint64_t selection_index = 0u;
// Pseudo-randomized path selection if found more than one choice.
if (next_waypoints.size() > 1) {
// Arranging selection points from right to left.
std::sort(next_waypoints.begin(), next_waypoints.end(),
[&furthest_waypoint](const SimpleWaypointPtr &a, const SimpleWaypointPtr &b) {
float a_x_product = DeviationCrossProduct(furthest_waypoint->GetLocation(),
furthest_waypoint->GetForwardVector(),
a->GetLocation());
float b_x_product = DeviationCrossProduct(furthest_waypoint->GetLocation(),
furthest_waypoint->GetForwardVector(),
b->GetLocation());
return a_x_product < b_x_product;
});
double r_sample = random_devices.at(actor_id).next();
double s_bucket = 100.0 / next_waypoints.size();
selection_index = static_cast<uint64_t>(std::floor(r_sample/s_bucket));
selection_index = static_cast<uint64_t>(r_sample*next_waypoints.size()*0.01);
} else if (next_waypoints.size() == 0) {
if (!parameters.GetOSMMode()) {
std::cout << "This map has dead-end roads, please change the set_open_street_map parameter to true" << std::endl;

View File

@ -61,7 +61,7 @@ TargetWPInfo GetTargetWaypoint(const Buffer &waypoint_buffer, const float &targe
const SimpleWaypointPtr &buffer_front = waypoint_buffer.front();
uint64_t startPosn = static_cast<uint64_t>(std::fabs(target_point_distance * INV_MAP_RESOLUTION));
uint64_t index = 0;
/// Condition to determine forward or backward scanning of WayPoint Buffer.
/// Condition to determine forward or backward scanning of waypoint buffer.
if (startPosn < waypoint_buffer.size()) {
bool mScanForward = false;