tinympc-python icon indicating copy to clipboard operation
tinympc-python copied to clipboard

Cannot use `set_x0` in codegen/pywrapper/bindings.cpp

Open levioctl opened this issue 1 year ago • 0 comments

Hi,

I'm trying to build a small C++ program that uses the generated tiny_data.cpp, by calling set_x0 and set_x_ref, like codegen/pywrapper/bindings.cpp.

However, when calling set_x0 (copied from codegen/pywrapper/bindings.cpp) I get a runtime error; The call to the inner tiny_set_x0 (that expects a tinyVector) fails, as it tries to pass a matrix (that is, more than 1 rows and cols) as an argument (the result of the x0.replicate in here line 25) to a tinyVector. Which Eigen does not like, as it expects the matrix being cast to have at least one dimension of size 1. (The following message is printed: Assertion `other.rows() == 1 || other.cols() == 1' failed)

  1. I see that codegen/pywrapper/bindings.cpp is used for tinympcgen's operations (set_x0, set_x_ref etc.). Is it that Pybind11's Eigen implementation prevents this from failing (as opposed to when running these lines in pure C++ and Eigen like i've tried)?

  2. Is the replication necessary in the case of set_x0? Is it some kind of necessity from using Pybind11? or am I missing something.

Thanks.

levioctl avatar Jan 26 '25 17:01 levioctl