51 {
53
54
55 std::map<std::int32_t, apollo::hdmap::LaneBoundaryType_Type>
63
64 obstacles.mutable_header()->CopyFrom(smartereye_obstacles.
header());
65
66
67 std::int32_t sma_left_lane_type =
69 std::int32_t sma_right_lane_type =
71
72 obstacles.mutable_lane_marker()->mutable_left_lane_marker()->set_lane_type(
73 lane_conversion_map[sma_left_lane_type]);
74 obstacles.mutable_lane_marker()->mutable_right_lane_marker()->set_lane_type(
75 lane_conversion_map[sma_right_lane_type]);
76
77 obstacles.mutable_lane_marker()->mutable_left_lane_marker()->set_quality(
80 obstacles.mutable_lane_marker()->mutable_left_lane_marker()
83
84
85 obstacles.mutable_lane_marker()->mutable_left_lane_marker()->set_c0_position(
88 obstacles.mutable_lane_marker()->mutable_left_lane_marker()
91 obstacles.mutable_lane_marker()->mutable_left_lane_marker()
94 obstacles.mutable_lane_marker()->mutable_left_lane_marker()
95 ->set_c3_curvature_derivative(
98
99
100
101
102 obstacles.mutable_lane_marker()->mutable_right_lane_marker()->set_quality(
105 obstacles.mutable_lane_marker()->mutable_right_lane_marker()
108 obstacles.mutable_lane_marker()->mutable_right_lane_marker()
111 obstacles.mutable_lane_marker()->mutable_right_lane_marker()
114 obstacles.mutable_lane_marker()->mutable_right_lane_marker()
117 obstacles.mutable_lane_marker()->mutable_right_lane_marker()
118 ->set_c3_curvature_derivative(
121
122
123
124
128
131
134 double adc_velocity =
Speed(adc_vx, adc_vy);
135
136 for (
int index = 0; index < smartereye_obstacles.
num_obstacles() &&
137 index < smartereye_obstacles.output_obstacles_size();
138 ++index) {
139 auto* sma = obstacles.add_perception_obstacle();
140 const auto& data_obstacle =
142 int sma_id = data_obstacle.trackid() + FLAGS_smartereye_id_offset;
143
144 double sma_x = data_obstacle.avgdistancez();
145 double sma_y = data_obstacle.real3dcenterx();
146 double sma_z = (data_obstacle.real3dupy() +
147 data_obstacle.real3dlowy()) / 2.0;
148
149 double sma_vel_x = data_obstacle.fuzzyrelativespeedz();
150 int sma_type = data_obstacle.obstacletype();
151
152 double sma_w = data_obstacle.real3drightx() - data_obstacle.real3dleftx();
153 double sma_l = data_obstacle.real3dlowy() - data_obstacle.real3dupy();
154
155 switch (sma_type) {
156 case 1:
157 case 6:
158 case 7: {
159 sma->set_type(PerceptionObstacle::VEHICLE);
160 break;
161 }
162 case 4:
163 case 5: {
164 sma->set_type(PerceptionObstacle::BICYCLE);
165 break;
166 }
167 case 2:
168 case 3: {
169 sma->set_type(PerceptionObstacle::PEDESTRIAN);
170 break;
171 }
172 default: {
173 sma->set_type(PerceptionObstacle::UNKNOWN);
174 break;
175 }
176 }
177
178 if (sma_l > FLAGS_max_mobileye_obstacle_length) {
180 }
181 if (sma_w > FLAGS_max_mobileye_obstacle_width) {
183 }
184
186
187
188 double converted_x = 0.0;
189 double converted_y = 0.0;
190 double converted_z = 0.0;
191 double converted_speed = 0.0;
192 double converted_vx = 0.0;
193 double converted_vy = 0.0;
194
195 double path_c1 = 0.0;
196 double path_c2 = 0.0;
197 double path_c3 = 0.0;
198
203 path_c3 =
205 } else {
208 path_c3 =
210 }
211
212 if (!FLAGS_use_navigation_mode) {
213 converted_x = adc_x + xy_point.x();
214 converted_y = adc_y + xy_point.y();
215 converted_z = adc_z + sma_z;
217 converted_speed = adc_velocity + sma_vel_x;
218 converted_vx = converted_speed * std::cos(sma->theta());
219 converted_vy = converted_speed * std::sin(sma->theta());
220 } else {
221 converted_x = data_obstacle.real3dcenterx() - sma_l / 2.0;
222 converted_y = sma_y;
223 converted_vx = sma_vel_x + chassis.
speed_mps();
224 converted_vy = 0.0;
225 converted_z = data_obstacle.avgdistancez();
226
227 double nearest_lane_heading =
228 converted_vx > 0
229 ? std::atan2(3 * path_c3 * converted_x * converted_x +
230 2 * path_c2 * converted_x + path_c1,
231 1)
232 :
std::atan2(3 * path_c3 * converted_x * converted_x +
233 2 * path_c2 * converted_x + path_c1,
234 1) +
235 M_PI;
236 AINFO <<
"nearest lane heading is" << nearest_lane_heading;
237 sma->set_theta(nearest_lane_heading);
238 }
239
240 sma->set_id(sma_id);
241 sma->mutable_position()->set_x(converted_x);
242 sma->mutable_position()->set_y(converted_y);
243 sma->mutable_position()->set_z(converted_z);
244
245 sma->mutable_velocity()->set_x(converted_vx);
246 sma->mutable_velocity()->set_y(converted_vy);
247 sma->set_length(sma_l);
248 sma->set_width(sma_w);
249 sma->set_height(FLAGS_default_height);
250
251 sma->clear_polygon_point();
252
253
255 sma->position().z(), sma->length(), sma->width(),
256 sma->height(), sma->theta());
257
258 sma->set_confidence(0.5);
259 }
260
261 return obstacles;
262}
apollo::common::Point3D Point
void FillPerceptionPolygon(PerceptionObstacle *const perception_obstacle, const double mid_x, const double mid_y, const double mid_z, const double length, const double width, const double height, const double heading)
double GetDefaultObjectLength(const int object_type)
double GetAngleFromQuaternion(const Quaternion quaternion)
Point SLtoXY(const Point &point, const double theta)
double GetNearestLaneHeading(const PointENU &point_enu)
double GetDefaultObjectWidth(const int object_type)
double Speed(const Point &point)
optional LdwRoadway roadway
optional double c1_heading_angle
optional double c3_curvature_derivative
optional double c2_curvature
optional double c0_position
optional LdwLaneBoundary left_boundary
optional LdwLaneStyle style
optional LdwLaneBoundary right_boundary
optional LdwLane right_lane
optional LdwLane left_lane
optional LdwDataPacks lane_road_data
map< uint32, OutputObstacle > output_obstacles
optional int32 num_obstacles
optional apollo::common::Header header
optional apollo::localization::Pose pose
optional apollo::common::Point3D linear_velocity
optional apollo::common::Quaternion orientation
optional apollo::common::PointENU position
optional double c3_curvature_derivative
optional double c2_curvature
optional double c1_heading_angle
optional LaneMarker right_lane_marker
optional LaneMarker left_lane_marker
optional LaneMarkers lane_marker