hungpham2511 / toppra

robotic motion planning library
https://hungpham2511.github.io/toppra/index.html
MIT License
625 stars 170 forks source link

Expose trajectory gridpoint times (m_ts) in parametrizers #187

Open stevegolton opened 2 years ago

stevegolton commented 2 years ago

It would be useful to have visibility on how points in the source path are remapped into the retimed path, for the purpose of path debugging.

For example, let's say you have a robot path comprised of several key waypoints. The path is retimed using toppra and sent to the robot. Assuming we can get the elapsed time from the robot while it is running the retimed path, this time could be used to work out which key waypoint in the source path the robot is currently executing for the purposes of debugging and tweaking the source path.

This information is available in both the ConstAccel and the Spline parametrizers internally as m_ts member variable but don't expose them publicly.

Describe the solution you'd like A way to access m_ts, preferably in the toppra::Parametrizer interface, so we don't have to worry about which parametrizer is used.

Describe alternatives you've considered We could have a separate class which works out these times and exposes them, but this mapping presumably depends on the parametrizer used.

Additional context

Suggested solution:

parametrizer.hpp

class Parametrizer : public GeometricPath {
  public:
    const Vector &times() const = 0;
};

const_accel.hpp

const Vector &times() const override;

const_accel.cpp

const Vector &ConstAccel::times() const {
  return m_ts;
}

... and the same for Spline parametrizer.