yarp-devices
TrapezoidalTrajectory.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __TRAPEZOIDAL_TRAJECTORY_HPP__
4 #define __TRAPEZOIDAL_TRAJECTORY_HPP__
5 
6 #include <mutex>
7 
8 namespace roboticslab
9 {
10 
17 {
18 public:
19  struct Reference
20  {
21  double position; // units
22  double velocity; // units/seconds
23  double acceleration; // units/seconds^2
24  };
25 
28 
30  void setTargetPosition(double startTimestamp, double initialPosition, double initialVelocity,
31  double targetPosition, double refSpeed, double refAcceleration);
32 
34  void setTargetVelocity(double startTimestamp, double initialPosition, double initialVelocity,
35  double targetVelocity, double refAcceleration);
36 
38  void reset(double currentPosition);
39 
41  Reference update(double timestamp);
42 
44  double getTargetPosition() const;
45 
47  double queryPosition() const;
48 
50  double queryVelocity() const;
51 
53  double queryAcceleration() const;
54 
56  double queryTime() const;
57 
59  bool isActive() const;
60 
61 private:
62  void configure(double startTimestamp, double initialPosition, double initialVelocity,
63  double targetPosition, double refSpeed, double refAcceleration);
64 
65  double ta, a1, a2, a3;
66  double tb, b2, b3;
67  double tc, c1, c2, c3;
68 
69  double startTimestamp;
70  double targetPosition;
71 
72  double positionReference;
73  double velocityReference;
74  double accelerationReference;
75  double elapsedTime;
76 
77  bool active;
78  mutable std::mutex mutex;
79 };
80 
81 } // namespace roboticslab
82 
83 #endif // __TRAPEZOIDAL_TRAJECTORY_HPP__
Definition: TrapezoidalTrajectory.hpp:17
TrapezoidalTrajectory()
Constructor.
Definition: TrapezoidalTrajectory.cpp:29
void setTargetVelocity(double startTimestamp, double initialPosition, double initialVelocity, double targetVelocity, double refAcceleration)
Set motion parameters (infinite motion).
Definition: TrapezoidalTrajectory.cpp:58
void setTargetPosition(double startTimestamp, double initialPosition, double initialVelocity, double targetPosition, double refSpeed, double refAcceleration)
Set motion parameters (using target position).
Definition: TrapezoidalTrajectory.cpp:44
double queryAcceleration() const
Retrieve last acceleration reference (units/seconds^2).
Definition: TrapezoidalTrajectory.cpp:318
double getTargetPosition() const
Query configured target position (units).
Definition: TrapezoidalTrajectory.cpp:294
void reset(double currentPosition)
Reset state, remember current position (units).
Definition: TrapezoidalTrajectory.cpp:224
Reference update(double timestamp)
Update trajectory state, must be called on regular intervals of period.
Definition: TrapezoidalTrajectory.cpp:242
double queryVelocity() const
Retrieve last velocity reference (units/seconds).
Definition: TrapezoidalTrajectory.cpp:310
bool isActive() const
Whether the trajectory is currently ongoing.
Definition: TrapezoidalTrajectory.cpp:334
double queryPosition() const
Retrieve last position reference (units).
Definition: TrapezoidalTrajectory.cpp:302
double queryTime() const
Retrieve elapsed time since start (seconds).
Definition: TrapezoidalTrajectory.cpp:326
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6
Definition: TrapezoidalTrajectory.hpp:20