Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
MidpointGenerator Class Reference

Generates midpoints between cones using Delaunay triangulation. More...

#include <midpoint_generator.hpp>

Collaboration diagram for MidpointGenerator:
Collaboration graph

Public Member Functions

 MidpointGenerator ()=default
 Default constructor.
 
 MidpointGenerator (const MidpointGeneratorConfig &config)
 Constructs a new MidpointGenerator with a specific configuration.
 
std::vector< std::shared_ptr< Midpoint > > & generate_midpoints (const std::vector< Cone > &cone_array, bool rebuild_all_midpoints)
 Generates midpoints from a set of cones.
 
const std::vector< std::pair< Point, Point > > & get_triangulations () const
 Returns the current set of Delaunay edges used for visualization.
 
void set_vehicle_pose (const Pose &vehicle_pose)
 Updates the vehicle pose for dynamic filtering.
 

Private Member Functions

void filter_cones (const std::vector< Cone > &cone_array, std::vector< std::shared_ptr< Cone > > &filtered_cones, bool rebuild_all_midpoints)
 Filters input cones based on proximity to the vehicle pose.
 
std::shared_ptr< Midpointprocess_triangle_edge (const Vertex_handle &va, const Vertex_handle &vb, std::vector< std::shared_ptr< Cone > > &filtered_cones, std::map< std::pair< int, int >, std::shared_ptr< Midpoint > > &segment_to_midpoint)
 Processes a single edge of a Delaunay triangle and creates its midpoint if valid.
 
void connect_triangle_midpoints (const std::array< std::shared_ptr< Midpoint >, 3 > &triangle_midpoints)
 Connects midpoints that belong to the same Delaunay triangle.
 
int find_cone (std::vector< std::shared_ptr< Cone > > &cones, double x, double y)
 Finds a cone in a vector based on its position coordinates.
 

Private Attributes

std::vector< std::pair< Point, Point > > triangulations_
 
Pose vehicle_pose_
 
std::vector< std::shared_ptr< Midpoint > > midpoints_
 
MidpointGeneratorConfig config_
 

Detailed Description

Generates midpoints between cones using Delaunay triangulation.

The algorithm performs the following main steps:

  • Filters cones using a sliding window based on the vehicle’s position (if enabled).
  • Builds a Delaunay triangulation from the cone coordinates.
  • Creates midpoints for valid cone pairs (within configured distance limits).
  • Connects midpoints belonging to the same triangle.

Definition at line 34 of file midpoint_generator.hpp.

Constructor & Destructor Documentation

◆ MidpointGenerator() [1/2]

MidpointGenerator::MidpointGenerator ( )
default

Default constructor.

◆ MidpointGenerator() [2/2]

MidpointGenerator::MidpointGenerator ( const MidpointGeneratorConfig config)
inlineexplicit

Constructs a new MidpointGenerator with a specific configuration.

Parameters
configConfiguration object defining thresholds and filtering behavior.

Definition at line 46 of file midpoint_generator.hpp.

Member Function Documentation

◆ connect_triangle_midpoints()

void MidpointGenerator::connect_triangle_midpoints ( const std::array< std::shared_ptr< Midpoint >, 3 > &  triangle_midpoints)
private

Connects midpoints that belong to the same Delaunay triangle.

Parameters
triangle_midpointsArray of up to three midpoints from one triangle.

Definition at line 110 of file midpoint_generator.cpp.

Here is the caller graph for this function:

◆ filter_cones()

void MidpointGenerator::filter_cones ( const std::vector< Cone > &  cone_array,
std::vector< std::shared_ptr< Cone > > &  filtered_cones,
bool  rebuild_all_midpoints 
)
private

Filters input cones based on proximity to the vehicle pose.

Parameters
cone_arrayInput array of detected cones.
filtered_conesOutput vector containing cones after filtering.
rebuild_all_midpointsWhether to reset filtering and include all cones.

Definition at line 44 of file midpoint_generator.cpp.

Here is the caller graph for this function:

◆ find_cone()

int MidpointGenerator::find_cone ( std::vector< std::shared_ptr< Cone > > &  cones,
double  x,
double  y 
)
private

Finds a cone in a vector based on its position coordinates.

Parameters
conesReference to a vector of shared pointers to Cone objects.
xThe x-coordinate of the cone to find.
yThe y-coordinate of the cone to find.
Returns
The index of the cone with the matching position, or -1 if not found.

Definition at line 133 of file midpoint_generator.cpp.

Here is the caller graph for this function:

◆ generate_midpoints()

std::vector< std::shared_ptr< Midpoint > > & MidpointGenerator::generate_midpoints ( const std::vector< Cone > &  cone_array,
bool  rebuild_all_midpoints 
)

Generates midpoints from a set of cones.

This method filters cones (if enabled), computes the Delaunay triangulation, and generates valid midpoints between cone pairs that meet distance constraints.

Parameters
cone_arrayInput vector of cone objects.
rebuild_all_midpointsWhether to use all cones
Returns
Reference to the vector containing all generated midpoints.

Definition at line 3 of file midpoint_generator.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_triangulations()

const std::vector< std::pair< Point, Point > > & MidpointGenerator::get_triangulations ( ) const

Returns the current set of Delaunay edges used for visualization.

Returns
A const reference to the vector of triangulated edges.

Definition at line 125 of file midpoint_generator.cpp.

Here is the caller graph for this function:

◆ process_triangle_edge()

std::shared_ptr< Midpoint > MidpointGenerator::process_triangle_edge ( const Vertex_handle va,
const Vertex_handle vb,
std::vector< std::shared_ptr< Cone > > &  filtered_cones,
std::map< std::pair< int, int >, std::shared_ptr< Midpoint > > &  segment_to_midpoint 
)
private

Processes a single edge of a Delaunay triangle and creates its midpoint if valid.

This function verifies the corresponding cones for the edge, checks distance constraints, and either creates a new midpoint or reuses an existing one to prevent duplication.

Parameters
vaFirst vertex of the triangle edge.
vbSecond vertex of the triangle edge.
filtered_conesVector of all filtered cones.
segment_to_midpointMap used to ensure unique midpoint creation per cone pair.
Returns
A shared pointer to the created or existing midpoint, or nullptr if invalid.

Definition at line 69 of file midpoint_generator.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_vehicle_pose()

void MidpointGenerator::set_vehicle_pose ( const Pose vehicle_pose)

Updates the vehicle pose for dynamic filtering.

This pose is used to center the sliding window for filtering relevant cones.

Parameters
vehicle_poseThe current vehicle pose.

Definition at line 129 of file midpoint_generator.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ config_

MidpointGeneratorConfig MidpointGenerator::config_
private

Definition at line 87 of file midpoint_generator.hpp.

◆ midpoints_

std::vector<std::shared_ptr<Midpoint> > MidpointGenerator::midpoints_
private

Definition at line 85 of file midpoint_generator.hpp.

◆ triangulations_

std::vector<std::pair<Point, Point> > MidpointGenerator::triangulations_
private

Definition at line 79 of file midpoint_generator.hpp.

◆ vehicle_pose_

Pose MidpointGenerator::vehicle_pose_
private

Definition at line 82 of file midpoint_generator.hpp.


The documentation for this class was generated from the following files: