#!/usr/bin/env python
######################################################################
# Software License Agreement (BSD License)
#
# Copyright (c) 2010, Rice University
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the Rice University nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
######################################################################
# Author: Mark Moll
from os.path import join, dirname
from sys import argv, setrecursionlimit
from pygccxml import declarations
from pygccxml.declarations.runtime_errors import declaration_not_found_t
from pyplusplus.module_builder import call_policies
from pyplusplus import function_transformers as FT
from ompl.bindings_generator import code_generator_t, default_replacement
class ompl_base_generator_t(code_generator_t):
"""Class for generating the ompl.base python module."""
def __init__(self):
replacement = default_replacement
# special case for abstract base class Path with pure virtual print method:
replacement['::ompl::base::Path::print'] = ('def("__str__", bp::pure_virtual(&__str__))', \
"""std::string __str__(%s* obj)
{
std::ostringstream s;
obj->print(s);
return s.str();
}
""")
# A C++ call like "foo.printState(state, std::cout)" will be replaced with
# something more pythonesque: "print(foo.string(state))"
replacement['printState'] = ('def("string", &__printState)', """
std::string __printState(%s* space, ompl::base::State* state)
{
std::ostringstream s;
space->printState(state, s);
return s.str();
}
""")
# A C++ call like "foo.printProperties(std::cout)" will be replaced with
# something more pythonesque: "print(foo.properties())"
replacement['printProperties'] = ('def("properties", &__printProperties)', """
std::string __printProperties(%s* obj)
{
std::ostringstream s;
obj->printProperties(s);
return s.str();
}
""")
# A C++ call like "foo.printProjections(std::cout)" will be replaced with
# something more pythonesque: "print(foo.projections())"
replacement['printProjections'] = ('def("projections", &__printProjections)', """
std::string __printProjections(%s* obj)
{
std::ostringstream s;
obj->printProjections(s);
return s.str();
}
""")
# A C++ call like "foo.printProjection(projection, std::cout)" will be replaced with
# something more pythonesque: "print(foo.projection())"
replacement['printProjection'] = ('def("projection", &__printProjection)', """
std::string __printProjection(%s* obj, const Eigen::Ref<Eigen::VectorXd> &projection)
{
std::ostringstream s;
obj->printProjection(projection, s);
return s.str();
}
""")
# "StateSpace::Diagram(std::cout)" will be replaced with
# something more pythonesque: "print(StateSpace.Diagram())"
replacement['::ompl::base::StateSpace::Diagram'] = ('def("Diagram", &DiagramWrapper)', """
std::string DiagramWrapper(%s* obj)
{
std::ostringstream s;
obj->Diagram(s);
return s.str();
}
""")
# "StateSpace::List(std::cout)" will be replaced with
# something more pythonesque: "print(StateSpace.List())"
replacement['::ompl::base::StateSpace::List'] = ('def("List", &ListWrapper)', """
std::string ListWrapper(%s* obj)
{
std::ostringstream s;
obj->List(s);
return s.str();
}
""")
# "PlannerData::printGraphML(std::cout)" will be replaced with
# something more pythonesque: "print(PlannerData.printGraphML())"
replacement['::ompl::base::PlannerData::printGraphML'] = \
('def("printGraphML", &__printGraphML)', """
std::string __printGraphML(%s* obj)
{
std::ostringstream s;
obj->printGraphML(s);
return s.str();
}
""")
# "PlannerData::printGraphviz(std::cout)" will be replaced with
# something more pythonesque: "print(PlannerData.printGraphviz())"
replacement['::ompl::base::PlannerData::printGraphviz'] = \
('def("printGraphviz", &__printGraphviz)', """
std::string __printGraphviz(%s* obj)
{
std::ostringstream s;
obj->printGraphviz(s);
return s.str();
}
""")
# "Atlas::printPLY(std::cout)" will be replaced with
# something more pythonesque: "print(PlannerData.printGraphviz())"
replacement['::ompl::base::AtlasStateSpace::printPLY'] = \
('def("printPLY", &__printPLY)', """
std::string __printPLY(%s* obj)
{
std::ostringstream s;
obj->printPLY(s);
return s.str();
}
""")
code_generator_t.__init__(self, 'base', ['bindings/util'], replacement)
def filter_declarations(self):
# force ProblemDefinition to be included, because it is used by other modules
self.ompl_ns.class_('ProblemDefinition').include()
# force the abstract base class Path to be included, because it is used by other modules
self.ompl_ns.class_('Path').include()
code_generator_t.filter_declarations(self)
# rename STL vectors of certain types
self.std_ns.class_(
f'map< {self.string_decl}, std::shared_ptr< ompl::base::ProjectionEvaluator > >').rename(
'mapStringToProjectionEvaluator')
self.std_ns.class_('vector< ompl::base::State * >').rename('vectorState')
try:
self.std_ns.class_('vector< ompl::base::State const* >').rename('vectorConstState')
except declaration_not_found_t:
pass
self.std_ns.class_('vector< std::shared_ptr<ompl::base::StateSpace> >').rename(
'vectorStateSpacePtr')
#self.std_ns.class_('vector< <ompl::base::PlannerSolution> >').rename(
# 'vectorPlannerSolution')
self.std_ns.class_(f'map< {self.string_decl}, std::shared_ptr<ompl::base::GenericParam> >').rename(
'mapStringToGenericParam')
self.std_ns.class_(f'map< {self.string_decl}, ompl::base::StateSpace::SubstateLocation >').rename(
'mapStringToSubstateLocation')
self.std_ns.class_('vecto
OMPL按照教程安装缺少库问题的解决方法
需积分: 0 135 浏览量
2023-05-11
09:33:29
上传
评论 1
收藏 15KB ZIP 举报
Destinyjsy
- 粉丝: 421
- 资源: 2
最新资源
- 基于matlab实现夜间车牌识别程序(1).rar
- 基于matlab实现图像处理,本程序使用背景差分法对来往车辆进行检测和跟踪.rar
- 基于matlab实现视频监控中车型识别代码,自己写的,希望和大家多多交流.rar
- sdk.config
- 基于matlab实现配电网三相潮流计算方法,对几种常用的配电网潮流计算方法进行了对比分析.rar
- 基于matlab实现配电网潮流 经典33节点 前推回代法潮流计算 回代电流 前推电压 带注释.rar
- 基于matlab实现模拟退火遗传算法的车辆调度问题研究,用MATLAB语言加以实现.rar
- 基于matlab实现蒙特卡洛的的移动传感器节点定位算法仿真代码.rar
- 华中数控系统818用户说明书
- 基于matlab实现卡尔曼滤波器完成多传感器数据融合 对多个机器人的不同传感器数据进行融合估计足球精确位置.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈