Apollo  6.0
Open source self driving car software
plane_motion.h
Go to the documentation of this file.
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 
17 #pragma once
18 
19 #include <cmath>
20 #include <cstdio>
21 #include <list>
22 #include <memory>
23 #include <mutex>
24 
25 #include "Eigen/Dense"
26 #include "Eigen/Eigen"
27 #include "Eigen/Geometry"
29 
30 namespace apollo {
31 namespace perception {
32 namespace camera {
33 
34 class PlaneMotion {
35  public:
36  explicit PlaneMotion(int s);
37 
38  ~PlaneMotion(void);
40 
41  private:
42  std::list<base::VehicleStatus> raw_motion_queue_;
43  base::MotionBufferPtr mot_buffer_;
44  std::mutex mutex_;
45  int buffer_size_;
46  int time_increment_; // the time increment units in motion input
47  float time_difference_; // the time difference for each buffer input
48  base::MotionType mat_motion_sensor_ = base::MotionType::Identity();
49  // motion matrix of accumulation through high sampling CAN+IMU input sequence
50  bool is_3d_motion_;
51  void generate_motion_matrix(
52  base::VehicleStatus *vehicledata); // generate inverse motion
53  void accumulate_motion(double start_time, double end_time);
54  void update_motion_buffer(const base::VehicleStatus &vehicledata,
55  const double pre_image_timestamp,
56  const double image_timestamp);
57 
58  public:
59  void cleanbuffer() {
60  if (mot_buffer_ != nullptr) {
61  mot_buffer_->clear();
62  mot_buffer_ = nullptr;
63  }
64 
65  mat_motion_sensor_ = base::MotionType::Identity();
66  }
67 
68  void set_buffer_size(int s) {
69  cleanbuffer();
70  buffer_size_ = s;
71  // mot_buffer_.reserve(buffer_size_);
72  if (mot_buffer_ == nullptr) {
73  mot_buffer_.reset(new base::MotionBuffer(buffer_size_));
74  } else {
75  mot_buffer_->set_capacity(buffer_size_);
76  }
77  }
78 
79  void add_new_motion(double pre_image_timestamp, double image_timestamp,
80  int motion_operation_flag,
81  base::VehicleStatus *vehicledata);
82 
84  bool find_motion_with_timestamp(double timestamp, base::VehicleStatus *vs);
85  bool is_3d_motion() const { return is_3d_motion_; }
86 };
87 
88 } // namespace camera
89 } // namespace perception
90 } // namespace apollo
void cleanbuffer()
Definition: plane_motion.h:59
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: plane_motion.h:34
Eigen::Matrix4f MotionType
Definition: object_supplement.h:188
void add_new_motion(double pre_image_timestamp, double image_timestamp, int motion_operation_flag, base::VehicleStatus *vehicledata)
bool find_motion_with_timestamp(double timestamp, base::VehicleStatus *vs)
Definition: object_supplement.h:189
bool is_3d_motion() const
Definition: plane_motion.h:85
std::shared_ptr< MotionBuffer > MotionBufferPtr
Definition: object_supplement.h:203
void set_buffer_size(int s)
Definition: plane_motion.h:68
boost::circular_buffer< VehicleStatus > MotionBuffer
Definition: object_supplement.h:202