stulp / dmpbbo

Python/C++ library for Dynamical Movement Primitives and Black-Box Optimization
GNU Lesser General Public License v2.1
227 stars 89 forks source link

Did dmpbbo support 6 DOF trajectory DMP training ? #85

Open maoyangchien opened 1 year ago

maoyangchien commented 1 year ago

Hi, thank you for contributing to this great open-source project.

I have looked at the test process in the demo directory and also looked at the contents of the Trajectory.py and trajectory.txt files. I have a few questions to ask you:

  1. Looking at the structure of trajectory.txt, the first column is the timestamp, the second and third columns are the x, y coordinates, the fourth and fifth columns are the velocity in the x and y directions, and the fifth and sixth columns are the acceleration in the x and y directions. Is my understanding correct?

  2. If my target trajectory has 6 degrees of freedom and uses quaternion coordinates, such as (x, y, z, qx, qy, qz, qw), does dmpbbo support such coordinate trajectories? If I also provide the velocity and acceleration of x, y, z, how does dmpbbo handle qx, qy, qz, qw?

stulp commented 1 year ago

The short answer is that yes, orientations can be represented in principle, but no, it is not supported explicitly. This is one of the main weaknesses of the current implementations,, and support for orientations is at the top of my wishlist.

In principle: yes

Quaternions can be implemented by adding them as miscellaneous variables to the trajectory: https://github.com/stulp/dmpbbo/blob/c73e1418b611f31cfbe652df51f14f8c18552897/dmpbbo/dmps/Trajectory.py#L142-L143

You can then train a DMP with these miscellaneous variables with this function (i.e. instead of gains/forces, you would have orientations) https://github.com/stulp/dmpbbo/blob/c73e1418b611f31cfbe652df51f14f8c18552897/dmpbbo/dmps/DmpWithSchedules.py#L50-L62

In practice: no

However, the DMP implementation does not know that these are quaternions, and would thus not ensure that they are normalized, for instance. So in practice, this is not a satisfactory solution.

The proper way would rather be to have trajectories and DMPs that are aware that they are dealing with orientations and/or quaternions. Although I have no time to implement that, I would be very happy to help design it and review code, in case someone is interested in pursuing this for a student project, for instance.

There are several ways this could be implemented, including

I also see that I need to improve the documentation of the Trajectory class...

maoyangchien commented 1 year ago

Thank you for your quick reply. Can I first use dmpbbo to train trajectory data like timestamp, x, y, z, vx, vy, vz, ax, ay, az?

maoyangchien commented 1 year ago

After carefully considering my needs, I still require quaternions coordinate information. I hope I can implement this feature, but I don't know where to start.

stulp commented 10 months ago

This is probably what I would go for: https://arxiv.org/abs/2203.03374

Sorry, this would be a bigger project, and I don't have time to support that right now.