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.
1/*
2 * Copyright (C) 2021-2022 LEIDOS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * 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, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17
19
20namespace basic_autonomy
21{
22namespace smoothing
23{
24void BSpline::setPoints(const std::vector<lanelet::BasicPoint2d>& points)
25{
26 Eigen::MatrixXd matrix_points(2, points.size());
27 int row_index = 0;
28 for(auto const point : points){
29 matrix_points.col(row_index) << point.x(), point.y();
30 row_index++;
31 }
32 spline_ = Eigen::SplineFitting<Spline2d>::Interpolate(matrix_points,3 );
33}
34lanelet::BasicPoint2d BSpline::operator()(double t) const
35{
36 Eigen::VectorXd values = spline_(t);
37 lanelet::BasicPoint2d pt = {values.x(), values.y()};
38 return pt;
39}
40
41lanelet::BasicPoint2d BSpline::first_deriv(double t) const {
42 Eigen::Array2Xd v = spline_.derivatives(t, 1);
43 lanelet::BasicPoint2d output = {v(2), v(3)};
44 return output;
45}
46
47lanelet::BasicPoint2d BSpline::second_deriv(double t) const {
48 Eigen::Array2Xd v = spline_.derivatives(t, 2);
49 lanelet::BasicPoint2d output = {v(4), v(5)};
50 return output;
51}
52
53} // namespace smoothing
54} // namespace basic_autonomy
void setPoints(const std::vector< lanelet::BasicPoint2d > &points) override
Set key points which the spline will interpolate between.
Definition: BSpline.cpp:24
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:41
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:47
lanelet::BasicPoint2d operator()(double t) const override
Get the BasicPoint2d coordinate along the curve at t-th step.
Definition: BSpline.cpp:34