4 std::vector<PathPoint>& yellow_cones,
5 std::vector<PathPoint>& blue_cones) {
7 if (colorpoints.size() < 2) {
11 for (
size_t i = 0; i < colorpoints.size() - 1; i++) {
12 color_cones(colorpoints[i], colorpoints[i + 1], yellow_cones, blue_cones);
20 std::vector<PathPoint>& yellow_cones,
21 std::vector<PathPoint>& blue_cones) {
23 double path_dx = next_colorpoint.
point.x() - colorpoint.
point.x();
24 double path_dy = next_colorpoint.
point.y() - colorpoint.
point.y();
35 double cross_product1 = path_dx * cone1_dy - path_dy * cone1_dx;
36 double cross_product2 = path_dx * cone2_dy - path_dy * cone2_dx;
39 if (cross_product1 > cross_product2) {
48 std::vector<PathPoint>& yellow_cones,
49 std::vector<PathPoint>& blue_cones) {
50 if (reference_cone.
color == Color::BLUE) {
58 std::vector<PathPoint>& yellow_cones,
59 std::vector<PathPoint>& blue_cones) {
60 const Colorpoint& second_to_last = colorpoints[colorpoints.size() - 2];
66 }
else if (second_to_last.
cone1 == last.
cone2) {
68 }
else if (second_to_last.
cone2 == last.
cone1) {
70 }
else if (second_to_last.
cone2 == last.
cone2) {
73 RCLCPP_WARN(rclcpp::get_logger(
"planning"),
74 "The last cone does not match with any previous cone.");
79 std::vector<PathPoint>& yellow_cones,
80 std::vector<PathPoint>& blue_cones) {
81 yellow_cone.
color = Color::YELLOW;
82 blue_cone.
color = Color::BLUE;
Path point with two boundary cones, provides cone classification into left/right boundaries.
Point point
The path point (midpoint between cones).
static void color_pair_of_cones(Cone &yellow_cone, Cone &blue_cone, std::vector< PathPoint > &yellow_cones, std::vector< PathPoint > &blue_cones)
Assigns colors to a cone pair and appends them to the output vectors.
static void add_cones_by_reference(const Cone &reference_cone, Cone &matching_cone, Cone &other_cone, std::vector< PathPoint > &yellow_cones, std::vector< PathPoint > &blue_cones)
Classifies a cone pair using a reference cone whose color is already known.
static void extract_cones(std::vector< Colorpoint > &colorpoints, std::vector< PathPoint > &yellow_cones, std::vector< PathPoint > &blue_cones)
Extracts and classifies all cones from a sequence of colorpoints.
Cone cone2
Second cone associated with this path point.
static void color_last_point(std::vector< Colorpoint > &colorpoints, std::vector< PathPoint > &yellow_cones, std::vector< PathPoint > &blue_cones)
Classifies the cones of the last colorpoint using a shared cone from the previous one.
Cone cone1
First cone associated with this path point.
static void color_cones(Colorpoint &colorpoint, const Colorpoint &next_colorpoint, std::vector< PathPoint > &yellow_cones, std::vector< PathPoint > &blue_cones)
Classifies the cones of a single colorpoint using the direction to the next point.
common_lib::competition_logic::Color color