BSpline.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 
8 #include <mc_trajectory/Spline.h>
9 #include <mc_trajectory/api.h>
10 
11 #include <ndcurves/bezier_curve.h>
12 #include <vector>
13 
14 namespace mc_trajectory
15 {
16 
17 struct MC_TRAJECTORY_DLLAPI BSpline : public Spline<Eigen::Vector3d, std::vector<Eigen::Vector3d>>
18 {
19  using bezier_curve_t = ndcurves::bezier_curve<double, double, false, Eigen::Vector3d>;
20  using waypoints_t = std::vector<Eigen::Vector3d>;
21 
22 public:
32  BSpline(double duration,
33  const Eigen::Vector3d & start,
34  const Eigen::Vector3d & target,
35  const waypoints_t & waypoints = {});
36 
41  void update() override;
42 
51  std::vector<Eigen::Vector3d> splev(double t, unsigned int der = 0);
52 
59  std::vector<Eigen::Vector3d> sampleTrajectory();
60 
66  void addToGUI(mc_rtc::gui::StateBuilder & gui, const std::vector<std::string> & category);
67 
68 private:
69  std::unique_ptr<bezier_curve_t> spline = nullptr;
70 };
71 
72 } // namespace mc_trajectory
#define MC_TRAJECTORY_DLLAPI
Definition: api.h:50
Definition: BSpline.h:15
Definition: StateBuilder.h:28
Definition: BSpline.h:18
void addToGUI(mc_rtc::gui::StateBuilder &gui, const std::vector< std::string > &category)
Add GUI elements to control the curve's waypoints and targets.
BSpline(double duration, const Eigen::Vector3d &start, const Eigen::Vector3d &target, const waypoints_t &waypoints={})
Creates a curve with given waypoints (should includes starting and target position)
void update() override
Triggers recreation of the curve. Will only occur if the curve parameters were modified (waypoints,...
ndcurves::bezier_curve< double, double, false, Eigen::Vector3d > bezier_curve_t
Definition: BSpline.h:19
std::vector< Eigen::Vector3d > sampleTrajectory()
Sample positions along the trajectory (for visualization purposes)
std::vector< Eigen::Vector3d > waypoints_t
Definition: BSpline.h:20
std::vector< Eigen::Vector3d > splev(double t, unsigned int der=0)
Computes the position along the curve at time t, and its derivatives up to the nth order (typically v...
Definition: Spline.h:15