From e632d3abec077e5b32ff66b46de0e482f94f53d8 Mon Sep 17 00:00:00 2001 From: Zhang Liangliang Date: Thu, 20 Jul 2017 14:53:03 -0700 Subject: [PATCH] added perception_proxy. --- modules/planning/proxy/BUILD | 27 +++++++++-- modules/planning/proxy/perception_proxy.cc | 52 ++++++++++++++++++++++ modules/planning/proxy/perception_proxy.h | 48 ++++++++++++++++++++ 3 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 modules/planning/proxy/perception_proxy.cc create mode 100644 modules/planning/proxy/perception_proxy.h diff --git a/modules/planning/proxy/BUILD b/modules/planning/proxy/BUILD index 8f07e5a3c8..6856b8dfab 100644 --- a/modules/planning/proxy/BUILD +++ b/modules/planning/proxy/BUILD @@ -3,13 +3,32 @@ package(default_visibility = ["//visibility:public"]) load("//tools:cpplint.bzl", "cpplint") cc_library( - name = "proxy", + name = "perception_proxy", + srcs = [ + "perception_proxy.cc", + ], + hdrs = [ + "perception_proxy.h", + ], + deps = [ + "//external:gflags", + "//modules/common/math", + "//modules/common/status", + "//modules/common/util", + "//modules/map/proto:map_proto", + "//modules/perception/proto:perception_proto", + "//modules/planning/common:planning_gflags", + ], +) + +cc_library( + name = "routing_proxy", srcs = [ "routing_proxy.cc", ], - hdrs = glob([ - "*.h", - ]), + hdrs = [ + "routing_proxy.h", + ], data = ["//modules/map:map_data"], deps = [ "//external:gflags", diff --git a/modules/planning/proxy/perception_proxy.cc b/modules/planning/proxy/perception_proxy.cc new file mode 100644 index 0000000000..89514f3c04 --- /dev/null +++ b/modules/planning/proxy/perception_proxy.cc @@ -0,0 +1,52 @@ +/****************************************************************************** + * Copyright 2017 The Apollo Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + +/** + * @file perception_proxy.cc + **/ + +#include "modules/planning/proxy/perception_proxy.h" + +#include "modules/planning/common/planning_gflags.h" + +namespace apollo { +namespace planning { + +void PerceptionProxy::add_perception_obstacles( + const apollo::perception::PerceptionObstacles& perception_obstacles) { + if (_perception_frame.size() > + static_cast(FLAGS_max_frame_size)) { + _perception_frame.pop_front(); + } + _perception_frame.emplace_back(std::move(perception_obstacles)); + return; +} + +apollo::perception::PerceptionObstacles* +PerceptionProxy::get_latest_perception_frame() { + if (_perception_frame.size() == 0) { + return nullptr; + } + return &(*(_perception_frame.rbegin())); +} + +const std::list& +PerceptionProxy::perception_frame() const { + return _perception_frame; +} + +} // namespace planning +} // namespace apollo diff --git a/modules/planning/proxy/perception_proxy.h b/modules/planning/proxy/perception_proxy.h new file mode 100644 index 0000000000..d8512d4b14 --- /dev/null +++ b/modules/planning/proxy/perception_proxy.h @@ -0,0 +1,48 @@ +/****************************************************************************** + * Copyright 2017 The Apollo Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + +/** + * @file perception_proxy.h + **/ + +#ifndef MODULES_PLANNING_PROXY_PERCEPTION_PROXY_H_ +#define MODULES_PLANNING_PROXY_PERCEPTION_PROXY_H_ + +#include + +#include "modules/common/proto/error_code.pb.h" +#include "modules/perception/proto/perception_obstacle.pb.h" + +namespace apollo { +namespace planning { + +class PerceptionProxy { + public: + PerceptionProxy() = default; + void add_perception_obstacles( + const apollo::perception::PerceptionObstacles& perception_obstacles); + apollo::perception::PerceptionObstacles* get_latest_perception_frame(); + const std::list& perception_frame() + const; + + private: + std::list _perception_frame; +}; + +} // namespace planning +} // namespace apollo + +#endif // MODULES_PLANNING_PROXY_PERCEPTION_PROXY_H_ -- GitLab