Hey Paul, I think I'm good for now. I'm in the process of traveling for the
holidays some haven't had the chance to try your recommendations on the
includes yet. I'll let you know of it's still an issue once I add the fix.
Basically the problem was that the grammar of the automatic wrapper currently does not accept numbers (and I think basic types as well) as template arguments.
In boost python sometimes we need to create function pointers to specify which method we're calling when the method has overloads that take different lists of arguments. To create the function pointer we need the full signature of the method (longer list of arguments), and the problem arises when the method uses templated types like Optional Jacobian. When this happens, we need to write the templated type (OptionalJacobian<4,3> for example) in the interface file gtsampy.h, so it gets copied in the generated file used to compile the module, but this kind of construction is not accepted by the grammar.
I don't know if I was clear enough. I explained it with some examples here and here before starting wrapping everything by hand.
BTW, @Ellon Paiva
OptionalJacobian is of course meant to return a Jacobian. Do you have an example with your Pose3 wrapping (or any other class) that actually achieves this? It is not obvious to me (yet) how to make this happen.....
No, I do not have an example. In fact, I just found the problem because when wrapping I found some methods that I couldn't expose via the simple way (overloading macro + .def line).
I'm not sure how to return the jacobian through the method arguments in python, it it can be done at all. From what I read, the pythonic way of doing it would be to return the jacobian as extra arguments of the method, since python accepts returning more than one value, like in Matlab. To do this in the wrapper, I think a interface function needs to be created (like Quaternion_0 and Quaternion_1 on python/handwritten/geometry/Rot3.cpp), that will call the C++ method, receive the jacobians from the method, then compose the result and the jacobians in a tuple and finally return it to python.
Yes, these are good questions. I also don't have the knowledge on python or boost python to answer them.
I quick search tells me that passing a "mutable parameter" to a function makes it possible to return the jacobian matrix by parameter, like it is currently in C++. Although I think adding a named parameter to the method (something like "..., jacobians=true") to the function call would be the best way to trigger the computation of jacobians, returning them together with the values as a tuple. I'll dig more into it next week.
Actually, I looked into the numpy_eigen code and I think it can be done. We just need a type_convertor from Python to OptionalJacobian, that takes either None or a numpy array of the correct size. It should be seamless. I'll experiment a bit..