Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
BSpline.cpp
Go to the documentation of this file.
2
4{
5namespace smoothing
6{
7void BSpline::setPoints(const std::vector<lanelet::BasicPoint2d>& points)
8{
9 Eigen::MatrixXd matrix_points(2, points.size());
10 int row_index = 0;
11 for(auto const point : points){
12 matrix_points.col(row_index) << point.x(), point.y();
13 row_index++;
14 }
15 spline_ = Eigen::SplineFitting<Spline2d>::Interpolate(matrix_points,3 );
16}
17lanelet::BasicPoint2d BSpline::operator()(double t) const
18{
19 Eigen::VectorXd values = spline_(t);
20 lanelet::BasicPoint2d pt = {values.x(), values.y()};
21 return pt;
22}
23
24lanelet::BasicPoint2d BSpline::first_deriv(double t) const {
25 Eigen::Array2Xd v = spline_.derivatives(t, 1);
26 lanelet::BasicPoint2d output = {v(2), v(3)};
27 return output;
28}
29
30lanelet::BasicPoint2d BSpline::second_deriv(double t) const {
31 Eigen::Array2Xd v = spline_.derivatives(t, 2);
32 lanelet::BasicPoint2d output = {v(4), v(5)};
33 return output;
34}
35
36}; // namespace smoothing
37}; // namespace inlanecruising_plugin
lanelet::BasicPoint2d operator()(double t) const override
Get the BasicPoint2d coordinate along the curve at t-th step.
Definition: BSpline.cpp:17
void setPoints(const std::vector< lanelet::BasicPoint2d > &points) override
Set key points which the spline will interpolate between.
Definition: BSpline.cpp:7
lanelet::BasicPoint2d first_deriv(double t) const override
Get the BasicPoint2d representing the first_deriv along the curve at t-th step.
Definition: BSpline.cpp:24
lanelet::BasicPoint2d second_deriv(double t) const override
Get the BasicPoint2d representing the first_deriv along the curve at t-th step.
Definition: BSpline.cpp:30