You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version (or hash if on master) of pybind11 are you using?
2.11.1
Problem description
Due to the set_max_vel function of Engine class is not static function, so it will raise an error when I bind the the set_max_vel function like that. How to bind a c array which is in a function within a class?
Reproducible example code
// c++ code
#include <Eigen/Core>
class Engine: {
public:
Engine();
void set_max_vel(float *max_vel, int dof){
max_velocity_.resize(dof);
for (int i = 0; i < dof; i++){
max_velocity_[i] = (double)max_vel[i];
}
}
private:
Eigen::VectorXd max_velocity_;
}
// binding code
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
namespace py = pybind11;
py::class_<Engine>(m, "Engine")
.def(py::init<>())
.def("set_max_vel", [](py::array_t<float> buffer, int dof) {
py::buffer_info info = buffer.request();
Engine::set_max_vel(static_cast<float*>(info.ptr), dof); });
Is this a regression? Put the last known working version here if it is.
Not a regression
The text was updated successfully, but these errors were encountered:
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
2.11.1
Problem description
Due to the set_max_vel function of Engine class is not static function, so it will raise an error when I bind the the set_max_vel function like that. How to bind a c array which is in a function within a class?
Reproducible example code
Is this a regression? Put the last known working version here if it is.
Not a regression
The text was updated successfully, but these errors were encountered: