27constexpr double kMaxFollow = 100.0;
28constexpr double kMaxOvertake = 100.0;
29constexpr double kMaxStop = 60.0;
30constexpr double kMaxNudge = 60.0;
31constexpr double kMaxNudgeLateralDistance = 10.0;
32constexpr double kMaxSidePassDistance = 100.0;
51void AutotuningSpeedMLPModel::FlattenFeatures(
53 Eigen::MatrixXd*
const flat_feature)
const {
54 int row_count = feature.point_feature_size();
56 flat_feature->resize(row_count, col_count);
58 for (
int i = 0; i < row_count; ++i) {
64void AutotuningSpeedMLPModel::FlattenFeatures(
65 const autotuning::SpeedPointwiseFeature& speed_point_feature,
const int row,
66 Eigen::MatrixXd*
const flat_feature)
const {
67 double v = speed_point_feature.v();
68 double acc = speed_point_feature.acc();
69 double jerk = speed_point_feature.jerk();
70 double speed_limit = speed_point_feature.speed_limit();
72 double lateral_acc = speed_point_feature.lateral_acc();
74 double collision = 0.0;
76 double follow_distance = kMaxFollow;
77 double follow_v_rel = 0.0;
78 double overtake_distance = kMaxOvertake;
79 double overtake_v_rel = 0.0;
80 double stop_distance = kMaxStop;
81 double stop_v_rel = 0.0;
82 double virtual_distance = kMaxStop;
83 double virtual_v_rel = 0.0;
84 double nudge_distance = kMaxNudge;
85 double nudge_v_rel = 0.0;
86 double nudge_lateral_distance = kMaxNudgeLateralDistance;
87 double sidepass_front_v_rel = 0.0;
88 double sidepass_front_distance = kMaxSidePassDistance;
89 double sidepass_rear_v_rel = 0.0;
90 double sidepass_rear_distance = kMaxSidePassDistance;
93 for (
int i = 0; i < speed_point_feature.follow_obs_feature_size(); ++i) {
94 const auto& follow_obs_feature = speed_point_feature.follow_obs_feature(i);
95 if (follow_distance > follow_obs_feature.longitudinal_distance()) {
96 follow_distance = follow_obs_feature.longitudinal_distance();
97 follow_v_rel = follow_obs_feature.relative_v();
101 for (
int i = 0; i < speed_point_feature.overtake_obs_feature_size(); ++i) {
102 const auto& overtake_obs_feature =
103 speed_point_feature.overtake_obs_feature(i);
104 if (overtake_distance > overtake_obs_feature.longitudinal_distance()) {
105 overtake_distance = overtake_obs_feature.longitudinal_distance();
106 overtake_v_rel = overtake_obs_feature.relative_v();
110 for (
int i = 0; i < speed_point_feature.stop_obs_feature_size(); ++i) {
111 const auto& stop_obs_feature = speed_point_feature.stop_obs_feature(i);
112 if (stop_distance > stop_obs_feature.longitudinal_distance()) {
113 stop_distance = stop_obs_feature.longitudinal_distance();
114 stop_v_rel = stop_obs_feature.relative_v();
118 for (
int i = 0; i < speed_point_feature.virtual_obs_feature_size(); ++i) {
119 const auto& virtual_obs_feature =
120 speed_point_feature.virtual_obs_feature(i);
121 if (virtual_distance > virtual_obs_feature.longitudinal_distance()) {
122 virtual_distance = virtual_obs_feature.longitudinal_distance();
123 virtual_v_rel = virtual_obs_feature.relative_v();
127 for (
int i = 0; i < speed_point_feature.nudge_obs_feature_size(); ++i) {
128 const auto& nudge_obs_feature = speed_point_feature.nudge_obs_feature(i);
129 if (nudge_distance > nudge_obs_feature.longitudinal_distance()) {
130 nudge_distance = nudge_obs_feature.longitudinal_distance();
131 nudge_v_rel = nudge_obs_feature.relative_v();
132 nudge_lateral_distance = nudge_obs_feature.lateral_distance();
136 for (
int i = 0; i < speed_point_feature.sidepass_front_obs_feature_size();
138 const auto& sidepass_front_obs_feature =
139 speed_point_feature.sidepass_front_obs_feature(i);
140 if (sidepass_front_distance >
141 sidepass_front_obs_feature.longitudinal_distance()) {
142 sidepass_front_distance =
143 sidepass_front_obs_feature.longitudinal_distance();
144 sidepass_front_v_rel = sidepass_front_obs_feature.relative_v();
148 for (
int i = 0; i < speed_point_feature.sidepass_rear_obs_feature_size();
150 const auto& sidepass_rear_obs_feature =
151 speed_point_feature.sidepass_rear_obs_feature(i);
152 if (sidepass_rear_distance >
153 sidepass_rear_obs_feature.longitudinal_distance()) {
154 sidepass_rear_distance =
155 sidepass_rear_obs_feature.longitudinal_distance();
156 sidepass_rear_v_rel = sidepass_rear_obs_feature.relative_v();
160 (*flat_feature)(row, 0) = v;
161 (*flat_feature)(row, 1) = speed_limit;
162 (*flat_feature)(row, 2) = acc;
163 (*flat_feature)(row, 3) = jerk;
164 (*flat_feature)(row, 4) = lateral_acc;
165 (*flat_feature)(row, 5) = collision;
166 (*flat_feature)(row, 6) = follow_distance;
167 (*flat_feature)(row, 7) = follow_v_rel;
168 (*flat_feature)(row, 8) = overtake_distance;
169 (*flat_feature)(row, 9) = overtake_v_rel;
170 (*flat_feature)(row, 10) = nudge_distance;
171 (*flat_feature)(row, 11) = nudge_v_rel;
172 (*flat_feature)(row, 12) = nudge_lateral_distance;
173 (*flat_feature)(row, 13) = stop_distance;
174 (*flat_feature)(row, 14) = stop_v_rel;
175 (*flat_feature)(row, 15) = virtual_distance;
176 (*flat_feature)(row, 16) = virtual_v_rel;
177 (*flat_feature)(row, 17) = sidepass_front_distance;
178 (*flat_feature)(row, 18) = sidepass_front_v_rel;
179 (*flat_feature)(row, 19) = sidepass_rear_distance;
180 (*flat_feature)(row, 20) = sidepass_rear_v_rel;
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
std::unique_ptr< AutotuningMLPModel > mlp_model_
: stored autotuning mlp model
std::unique_ptr< AutotuningFeatureBuilder > feature_builder_
: build the mlp cost functional for speed profile based on trajectory raw feature
double Evaluate(const autotuning::TrajectoryFeature &trajectory_feature) const override
: evaluate by trajectory
common::Status SetParams() override
set mlp model as well as feature builder
Planning module main class.
repeated TrajectoryPointwiseFeature point_feature
optional SpeedPointwiseFeature speed_input_feature