Giter Club home page Giter Club logo

drake-external-examples's People

Contributors

ericcousineau-tri avatar ggould-tri avatar jamiesnape avatar jwnimmer-tri avatar nuclearsandwich avatar seancurtis-tri avatar sherm1 avatar soonho-tri avatar stonier avatar yf225 avatar

Stargazers

 avatar

drake-external-examples's Issues

Wrapping "friend" operators without py::self shortcuts

When trying to wrap the polynomial class, we receive a variety of errors with the direct generation of the pybind11 code.

Wrapping drake::Polynomial<double> const drake::operator+(double const & scalar, drake::Polynomial<double> const & p) [free operator] which points to this function: https://github.com/RobotLocomotion/drake/blob/master/common/polynomial.h#L341

returns

/home/softhat/Work/TRI/drake-external-examples/drake_cmake_bindings/build/pydrake/polynomial/Polynomial_py.cpp:59:144: error: ‘operator+’ is not a member of ‘drake’
     .def("__add__", static_cast<::drake::Polynomial<double> const (*)( ::drake::Polynomial<double> const &,double const & )>(&::drake::operator+), py::arg("p"), py::arg("scalar"))
                                                                                                                                                ^
/home/softhat/Work/TRI/drake-external-examples/drake_cmake_bindings/build/pydrake/polynomial/Polynomial_py.cpp:59:144: note: suggested alternatives:
In file included from /home/softhat/Work/TRI/drake-pybind/include/pybind11/stl.h:20:0,
                 from /home/softhat/Work/TRI/drake-external-examples/drake_cmake_bindings/build/pydrake/polynomial/Polynomial_py.cpp:3:
/usr/include/c++/7/valarray:1172:1: note:   ‘std::operator+’
 _DEFINE_BINARY_OPERATOR(+, __plus)

Additionally, "operator<<" returns a slightly different error:

/home/softhat/Work/TRI/drake-external-examples/drake_cmake_bindings/build/pydrake/polynomial/Polynomial_py.cpp:68:134: error: invalid static_cast from type ‘<unresolved overloaded function type>’ to type ‘std::ostream& (*)(std::ostream&, const drake::Polynomial<double>&) {aka std::basic_ostream<char>& (*)(std::basic_ostream<char>&, const drake::Polynomial<double>&)}’
     .def("__lshift__", static_cast<::std::ostream & (*)( ::std::ostream &,::drake::Polynomial<double> const & )>(&::drake::operator<<), py::arg("os"), py::arg("poly"))

Matching Polynomial constructor's Eigen objects

The explicit template constructor of the Polynomial class which takes, according to the .h file, an Eigen::MatrixBase<Derived>. I created an instantiation of the constructor to look like this:

template drake::Polynomial<double>::Polynomial(Eigen::MatrixBase<Eigen::VectorXd>const &);

Using that instantiation, PyBind11 errors with that there is some usage of deleted functions. If I use the same type found in polynomial_py.cc, const Eigen::Ref<const Eigen::VectorXd>&, CastXML complains about a signature mismatch

How do we connect the two types?

Pointer disagreement in LCM

.def("Subscribe", static_cast<::std::shared_ptr<drake::lcm::DrakeSubscriptionInterface> ( ::drake::lcm::DrakeLcm::* )( ::std::string const &,::drake::lcm::DrakeLcmInterface::HandlerFunction )>(&::drake::lcm::DrakeLcm::Subscribe), py::arg("channel"), py::arg("handler"))

would throws the "Unable to transfer between holders of different types" RuntimeError.

From Eric:

More acutely for your error, it's probably that autopybind11 is using unique_ptr for the holder.
You can go from unique_ptr -> shared_ptr, but not vice versa. This isn't solvable, because STL's shared_ptr is supposed to be thread-safe, so you cannot .release() from shared_ptr.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.