Spline.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 #include <mc_trajectory/api.h>
7 
8 #include <vector>
9 
10 namespace mc_trajectory
11 {
12 
13 template<typename T, typename WaypointsT>
14 struct Spline
15 {
16 public:
17  Spline(double duration, const T & start, const T & target, const WaypointsT & waypoints = {});
18 
25  void waypoints(const WaypointsT & waypoints);
31  const WaypointsT & waypoints() const;
32 
37  void start(const T & start);
42  const T & start() const;
43 
48  void target(const T & target);
53  const T & target() const;
54 
61  void samplingPoints(unsigned s);
62 
67  unsigned samplingPoints() const;
68 
73  virtual void update() = 0;
74 
75 protected:
76  double duration_;
77  T start_;
79  WaypointsT waypoints_;
80  unsigned samplingPoints_ = 10;
81  std::vector<T> samples_;
82  bool needsUpdate_ = false;
83 };
84 
85 } // namespace mc_trajectory
86 
87 #include <mc_trajectory/Spline.hpp>
mc_trajectory::Spline::start
const T & start() const
Starting point at time t=0.
mc_trajectory::Spline::waypoints_
WaypointsT waypoints_
Definition: Spline.h:79
mc_trajectory::Spline::start_
T start_
Definition: Spline.h:77
mc_trajectory::Spline::waypoints
const WaypointsT & waypoints() const
Returns waypoints.
mc_trajectory::Spline::Spline
Spline(double duration, const T &start, const T &target, const WaypointsT &waypoints={})
mc_trajectory::Spline::target
const T & target() const
Gets the spline target position.
mc_trajectory
Definition: BSpline.h:14
mc_trajectory::Spline::target_
T target_
Definition: Spline.h:78
mc_trajectory::Spline::samplingPoints_
unsigned samplingPoints_
Definition: Spline.h:80
api.h
mc_trajectory::Spline::samplingPoints
unsigned samplingPoints() const
Gets number of samples.
mc_trajectory::Spline::needsUpdate_
bool needsUpdate_
Definition: Spline.h:82
mc_trajectory::Spline
Definition: Spline.h:14
mc_trajectory::Spline::duration_
double duration_
Definition: Spline.h:76
mc_trajectory::Spline::samples_
std::vector< T > samples_
Definition: Spline.h:81
mc_trajectory::Spline::update
virtual void update()=0
Triggers recreation of the curve. Will only occur if the curve parameters were modified (waypoints,...