@@ -43,6 +43,8 @@ bool TypeConverterRegistry::insert(const std::type_index& type_index,
4343
4444 if (!ros_msg_name.empty ()) { // is this a ROS msg type?
4545 msg_names_.insert (std::make_pair (ros_msg_name, it_inserted.first ));
46+ } else {
47+ msg_names_.insert (std::make_pair (BT::demangle (type_index), it_inserted.first ));
4648 }
4749
4850 return true ;
@@ -83,9 +85,24 @@ BT::Any fromPython(const py::object& po) {
8385
8486 const std::string& ros_msg_name = rosMsgName (o);
8587 auto it = TypeConverterRegistry::get ().msg_names_ .find (ros_msg_name);
86- if (it == TypeConverterRegistry::get ().msg_names_ .end ())
87- throw py::type_error (" No C++ conversion available for type: " + ros_msg_name +
88- " \n Available conversions : " + fmt::format (" {}" , get_registered_converters ()));
88+ if (it == TypeConverterRegistry::get ().msg_names_ .end ()) {
89+ try {
90+ // Get the Python type object
91+ PyTypeObject* type = po.ptr ()->ob_type ;
92+
93+ // Check if it's a wrapped C++ type by checking for the type_info holder
94+ if (auto * type_info = pybind11::detail::get_type_info (type)) {
95+ const std::string cpptype = BT::demangle (*type_info->cpptype );
96+ it = TypeConverterRegistry::get ().msg_names_ .find (cpptype);
97+ if (it == TypeConverterRegistry::get ().msg_names_ .end ()) {
98+ throw py::type_error (" No C++ conversion available for type: '" + cpptype +
99+ " '\n Available conversions : " + fmt::format (" {}" , get_registered_converters ()));
100+ }
101+ }
102+ } catch (const std::runtime_error& e) {
103+ throw py::type_error (e.what ());
104+ }
105+ }
89106
90107 return it->second ->second .from_ (po);
91108}
0 commit comments