Removed all debug helper functions

This commit is contained in:
Jacopo Bartiromo 2021-05-13 11:18:57 +02:00 committed by Jacopo Bartiromo
parent 0002f0b478
commit 83f0a0097c
10 changed files with 10 additions and 66 deletions

View File

@ -22,7 +22,6 @@ CollisionStage::CollisionStage(
const TrackTraffic &track_traffic, const TrackTraffic &track_traffic,
const Parameters &parameters, const Parameters &parameters,
CollisionFrame &output_array, CollisionFrame &output_array,
cc::DebugHelper &debug_helper,
RandomGeneratorMap &random_devices) RandomGeneratorMap &random_devices)
: vehicle_id_list(vehicle_id_list), : vehicle_id_list(vehicle_id_list),
simulation_state(simulation_state), simulation_state(simulation_state),
@ -30,7 +29,6 @@ CollisionStage::CollisionStage(
track_traffic(track_traffic), track_traffic(track_traffic),
parameters(parameters), parameters(parameters),
output_array(output_array), output_array(output_array),
debug_helper(debug_helper),
random_devices(random_devices) {} random_devices(random_devices) {}
void CollisionStage::Update(const unsigned long index) { void CollisionStage::Update(const unsigned long index) {
@ -415,15 +413,5 @@ void CollisionStage::ClearCycleCache() {
geometry_cache.clear(); geometry_cache.clear();
} }
void CollisionStage::DrawBoundary(const LocationVector &boundary) {
cg::Location one_meter_up(0.0f, 0.0f, 1.0f);
for (uint64_t i = 0u; i < boundary.size(); ++i) {
debug_helper.DrawLine(
boundary[i] + one_meter_up,
boundary[i+1 == boundary.size()? 0: i+1] + one_meter_up,
0.1f, {255u, 255u, 0u}, 0.05f);
}
}
} // namespace traffic_manager } // namespace traffic_manager
} // namespace carla } // namespace carla

View File

@ -8,8 +8,6 @@
#include "boost/geometry/geometries/point_xy.hpp" #include "boost/geometry/geometries/point_xy.hpp"
#include "boost/geometry/geometries/polygon.hpp" #include "boost/geometry/geometries/polygon.hpp"
#include "carla/client/DebugHelper.h"
#include "carla/trafficmanager/DataStructures.h" #include "carla/trafficmanager/DataStructures.h"
#include "carla/trafficmanager/Parameters.h" #include "carla/trafficmanager/Parameters.h"
#include "carla/trafficmanager/RandomGenerator.h" #include "carla/trafficmanager/RandomGenerator.h"
@ -52,7 +50,6 @@ private:
const TrackTraffic &track_traffic; const TrackTraffic &track_traffic;
const Parameters &parameters; const Parameters &parameters;
CollisionFrame &output_array; CollisionFrame &output_array;
cc::DebugHelper &debug_helper;
// Structure keeping track of blocking lead vehicles. // Structure keeping track of blocking lead vehicles.
CollisionLockMap collision_locks; CollisionLockMap collision_locks;
// Structures to cache geodesic boundaries of vehicle and // Structures to cache geodesic boundaries of vehicle and
@ -93,7 +90,6 @@ public:
const TrackTraffic &track_traffic, const TrackTraffic &track_traffic,
const Parameters &parameters, const Parameters &parameters,
CollisionFrame &output_array, CollisionFrame &output_array,
cc::DebugHelper& debug_helper,
RandomGeneratorMap &random_devices); RandomGeneratorMap &random_devices);
void Update (const unsigned long index) override; void Update (const unsigned long index) override;

View File

@ -64,7 +64,7 @@ namespace traffic_manager {
return result; return result;
} }
void InMemoryMap::SetUp(cc::DebugHelper &debug_helper) { void InMemoryMap::SetUp() {
// 1. Building segment topology (i.e., defining set of segment predecessors and successors) // 1. Building segment topology (i.e., defining set of segment predecessors and successors)
assert(_world_map != nullptr && "No map reference found."); assert(_world_map != nullptr && "No map reference found.");
@ -162,14 +162,12 @@ namespace traffic_manager {
float distance = distance_squared(segment_waypoints.at(i)->GetLocation(), segment_waypoints.at(i+1)->GetLocation()); float distance = distance_squared(segment_waypoints.at(i)->GetLocation(), segment_waypoints.at(i+1)->GetLocation());
if (angle(segment_waypoints.at(i)->GetLocation(), segment_waypoints.at(i+1)->GetLocation()) > 0.12f) { // 7 deg if (angle(segment_waypoints.at(i)->GetLocation(), segment_waypoints.at(i+1)->GetLocation()) > 0.12f) { // 7 deg
debug_helper.DrawPoint(segment_waypoints.at(i)->GetLocation(), 0.15f, {0u, 0u, 255u}, 556.05f);
auto new_waypoint = segment_waypoints.at(i)->GetWaypoint()->GetNext(std::sqrt(distance)/2.0f).front(); auto new_waypoint = segment_waypoints.at(i)->GetWaypoint()->GetNext(std::sqrt(distance)/2.0f).front();
i++; i++;
segment_waypoints.insert(segment_waypoints.begin()+static_cast<int64_t>(i), std::make_shared<SimpleWaypoint>(new_waypoint)); segment_waypoints.insert(segment_waypoints.begin()+static_cast<int64_t>(i), std::make_shared<SimpleWaypoint>(new_waypoint));
} else if (distance > MAX_WPT_DISTANCE) { } else if (distance > MAX_WPT_DISTANCE) {
auto new_waypoint = segment_waypoints.at(i)->GetWaypoint()->GetNext(std::sqrt(distance)/2.0f).front(); auto new_waypoint = segment_waypoints.at(i)->GetWaypoint()->GetNext(std::sqrt(distance)/2.0f).front();
i++; i++;
debug_helper.DrawPoint(segment_waypoints.at(i)->GetLocation(), 0.15f, {0u, 255u, 255u}, 556.05f);
segment_waypoints.insert(segment_waypoints.begin()+static_cast<int64_t>(i), std::make_shared<SimpleWaypoint>(new_waypoint)); segment_waypoints.insert(segment_waypoints.begin()+static_cast<int64_t>(i), std::make_shared<SimpleWaypoint>(new_waypoint));
} }
} }
@ -209,7 +207,6 @@ namespace traffic_manager {
for (auto &simple_waypoint: dense_topology) { for (auto &simple_waypoint: dense_topology) {
if (simple_waypoint != nullptr) { if (simple_waypoint != nullptr) {
const cg::Location loc = simple_waypoint->GetLocation(); const cg::Location loc = simple_waypoint->GetLocation();
debug_helper.DrawPoint(loc, 0.1f, {255u, 0u, 0u}, 555.05f);
Point3D point(loc.x, loc.y, loc.z); Point3D point(loc.x, loc.y, loc.z);
rtree.insert(std::make_pair(point, simple_waypoint)); rtree.insert(std::make_pair(point, simple_waypoint));
} }

View File

@ -13,7 +13,6 @@
#include "boost/geometry.hpp" #include "boost/geometry.hpp"
#include "boost/geometry/geometries/point.hpp" #include "boost/geometry/geometries/point.hpp"
#include "boost/geometry/index/rtree.hpp" #include "boost/geometry/index/rtree.hpp"
#include "carla/client/DebugHelper.h"
#include "carla/client/Map.h" #include "carla/client/Map.h"
#include "carla/client/Waypoint.h" #include "carla/client/Waypoint.h"
@ -68,7 +67,7 @@ namespace bgi = boost::geometry::index;
/// This method constructs the local map with a resolution of /// This method constructs the local map with a resolution of
/// sampling_resolution. /// sampling_resolution.
void SetUp(cc::DebugHelper &debug_helper); void SetUp();
/// This method returns the closest waypoint to a given location on the map. /// This method returns the closest waypoint to a given location on the map.
SimpleWaypointPtr GetWaypoint(const cg::Location loc) const; SimpleWaypointPtr GetWaypoint(const cg::Location loc) const;

View File

@ -19,7 +19,6 @@ LocalizationStage::LocalizationStage(
Parameters &parameters, Parameters &parameters,
std::vector<ActorId>& marked_for_removal, std::vector<ActorId>& marked_for_removal,
LocalizationFrame &output_array, LocalizationFrame &output_array,
cc::DebugHelper &debug_helper,
RandomGeneratorMap &random_devices) RandomGeneratorMap &random_devices)
: vehicle_id_list(vehicle_id_list), : vehicle_id_list(vehicle_id_list),
buffer_map(buffer_map), buffer_map(buffer_map),
@ -29,7 +28,6 @@ LocalizationStage::LocalizationStage(
parameters(parameters), parameters(parameters),
marked_for_removal(marked_for_removal), marked_for_removal(marked_for_removal),
output_array(output_array), output_array(output_array),
debug_helper(debug_helper),
random_devices(random_devices) {} random_devices(random_devices) {}
void LocalizationStage::Update(const unsigned long index) { void LocalizationStage::Update(const unsigned long index) {
@ -404,21 +402,5 @@ SimpleWaypointPtr LocalizationStage::AssignLaneChange(const ActorId actor_id,
return change_over_point; return change_over_point;
} }
void LocalizationStage::DrawBuffer(Buffer &buffer) {
uint64_t buffer_size = buffer.size();
uint64_t step_size = std::max(buffer_size/20u, static_cast<uint64_t>(1));
cc::DebugHelper::Color color {0u, 0u, 0u};
cg::Location two_meters_up = cg::Location(0.0f, 0.0f, 2.0f);
for (uint64_t i = 0u; i + step_size < buffer_size; i += step_size) {
if (!buffer.at(i)->CheckJunction() && !buffer.at(i + step_size)->CheckJunction()) {
color.g = 255u;
}
debug_helper.DrawLine(buffer.at(i)->GetLocation() + two_meters_up,
buffer.at(i + step_size)->GetLocation() + two_meters_up,
0.2f, color, 0.05f);
color = {0u, 0u, 0u};
}
}
} // namespace traffic_manager } // namespace traffic_manager
} // namespace carla } // namespace carla

View File

@ -3,8 +3,6 @@
#include <memory> #include <memory>
#include "carla/client/DebugHelper.h"
#include "carla/trafficmanager/DataStructures.h" #include "carla/trafficmanager/DataStructures.h"
#include "carla/trafficmanager/InMemoryMap.h" #include "carla/trafficmanager/InMemoryMap.h"
#include "carla/trafficmanager/LocalizationUtils.h" #include "carla/trafficmanager/LocalizationUtils.h"
@ -37,7 +35,6 @@ private:
// Array of vehicles marked by stages for removal. // Array of vehicles marked by stages for removal.
std::vector<ActorId>& marked_for_removal; std::vector<ActorId>& marked_for_removal;
LocalizationFrame &output_array; LocalizationFrame &output_array;
cc::DebugHelper &debug_helper;
LaneChangeLocationMap last_lane_change_location; LaneChangeLocationMap last_lane_change_location;
ActorIdSet vehicles_at_junction; ActorIdSet vehicles_at_junction;
using SimpleWaypointPair = std::pair<SimpleWaypointPtr, SimpleWaypointPtr>; using SimpleWaypointPair = std::pair<SimpleWaypointPtr, SimpleWaypointPtr>;
@ -64,7 +61,6 @@ public:
Parameters &parameters, Parameters &parameters,
std::vector<ActorId>& marked_for_removal, std::vector<ActorId>& marked_for_removal,
LocalizationFrame &output_array, LocalizationFrame &output_array,
cc::DebugHelper &debug_helper,
RandomGeneratorMap &random_devices); RandomGeneratorMap &random_devices);
void Update(const unsigned long index) override; void Update(const unsigned long index) override;

View File

@ -29,8 +29,7 @@ MotionPlanStage::MotionPlanStage(
const CollisionFrame&collision_frame, const CollisionFrame&collision_frame,
const TLFrame &tl_frame, const TLFrame &tl_frame,
const cc::World &world, const cc::World &world,
ControlFrame &output_array, ControlFrame &output_array)
cc::DebugHelper &debug_helper)
: vehicle_id_list(vehicle_id_list), : vehicle_id_list(vehicle_id_list),
simulation_state(simulation_state), simulation_state(simulation_state),
parameters(parameters), parameters(parameters),
@ -44,8 +43,7 @@ MotionPlanStage::MotionPlanStage(
collision_frame(collision_frame), collision_frame(collision_frame),
tl_frame(tl_frame), tl_frame(tl_frame),
world(world), world(world),
output_array(output_array), output_array(output_array) {}
debug_helper(debug_helper) {}
void MotionPlanStage::Update(const unsigned long index) { void MotionPlanStage::Update(const unsigned long index) {
const ActorId actor_id = vehicle_id_list.at(index); const ActorId actor_id = vehicle_id_list.at(index);
@ -87,7 +85,6 @@ void MotionPlanStage::Update(const unsigned long index) {
TARGET_WAYPOINT_HORIZON_LENGTH); TARGET_WAYPOINT_HORIZON_LENGTH);
const SimpleWaypointPtr &target_waypoint = GetTargetWaypoint(waypoint_buffer, target_point_distance).first; const SimpleWaypointPtr &target_waypoint = GetTargetWaypoint(waypoint_buffer, target_point_distance).first;
const cg::Location target_location = target_waypoint->GetLocation(); const cg::Location target_location = target_waypoint->GetLocation();
debug_helper.DrawPoint(target_location + cg::Location(0,0,0.5), 0.2f, {0u, 255u, 0u}, .1f);
float dot_product = DeviationDotProduct(ego_location, ego_heading, target_location); float dot_product = DeviationDotProduct(ego_location, ego_heading, target_location);
float cross_product = DeviationCrossProduct(ego_location, ego_heading, target_location); float cross_product = DeviationCrossProduct(ego_location, ego_heading, target_location);
dot_product = 1.0f - dot_product; dot_product = 1.0f - dot_product;

View File

@ -11,8 +11,6 @@
#include "carla/trafficmanager/Stage.h" #include "carla/trafficmanager/Stage.h"
#include "carla/trafficmanager/TrackTraffic.h" #include "carla/trafficmanager/TrackTraffic.h"
#include "carla/client/DebugHelper.h"
namespace carla { namespace carla {
namespace traffic_manager { namespace traffic_manager {
@ -38,7 +36,6 @@ private:
// in hybrid physics mode. // in hybrid physics mode.
std::unordered_map<ActorId, cc::Timestamp> teleportation_instance; std::unordered_map<ActorId, cc::Timestamp> teleportation_instance;
ControlFrame &output_array; ControlFrame &output_array;
cc::DebugHelper debug_helper;
cc::Timestamp current_timestamp; cc::Timestamp current_timestamp;
std::pair<bool, float> CollisionHandling(const CollisionHazardData &collision_hazard, std::pair<bool, float> CollisionHandling(const CollisionHazardData &collision_hazard,
@ -65,8 +62,7 @@ public:
const CollisionFrame &collision_frame, const CollisionFrame &collision_frame,
const TLFrame &tl_frame, const TLFrame &tl_frame,
const cc::World &world, const cc::World &world,
ControlFrame &output_array, ControlFrame &output_array);
cc::DebugHelper &debug_helper);
void Update(const unsigned long index); void Update(const unsigned long index);

View File

@ -31,7 +31,6 @@ TrafficManagerLocal::TrafficManagerLocal(
episode_proxy(episode_proxy), episode_proxy(episode_proxy),
world(cc::World(episode_proxy)), world(cc::World(episode_proxy)),
debug_helper(world.MakeDebugHelper()),
localization_stage(LocalizationStage(vehicle_id_list, localization_stage(LocalizationStage(vehicle_id_list,
buffer_map, buffer_map,
@ -41,7 +40,6 @@ TrafficManagerLocal::TrafficManagerLocal(
parameters, parameters,
marked_for_removal, marked_for_removal,
localization_frame, localization_frame,
debug_helper,
random_devices)), random_devices)),
collision_stage(CollisionStage(vehicle_id_list, collision_stage(CollisionStage(vehicle_id_list,
@ -50,7 +48,6 @@ TrafficManagerLocal::TrafficManagerLocal(
track_traffic, track_traffic,
parameters, parameters,
collision_frame, collision_frame,
debug_helper,
random_devices)), random_devices)),
traffic_light_stage(TrafficLightStage(vehicle_id_list, traffic_light_stage(TrafficLightStage(vehicle_id_list,
@ -74,8 +71,7 @@ TrafficManagerLocal::TrafficManagerLocal(
collision_frame, collision_frame,
tl_frame, tl_frame,
world, world,
control_frame, control_frame)),
debug_helper)),
alsm(ALSM(registered_vehicles, alsm(ALSM(registered_vehicles,
buffer_map, buffer_map,
@ -97,7 +93,7 @@ TrafficManagerLocal::TrafficManagerLocal(
registered_vehicles_state = -1; registered_vehicles_state = -1;
SetupLocalMap(debug_helper); SetupLocalMap();
Start(); Start();
} }
@ -107,10 +103,10 @@ TrafficManagerLocal::~TrafficManagerLocal() {
Release(); Release();
} }
void TrafficManagerLocal::SetupLocalMap(cc::DebugHelper &debug_helper) { void TrafficManagerLocal::SetupLocalMap() {
const carla::SharedPtr<cc::Map> world_map = world.GetMap(); const carla::SharedPtr<cc::Map> world_map = world.GetMap();
local_map = std::make_shared<InMemoryMap>(world_map); local_map = std::make_shared<InMemoryMap>(world_map);
local_map->SetUp(debug_helper); local_map->SetUp();
} }
void TrafficManagerLocal::Start() { void TrafficManagerLocal::Start() {

View File

@ -12,7 +12,6 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "carla/client/DebugHelper.h"
#include "carla/client/detail/EpisodeProxy.h" #include "carla/client/detail/EpisodeProxy.h"
#include "carla/client/TrafficLight.h" #include "carla/client/TrafficLight.h"
#include "carla/client/World.h" #include "carla/client/World.h"
@ -71,8 +70,6 @@ private:
LocalMapPtr local_map; LocalMapPtr local_map;
/// Structures to hold waypoint buffers for all vehicles. /// Structures to hold waypoint buffers for all vehicles.
BufferMap buffer_map; BufferMap buffer_map;
/// Carla's debug helper object.
cc::DebugHelper debug_helper;
/// Object for tracking paths of the traffic vehicles. /// Object for tracking paths of the traffic vehicles.
TrackTraffic track_traffic; TrackTraffic track_traffic;
/// Type containing the current state of all actors involved in the simulation. /// Type containing the current state of all actors involved in the simulation.
@ -136,7 +133,7 @@ public:
virtual ~TrafficManagerLocal(); virtual ~TrafficManagerLocal();
/// Method to setup InMemoryMap. /// Method to setup InMemoryMap.
void SetupLocalMap(cc::DebugHelper &debug_helper); void SetupLocalMap();
/// To start the TrafficManager. /// To start the TrafficManager.
void Start(); void Start();