stack-of-tasks / pinocchio

A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
http://stack-of-tasks.github.io/pinocchio/
BSD 2-Clause "Simplified" License
1.78k stars 375 forks source link

Fusion of Models #742

Closed jmirabel closed 5 years ago

jmirabel commented 5 years ago

I would like to be able to append a Model to a specific joint of another Model. I cannot think of any easy way of doing it.

Using Pinocchio, I would have to write:

I could also create a new Model and append joints to it in the right order. It seems a bit easier.

Any hints or comments on the above ?

jcarpent commented 5 years ago
* an algo that reorder the joints so that all the children of a joint are contiguous. This looks a bit more tricky as they are many fields to be updated, both in Model and GeomModel. it's going to be a nightmare to maintain...

You should follow this strategy if you want Pinocchio to be efficient and it is mandatory in the context of CRBA algorithms for instance. I would say that is better to create a new model from two existing ones. It is just a call to appendJoint method, which is pretty sufficient.

jmirabel commented 5 years ago

For my application, it doesn't have to be efficient.

I will have a look at the second option.

jcarpent commented 5 years ago

I would prefer to implement directly the final solution, which means having continuous ordering for directly parent joints. It will avoid additional work later and full compatibility with all the existing algo.

jmirabel commented 5 years ago

I would prefer to implement directly the final solution

what do you mean ?

jcarpent commented 5 years ago

I mean, the solution of merging two models in a new model, having all the index of a given subtree represented by a continuous collection (again, this is mandatory for most dynamic algorithms).

jmirabel commented 5 years ago

In which file should this be ? My first thought is a new file algorithm/model.hpp.

jmirabel commented 5 years ago

It could also go into algorithm/copy.hpp.

jmirabel commented 5 years ago

It could also be a constructor of Model class. It may be a little awkward though.

gabrielebndn commented 5 years ago

Related to #470. A new file called algorithm/model.hpp could contain all algorithms related to directly manipulating the model, such as the proposed fusion of models, the extraction of subtrees, and possibly joint reordering (see #379). My feeling though is that all these features would be best implemented as instance methods of the Model class.

jcarpent commented 5 years ago

I would do it in multibody/model.hxx

jcarpent commented 5 years ago

solved by #752.