Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include <algorithm>
00007 #include <string>
00008 #include <vector>
00009 #include <sstream>
00010
00011 #include <boost/python.hpp>
00012 #include <python2.7/Python.h>
00013
00014 #include <ros/serialization.h>
00015
00016 #include <lama_msgs/Crossing.h>
00017 #include <lama_msgs/Frontier.h>
00018 #include <lama_msgs/PlaceProfile.h>
00019
00020 #include <crossing_detector/crossing_detector.h>
00021 #include <crossing_detector/wrapper_utils.h>
00022
00023 namespace bp = boost::python;
00024 namespace rs = ros::serialization;
00025
00026 using crossing_detector::CrossingDetector;
00027 using lama_msgs::Crossing;
00028 using lama_msgs::Frontier;
00029 using lama_msgs::PlaceProfile;
00030
00031
00032
00033
00034
00035
00036 class CrossingDetectorWrapper : public CrossingDetector
00037 {
00038 public:
00039
00040 CrossingDetectorWrapper(const double frontier_width, const double max_frontier_angle=0.785) :
00041 CrossingDetector(frontier_width, max_frontier_angle)
00042 {
00043 }
00044
00045 std::string crossingDescriptor(const std::string str_profile, const bool normalize=false)
00046 {
00047
00048 PlaceProfile profile = from_python<PlaceProfile>(str_profile);
00049 Crossing crossing = CrossingDetector::crossingDescriptor(profile, normalize);
00050
00051 return to_python(crossing);
00052 }
00053
00054 std::vector<std::string> frontiers(const std::string str_profile, const bool normalize=false)
00055 {
00056 PlaceProfile profile = from_python<PlaceProfile>(str_profile);
00057 std::vector<Frontier> frontiers = CrossingDetector::frontiers(profile, normalize);
00058 std::vector<std::string> str_frontiers;
00059 str_frontiers.reserve(frontiers.size());
00060 for (size_t i = 0; i < frontiers.size(); ++i)
00061 {
00062 str_frontiers.push_back(to_python(frontiers[i]));
00063 }
00064 return str_frontiers;
00065 }
00066 };
00067
00068 BOOST_PYTHON_MODULE(crossing_detector_wrapper_cpp)
00069 {
00070 bp::class_<CrossingDetectorWrapper>("CrossingDetectorWrapper", bp::init<double, double>())
00071 .def("crossingDescriptor", &CrossingDetectorWrapper::crossingDescriptor)
00072 .def("frontiers", &CrossingDetectorWrapper::frontiers)
00073 ;
00074
00075 bp::to_python_converter<std::vector<std::string, std::allocator<std::string> >, vector_to_python<std::string> >();
00076 }