Apollo  6.0
Open source self driving car software
third_party_perception_base.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2020 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  *****************************************************************************/
16 
21 #pragma once
22 
23 #include <memory>
24 #include <mutex>
25 #include <string>
26 
27 #include "cyber/node/node.h"
28 #include "cyber/node/reader.h"
29 #include "modules/canbus/proto/chassis.pb.h"
31 #include "modules/drivers/proto/sensor_image.pb.h"
32 #include "modules/localization/proto/localization.pb.h"
33 #include "modules/perception/proto/perception_obstacle.pb.h"
35 #include "modules/third_party_perception/proto/radar_obstacle.pb.h"
36 
41 namespace apollo {
42 namespace third_party_perception {
43 
45  public:
46  explicit ThirdPartyPerception(apollo::cyber::Node* const node);
47  ThirdPartyPerception() = default;
48  virtual ~ThirdPartyPerception() = default;
49  std::string Name() const;
52  void Stop();
53 
54  // Upon receiving localization data
55  void OnLocalization(
56  const apollo::localization::LocalizationEstimate& message);
57  // Upon receiving chassis data
58  void OnChassis(const apollo::canbus::Chassis& message);
59  // publish perception obstacles when timer is triggered
60  virtual bool Process(apollo::perception::PerceptionObstacles* const response);
61 
62  protected:
64  apollo::localization::LocalizationEstimate localization_;
65  apollo::canbus::Chassis chassis_;
66  RadarObstacles current_radar_obstacles_;
67  RadarObstacles last_radar_obstacles_;
68  std::shared_ptr<apollo::cyber::Node> node_ = nullptr;
69  std::shared_ptr<
72  std::shared_ptr<apollo::cyber::Reader<apollo::canbus::Chassis>>
73  chassis_reader_ = nullptr;
74 };
75 
76 } // namespace third_party_perception
77 } // namespace apollo
virtual bool Process(apollo::perception::PerceptionObstacles *const response)
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Reader subscribes a channel, it has two main functions:
Definition: reader.h:68
std::shared_ptr< apollo::cyber::Node > node_
Definition: third_party_perception_base.h:68
Node is the fundamental building block of Cyber RT. every module contains and communicates through th...
Definition: node.h:44
RadarObstacles current_radar_obstacles_
Definition: third_party_perception_base.h:66
Definition: third_party_perception_base.h:44
RadarObstacles last_radar_obstacles_
Definition: third_party_perception_base.h:67
void OnLocalization(const apollo::localization::LocalizationEstimate &message)
apollo::localization::LocalizationEstimate localization_
Definition: third_party_perception_base.h:64
std::shared_ptr< apollo::cyber::Reader< apollo::canbus::Chassis > > chassis_reader_
Definition: third_party_perception_base.h:73
apollo::canbus::Chassis chassis_
Definition: third_party_perception_base.h:65
std::shared_ptr< apollo::cyber::Reader< apollo::localization::LocalizationEstimate > > localization_reader_
Definition: third_party_perception_base.h:71
A general class to denote the return status of an API call. It can either be an OK status for success...
Definition: status.h:43
void OnChassis(const apollo::canbus::Chassis &message)
std::mutex third_party_perception_mutex_
Definition: third_party_perception_base.h:63