Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <boost/python.hpp>
00021 #include <boost/python/stl_iterator.hpp>
00022 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
00023
00024 #include <octomap_msgs/conversions.h>
00025
00026 template<class T>
00027 boost::python::list std_vector_to_py_list(const std::vector<T>& vec)
00028 {
00029 typename std::vector<T>::const_iterator iter;
00030 boost::python::list res;
00031 for (iter = vec.begin(); iter != vec.end(); ++iter) {
00032 res.append(*iter);
00033 }
00034 return res;
00035 }
00036
00038 boost::python::tuple octomap_str_to_tuple(const std::string &str_msg)
00039 {
00040 std::stringstream ss;
00041 ss << str_msg;
00042 ss.seekg(0);
00043 octomap::OcTree* octree = static_cast<octomap::OcTree*>(octomap::OcTree::read(ss));
00044 if (!octree) {
00045 std::cout << "Cast failed.";
00046 return boost::python::make_tuple();
00047 }
00048 octomap_msgs::Octomap msg;
00049 bool res = octomap_msgs::binaryMapToMsg(*octree, msg);
00050 delete(octree);
00051 return boost::python::make_tuple(msg.binary, msg.id, msg.resolution, std_vector_to_py_list(msg.data));
00052 }
00053
00054 BOOST_PYTHON_MODULE(octomap_python)
00055 {
00056 boost::python::def("octomap_str_to_tuple", octomap_str_to_tuple);
00057 }
naoqi_sensors_py
Author(s): Séverin Lemaignan, Vincent Rabaud, Karsten Knese, Jack O'Quin, Ken Tossell, Patrick Beeson, Nate Koenig, Andrew Howard, Damien Douxchamps, Dan Dennedy, Daniel Maier
autogenerated on Sat Jun 8 2019 20:30:18