Apollo  6.0
Open source self driving car software
trajectory_analyzer.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 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 
22 #pragma once
23 
24 #include <vector>
25 
26 #include "modules/planning/proto/planning.pb.h"
27 
30 #include "modules/common/proto/pnc_point.pb.h"
32 
37 namespace apollo {
38 namespace control {
39 
45  public:
49  TrajectoryAnalyzer() = default;
50 
57  const planning::ADCTrajectory *planning_published_trajectory);
58 
62  ~TrajectoryAnalyzer() = default;
63 
68  unsigned int seq_num() { return seq_num_; }
69 
76  common::TrajectoryPoint QueryNearestPointByAbsoluteTime(const double t) const;
77 
84  common::TrajectoryPoint QueryNearestPointByRelativeTime(const double t) const;
85 
93  common::TrajectoryPoint QueryNearestPointByPosition(const double x,
94  const double y) const;
95 
104  common::PathPoint QueryMatchedPathPoint(const double x, const double y) const;
105 
119  void ToTrajectoryFrame(const double x, const double y, const double theta,
120  const double v, const common::PathPoint &matched_point,
121  double *ptr_s, double *ptr_s_dot, double *ptr_d,
122  double *ptr_d_dot) const;
123 
130  void TrajectoryTransformToCOM(const double rear_to_com_distance);
131 
141  const double rear_to_com_distance,
142  const common::PathPoint &path_point) const;
143 
148  const std::vector<common::TrajectoryPoint> &trajectory_points() const;
149 
150  private:
151  common::PathPoint FindMinDistancePoint(const common::TrajectoryPoint &p0,
152  const common::TrajectoryPoint &p1,
153  const double x, const double y) const;
154 
155  std::vector<common::TrajectoryPoint> trajectory_points_;
156 
157  double header_time_ = 0.0;
158  unsigned int seq_num_ = 0;
159 };
160 
161 } // namespace control
162 } // namespace apollo
common::TrajectoryPoint QueryNearestPointByPosition(const double x, const double y) const
query a point of trajectory that its position is closest to the given position.
~TrajectoryAnalyzer()=default
destructor
Defines the Vec2d class.
void TrajectoryTransformToCOM(const double rear_to_com_distance)
Transform the current trajectory points to the center of mass(COM) of the vehicle, given the distance from rear wheels to the center of mass.
common::TrajectoryPoint QueryNearestPointByAbsoluteTime(const double t) const
query a point of trajectory that its absolute time is closest to the give time.
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void ToTrajectoryFrame(const double x, const double y, const double theta, const double v, const common::PathPoint &matched_point, double *ptr_s, double *ptr_s_dot, double *ptr_d, double *ptr_d_dot) const
convert a position with theta and speed to trajectory frame,
common::PathPoint QueryMatchedPathPoint(const double x, const double y) const
query a point on trajectory that its position is closest to the given position.
TrajectoryAnalyzer()=default
constructor
Implements a class of 2-dimensional vectors.
Definition: vec2d.h:42
process point query and conversion related to trajectory
Definition: trajectory_analyzer.h:44
The class of Box2d. Here, the x/y axes are respectively Forward/Left, as opposed to what happens in e...
common::TrajectoryPoint QueryNearestPointByRelativeTime(const double t) const
query a point of trajectory that its relative time is closest to the give time. The time is relative ...
unsigned int seq_num()
get sequence number of the trajectory
Definition: trajectory_analyzer.h:68
const std::vector< common::TrajectoryPoint > & trajectory_points() const
get all points of the trajectory
common::math::Vec2d ComputeCOMPosition(const double rear_to_com_distance, const common::PathPoint &path_point) const
Compute the position of center of mass(COM) of the vehicle, given the distance from rear wheels to th...