Apollo 10.0
自动驾驶开放平台
motion_service_component.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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#pragma once
17
18#include <list>
19#include <memory>
20#include <mutex>
21#include <string>
22#include <vector>
23
24#include "Eigen/Core"
25
26#include "modules/common_msgs/localization_msgs/localization.pb.h"
27#include "modules/common_msgs/sensor_msgs/sensor_image.pb.h"
28#include "modules/perception/common/proto/motion_service.pb.h"
29#include "modules/perception/motion_service/proto/motion_service_component.pb.h"
30
31#include "cyber/common/macros.h"
36
37namespace apollo {
38namespace perception {
39namespace camera {
40
41typedef std::shared_ptr<apollo::drivers::Image> ImageMsgType;
42typedef std::shared_ptr<localization::LocalizationEstimate> LocalizationMsgType;
43
45 public:
47 virtual ~MotionServiceComponent() { delete vehicle_planemotion_; }
48
49 bool Init() override;
50 bool GetMotionInformation(double timestamp, base::VehicleStatus *vs);
52 double GetLatestTimestamp();
53
54 private:
55 void OnLocalization(const LocalizationMsgType &localization);
56 void OnReceiveImage(const ImageMsgType &message,
57 const std::string &camera_name);
58 void PublishEvent(const double timestamp);
59 void ConvertVehicleMotionToMsgOut(
61
62 PlaneMotion *vehicle_planemotion_ = nullptr;
63 std::string device_id_;
64 double pre_azimuth = 0; // a invalid value
65 double pre_timestamp_ = 0;
66 double pre_camera_timestamp_ = 0;
67 double camera_timestamp_ = 0;
68 bool start_flag_ = false;
69 const int motion_buffer_size_ = 100;
70 double timestamp_offset_ = 0.0;
71
72 std::vector<std::string> camera_names_; // camera sensor names
73 std::vector<std::string> input_camera_channel_names_;
74 std::mutex mutex_;
75 // std::mutex image_mutex_;
76 std::mutex motion_mutex_;
77 std::shared_ptr<apollo::cyber::Writer<apollo::perception::MotionService>>
78 writer_;
80};
81
83
84} // namespace camera
85} // namespace perception
86} // namespace apollo
bool GetMotionInformation(double timestamp, base::VehicleStatus *vs)
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:656
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition macros.h:48
boost::circular_buffer< VehicleStatus > MotionBuffer
std::shared_ptr< localization::LocalizationEstimate > LocalizationMsgType
std::shared_ptr< apollo::drivers::Image > ImageMsgType
class register implement
Definition arena_queue.h:37