I have a header and a cpp file of SplineCreator class. There is a function in this called CreateLinearSpline and CreateCubicSpline. Here:- (Note: This is not a complete header file but these are the functions I am interested about. I have defined these functions in the cpp file as well. Also all the header files are included on top)
template <typename T> class SplineCreator {
public:
Spline<T> CreateLinearSpline(const std::vector<T>& y_values, const T x_diff = 1.0);
Spline<T> CreateCubicSpline(const std::vector<T>& y_values,
const std::array<T, 2> boundary_values = std::array<T, 2>{ { 0.0, 0.0 } },
const std::array<BoundaryType, 2> boundary_type
= std::array<BoundaryType, 2>{ { first_deriv, first_deriv } },
const T x_diff = 1.0);
}
I have used these functions in another cpp file as follows:
template <typename T> Path<T>::Path(const std::vector<Point2D<T>>& point_vector,
const T x_diff, const T gradient_start, const T gradient_end, const size_t degree)
{
VectorXY<T> xy_vec;
Point2D<T>::create_x_y_vectors(point_vector);
Expects(degree > 0);
std::array<T, 2> boundary_values{ { gradient_start, gradient_end } };
Spline<T> x_spline;
Spline<T> y_spline;
switch (degree) {
case 1:
x_spline = CreateLinearSpline(xy_vec.x, x_diff);
y_spline = CreateLinearSpline(xy_vec.y, x_diff);
case 3:
x_spline = CreateCubicSpline(xy_vec.x, boundary_values,
std::array<BoundaryType, 2>{ { first_deriv, first_deriv } }, x_diff);
y_spline = CreateCubicSpline(xy_vec.y, boundary_values,
std::array<BoundaryType, 2>{ { first_deriv, first_deriv } }, x_diff);
default:
throw std::invalid_argument("The Degree should be either 1 or 3");
}
Path(x_spline, y_spline);
}
Also, I have included all the header files on top of this file. But when I compile it using catkin_make I am getting the following error:
error: ‘CreateLinearSpline’ was not declared in this scope x_spline = CreateLinearSpline(xy_vec.x, x_diff);
error: ‘CreateLinearSpline’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] y_spline = CreateLinearSpline(xy_vec.y, x_diff);
I have checked similar questions but could not find the solution. I am sure I am making a silly error somewhere but I can't seem to figure this out.
I hope someone can help me.