File size: 2,445 Bytes
3624d0b
 
 
 
 
 
 
 
 
 
 
2206380
 
 
 
 
 
 
 
 
 
3624d0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2206380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3624d0b
 
 
 
 
 
 
 
 
2206380
 
 
 
 
 
 
3624d0b
 
 
 
2206380
 
 
 
 
 
 
 
3624d0b
 
2206380
 
3624d0b
 
2206380
 
3624d0b
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#pragma once

#include "decoder.hpp"

#include <array>
#include <cstddef>
#include <string>
#include <vector>

namespace rclane {

enum class BevMode {
    Raw,
    Trigger,
    AlwaysParallel,
    CompleteFour,
};

const char* bev_mode_name(BevMode mode);
BevMode parse_bev_mode(const std::string& value);

struct GroundPoint {
    double x{};
    double y{};
    double score{};
};

struct CubicFit {
    std::array<double, 4> coefficients{};
    double x_min{};
    double x_max{};
    double rmse{};
    std::size_t point_count{};
    std::size_t inlier_count{};
    bool valid{};
};

struct BevLane {
    int lane_id{};
    std::string role;
    double score{};
    std::vector<GroundPoint> points;
    CubicFit fit;
    bool fit_accepted{};
    bool funnel_clipped{};
    bool parallel_repaired{};
    bool synthetic{};
    bool has_source_fit{};
    CubicFit source_fit;
    int parallel_reference_lane{-1};
    double parallel_offset_m{};
    std::string parallel_repair_method;
};

struct BevTopologyReport {
    BevMode mode{BevMode::Raw};
    bool applied{};
    bool forced{};
    bool validation_passed{true};
    bool funnel_bypassed{};
    int reference_lane{-1};
    double reference_score{};
    double lane_width_m{3.5};
    std::string activation{"disabled"};
    std::string lane_width_source{"nominal"};
    std::string reference_selection;
    std::string method;
    std::string failure;
    std::vector<std::string> trigger_pairs;
    std::vector<int> synthetic_lane_ids;
};

struct BevConfig {
    double x_min{0.0};
    double x_max{300.0};
    double y_min{-85.0};
    double y_max{85.0};
    double maximum_rmse{0.5};
    double funnel_margin{0.10};
    BevMode mode{BevMode::Raw};
    double nominal_lane_width{3.5};
    double trigger_gap_ratio{0.55};
    double minimum_gap{1.0};
    double minimum_bad_run{4.0};
    double sample_step{0.5};
    double maximum_reference_extrapolation{2.0};
};

std::vector<BevLane> project_lanes_to_bev(
    const std::vector<Lane>& lanes,
    const BevConfig& config = {},
    BevTopologyReport* topology = nullptr
);

void apply_bev_mode(
    std::vector<BevLane>& lanes,
    const BevConfig& config,
    BevTopologyReport* topology = nullptr
);

std::string bev_topology_json(const BevTopologyReport& topology);

void write_bev_json(
    const std::string& path,
    const std::vector<BevLane>& lanes,
    const BevTopologyReport* topology = nullptr
);

}  // namespace rclane