Apollo 11.0
自动驾驶开放平台
dummy_algorithms.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
17
19
20namespace apollo {
21namespace perception {
22namespace radar {
23
24void DummyDetector::ContiObs2Frame(
25 const drivers::ContiRadar& corrected_obstacles,
26 base::FramePtr radar_frame) {
27 for (const auto& radar_obs : corrected_obstacles.contiobs()) {
28 base::ObjectPtr radar_object(new base::Object);
29 radar_object->id = radar_obs.obstacle_id();
30 radar_object->track_id = radar_obs.obstacle_id();
31 radar_object->center(0) = radar_obs.longitude_dist();
32 radar_object->center(1) = radar_obs.lateral_dist();
33 radar_object->center(2) = 0.0;
34 radar_object->anchor_point = radar_object->center;
35
36 radar_object->velocity(0) = static_cast<float>(radar_obs.longitude_vel());
37 radar_object->velocity(1) = static_cast<float>(radar_obs.lateral_vel());
38 radar_object->velocity(2) = 0.0f;
39
40 Eigen::Matrix3d dist_rms;
41 dist_rms.setZero();
42 Eigen::Matrix3d vel_rms;
43 vel_rms.setZero();
44 dist_rms(0, 0) = radar_obs.longitude_dist_rms();
45 dist_rms(1, 1) = radar_obs.lateral_dist_rms();
46 vel_rms(0, 0) = radar_obs.longitude_vel_rms();
47 vel_rms(1, 1) = radar_obs.lateral_vel_rms();
48 radar_object->center_uncertainty =
49 (dist_rms * dist_rms.transpose()).cast<float>();
50 radar_object->velocity_uncertainty =
51 (vel_rms * vel_rms.transpose()).cast<float>();
52
53 double local_obj_theta = radar_obs.oritation_angle() / 180.0 * PI;
54 Eigen::Vector3d direction(cos(local_obj_theta), sin(local_obj_theta), 0);
55 radar_object->direction = direction.cast<float>();
56 radar_object->theta =
57 static_cast<float>(std::atan2(direction(1), direction(0)));
58 radar_object->theta_variance =
59 static_cast<float>(radar_obs.oritation_angle_rms() / 180.0 * PI);
60 radar_object->size(0) = static_cast<float>(radar_obs.length());
61 radar_object->size(1) = static_cast<float>(radar_obs.width());
62 radar_object->confidence = static_cast<float>(radar_obs.probexist());
63
64 int cls = radar_obs.obstacle_class();
65 if (cls == CONTI_CAR || cls == CONTI_TRUCK) {
66 radar_object->type = base::ObjectType::VEHICLE;
67 } else if (cls == CONTI_PEDESTRIAN) {
68 radar_object->type = base::ObjectType::PEDESTRIAN;
69 } else if (cls == CONTI_MOTOCYCLE || cls == CONTI_BICYCLE) {
70 radar_object->type = base::ObjectType::BICYCLE;
71 } else {
72 radar_object->type = base::ObjectType::UNKNOWN;
73 }
74 radar_frame->objects.push_back(radar_object);
75 }
76}
77
79 return true;
80}
81
83 const PreprocessorOptions& options,
84 drivers::ContiRadar* corrected_obstacles) {
85 if (corrected_obstacles == nullptr) {
86 AERROR << "corrected_obstacles is not available";
87 return false;
88 }
89 *corrected_obstacles = raw_obstacles;
90 return true;
91}
92
93std::string DummyPreprocessor::Name() const { return "DummyPreprocessor"; }
94
95bool DummyDetector::Init(const DetectorInitOptions& options) { return true; }
96
97bool DummyDetector::Detect(const drivers::ContiRadar& corrected_obstacles,
98 const DetectorOptions& options,
99 base::FramePtr detected_frame) {
100 ContiObs2Frame(corrected_obstacles, detected_frame);
101 return true;
102}
103
104std::string DummyDetector::Name() const { return "DummyDetector"; }
105
106bool DummyRoiFilter::Init(const RoiFilterInitOptions& options) { return true; }
107
109 base::FramePtr radar_frame) {
110 return true;
111}
112std::string DummyRoiFilter::Name() const { return "DummyRoiFilter"; }
113
117
118} // namespace radar
119} // namespace perception
120} // namespace apollo
bool Init(const DetectorInitOptions &options) override
Dummy Init
bool Detect(const drivers::ContiRadar &corrected_obstacles, const DetectorOptions &options, base::FramePtr detected_frame) override
Dummy detect
std::string Name() const override
The name of the DummyDetector
std::string Name() const override
The name of the DummyPreprocessor
bool Init(const PreprocessorInitOptions &options) override
Dummy Init
bool Preprocess(const drivers::ContiRadar &raw_obstacles, const PreprocessorOptions &options, drivers::ContiRadar *corrected_obstacles) override
Dummy preprocess
std::string Name() const override
The name of the DummyRoiFilter
bool RoiFilter(const RoiFilterOptions &options, base::FramePtr radar_frame) override
Dummy roi filter
bool Init(const RoiFilterInitOptions &options) override
Dummy Init
#define AERROR
Definition log.h:44
float cos(Angle16 a)
Definition angle.cc:42
float sin(Angle16 a)
Definition angle.cc:25
std::shared_ptr< Object > ObjectPtr
Definition object.h:127
std::shared_ptr< Frame > FramePtr
Definition frame.h:60
const double PI
Definition types.h:22
class register implement
Definition arena_queue.h:37
#define PERCEPTION_REGISTER_DETECTOR(name)
#define PERCEPTION_REGISTER_PREPROCESSOR(name)
#define PERCEPTION_REGISTER_ROI_FILTER(name)