diff --git a/CMakeLists.txt b/CMakeLists.txt index ba9cbeea3a736ef0fad2a95cf0a37cbcbe3621c9..3102769e7384311201816c9511262403ca6ff06d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,11 +35,13 @@ SET(CUSTOM_HEADER_DIR hpp/corbaserver/rbprm) SETUP_HPP_PROJECT () +LIST(APPEND PKG_CONFIG_ADDITIONAL_VARIABLES cmake_plugin) + SET(${PROJECT_NAME}_HEADERS include/hpp/corbaserver/rbprm/server.hh ) -FINDPYTHON() +HPP_FINDPYTHON() ADD_DOC_DEPENDENCY("hpp-core >= 4.3") ADD_REQUIRED_DEPENDENCY("hpp-corbaserver >= 4.3") diff --git a/include/hpp/corbaserver/rbprm/server.hh b/include/hpp/corbaserver/rbprm/server.hh index 6825a1f9294d6de3facffa8151660f97f4b19042..aa68096a77c7be360b4341cb9b71cf441c2ebcde 100644 --- a/include/hpp/corbaserver/rbprm/server.hh +++ b/include/hpp/corbaserver/rbprm/server.hh @@ -21,29 +21,30 @@ # define HPP_RBPRM_CORBA_SERVER_HH # include <hpp/corba/template/server.hh> -# include <hpp/corbaserver/rbprm/config.hh> + # include <hpp/corbaserver/problem-solver-map.hh> +# include <hpp/corbaserver/rbprm/config.hh> +# include <hpp/corbaserver/server-plugin.hh> namespace hpp { namespace rbprm { namespace impl { class RbprmBuilder; } - class HPP_RBPRM_CORBA_DLLAPI Server + class HPP_RBPRM_CORBA_DLLAPI Server : public corbaServer::ServerPlugin { public: - Server (int argc, const char *argv[], bool multiThread = false, - const std::string& poaName = "child"); + Server (corbaServer::Server* parent); + ~Server (); - /// Set planner that will be controlled by server - void setProblemSolverMap (hpp::corbaServer::ProblemSolverMapPtr_t psMap); /// Start corba server - /// Call hpp::corba::Server <impl::Problem>::startCorbaServer void startCorbaServer(const std::string& contextId, - const std::string& contextKind, - const std::string& objectId); + const std::string& contextKind); + + std::string name () const; + public: corba::Server <impl::RbprmBuilder>* rbprmBuilder_; }; // class Server diff --git a/script/scenarios/demos/darpa_hyq.py b/script/scenarios/demos/darpa_hyq.py index aff1edf5c47418e4a1ffcd71fd2f67b6995dd962..a6bb26a4b2b732558ecae71528907fd316741294 100644 --- a/script/scenarios/demos/darpa_hyq.py +++ b/script/scenarios/demos/darpa_hyq.py @@ -103,7 +103,7 @@ def genPlan(stepsize=0.06): start = time.time() configs = fullBody.interpolate(stepsize, 5, 0., filterStates = True,testReachability = False) end = time.time() - print "Contact plan generated in " + str(end-start) + "seconds" + print("Contact plan generated in " + str(end-start) + "seconds") def contactPlan(step = 0.5): v.client.gui.setVisibility("hyq", "ON") @@ -115,6 +115,6 @@ def contactPlan(step = 0.5): time.sleep(step) -print "Root path generated in " + str(tp.t) + " ms." +print("Root path generated in " + str(tp.t) + " ms.") genPlan(0.01);contactPlan(0.01) diff --git a/script/scenarios/demos/darpa_hyq_path.py b/script/scenarios/demos/darpa_hyq_path.py index 60f30022f032979e710df35c8d46179246a08869..c98745c52256588021a4090537f7872a1b4d8450 100644 --- a/script/scenarios/demos/darpa_hyq_path.py +++ b/script/scenarios/demos/darpa_hyq_path.py @@ -57,7 +57,7 @@ t = ps.solve () if isinstance(t, list): t = t[0]* 3600000 + t[1] * 60000 + t[2] * 1000 + t[3] -print "computation time for root path ", t +print("computation time for root path ", t) # Playing the computed path from hpp.gepetto import PathPlayer diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 05caec46481f3d1dbbb0a0b0cf8144ffe7b79503..07500b954c5799effb221134691d11d0ebde307c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,6 +20,8 @@ SET(IDL_SOURCES rbprmbuilder ) +INCLUDE(${HPP_CORBASERVER_CMAKE_PLUGIN}) + OMNIIDL_INCLUDE_DIRECTORIES( ${HPP_CORBASERVER_DATAROOTDIR}/idl ${CMAKE_SOURCE_DIR}/idl ) @@ -51,27 +53,25 @@ INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/hpp_stubs/rbprm DESTINATION ${PYTHON_SITELIB}/hpp_stubs) -ADD_LIBRARY(${LIBRARY_NAME} SHARED +HPP_ADD_SERVER_PLUGIN(rbprm-corba + SOURCES ${ALL_IDL_CPP_STUBS} rbprmbuilder.impl.cc rbprmbuilder.impl.hh server.cc -) + + PKG_CONFIG_DEPENDENCIES + hpp-rbprm + hpp-corbaserver + omniORB4 + hpp-util + hpp-rbprm) ADD_CUSTOM_TARGET(generate_idl_cpp DEPENDS ${ALL_IDL_CPP_STUBS}) ADD_CUSTOM_TARGET(generate_idl_python DEPENDS ${ALL_IDL_PYTHON_STUBS}) -ADD_DEPENDENCIES (${LIBRARY_NAME} generate_idl_cpp) -ADD_DEPENDENCIES (${LIBRARY_NAME} generate_idl_python) -TARGET_INCLUDE_DIRECTORIES(${LIBRARY_NAME} PUBLIC ${CDD_INCLUDE_DIRS}) - -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-rbprm) -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-corbaserver) -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} omniORB4) -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-affordance-corba) -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-util) -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-rbprm) - -INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION lib) +ADD_DEPENDENCIES (rbprm-corba generate_idl_cpp) +ADD_DEPENDENCIES (rbprm-corba generate_idl_python) +TARGET_INCLUDE_DIRECTORIES(rbprm-corba PUBLIC ${CDD_INCLUDE_DIRS}) INSTALL( FILES @@ -102,7 +102,8 @@ INSTALL( ) # Stand alone corba server ADD_EXECUTABLE (hpp-rbprm-server hpp-rbprm-corba.cc) -TARGET_LINK_LIBRARIES (hpp-rbprm-server ${LIBRARY_NAME} hpp-rbprm) + +PKG_CONFIG_USE_DEPENDENCY(hpp-rbprm-server hpp-corbaserver) PKG_CONFIG_USE_DEPENDENCY(hpp-rbprm-server hpp-pinocchio) INSTALL (TARGETS hpp-rbprm-server DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/hpp-rbprm-corba.cc b/src/hpp-rbprm-corba.cc index 7e0408706618222b2e2417d3a60847ecf5c362bd..5393dd95ea1f3646ce09146eb8c763c177565c8f 100644 --- a/src/hpp-rbprm-corba.cc +++ b/src/hpp-rbprm-corba.cc @@ -16,31 +16,18 @@ // <http://www.gnu.org/licenses/>. #include <hpp/corbaserver/server.hh> -#include <hpp/corbaserver/affordance/server.hh> -#include <hpp/corbaserver/rbprm/server.hh> #include <hpp/core/problem-solver.hh> -typedef hpp::rbprm::Server RbprmServer; typedef hpp::corbaServer::Server CorbaServer; -typedef hpp::affordanceCorba::Server AffordanceServer; int main (int argc, char* argv []) { hpp::core::ProblemSolverPtr_t problemSolver (hpp::core::ProblemSolver::create()); - CorbaServer corbaServer (problemSolver, argc, const_cast<const char**> (argv), true); - AffordanceServer affordanceServer (argc, const_cast<const char**> (argv), - true); - affordanceServer.setProblemSolverMap(corbaServer.problemSolverMap()); - - RbprmServer rbprmServer (argc, const_cast<const char**> (argv), - true, "rbprmChild"); - rbprmServer.setProblemSolverMap (corbaServer.problemSolverMap()); corbaServer.startCorbaServer (); - affordanceServer.startCorbaServer ("hpp", "corbaserver", - "affordanceCorba", "affordance"); - rbprmServer.startCorbaServer ("hpp", "corbaserver", "rbprm"); + corbaServer.loadPlugin (corbaServer.mainContextId (), "rbprm-corba.so"); + corbaServer.loadPlugin (corbaServer.mainContextId (), "affordance-corba.so"); corbaServer.processRequest(true); } diff --git a/src/rbprmbuilder.impl.cc b/src/rbprmbuilder.impl.cc index 1eaa00e2693c9a1b89b4a8b4894c0d6bad048c9e..238e9500a83d97351c0868aa6a39a4aaca907f33 100644 --- a/src/rbprmbuilder.impl.cc +++ b/src/rbprmbuilder.impl.cc @@ -3319,13 +3319,6 @@ namespace hpp { } } - void RbprmBuilder::SetProblemSolverMap (hpp::corbaServer::ProblemSolverMapPtr_t psMap) - { - psMap_ = psMap; - //bind shooter creator to hide problem as a parameter and respect signature - //initNewProblemSolver(); - } - void RbprmBuilder::initNewProblemSolver() { //bind shooter creator to hide problem as a parameter and respect signature diff --git a/src/rbprmbuilder.impl.hh b/src/rbprmbuilder.impl.hh index 1d5a837017e5fbfffdfc8b87cf38b211a35c5978..ab8639b2252a3a5a5eca6572a66bb1a8e554a116 100644 --- a/src/rbprmbuilder.impl.hh +++ b/src/rbprmbuilder.impl.hh @@ -37,6 +37,7 @@ # include <hpp/core/config-validations.hh> #include <hpp/rbprm/dynamic/dynamic-path-validation.hh> # include "hpp/corbaserver/fwd.hh" +# include "hpp/corbaserver/rbprm/server.hh" namespace hpp { namespace rbprm { @@ -168,6 +169,11 @@ namespace hpp { public: RbprmBuilder (); + void setServer (Server* server) + { + server_ = server; + } + virtual void loadRobotRomModel (const char* robotName, const char* rootJointType, const char* packageName, @@ -377,12 +383,12 @@ namespace hpp { void initNewProblemSolver (); private: - /// \brief Pointer to hppPlanner object of hpp::corbaServer::Server. - corbaServer::ProblemSolverMapPtr_t psMap_; core::ProblemSolverPtr_t problemSolver() { - return psMap_->selected(); + return server_->problemSolver(); } + + Server* server_; FullBodyMap fullBodyMap_; rbprm::RbPrmFullBodyPtr_t fullBody() { diff --git a/src/server.cc b/src/server.cc index 9f4aa2306958c5ec12096c7ba4270aac70de942b..e431bc2560625093d14fc768e481dcde269626b3 100644 --- a/src/server.cc +++ b/src/server.cc @@ -17,37 +17,44 @@ // License along with hpp-manipulation-corba. If not, see // <http://www.gnu.org/licenses/>. +#include <hpp/corbaserver/rbprm/server.hh> + #include <hpp/util/exception.hh> #include "rbprmbuilder.impl.hh" -#include <hpp/corbaserver/rbprm/server.hh> +#include <hpp/corbaserver/server.hh> namespace hpp { namespace rbprm { - Server::Server (int argc, const char *argv[], bool multiThread, - const std::string& poaName) : - rbprmBuilder_ (new corba::Server <impl::RbprmBuilder> - (argc, argv, multiThread, poaName)) {} + Server::Server (corbaServer::Server* server) + : corbaServer::ServerPlugin (server), + rbprmBuilder_ (NULL) + {} Server::~Server () { - delete rbprmBuilder_; + if (rbprmBuilder_) delete rbprmBuilder_; } - void Server::setProblemSolverMap (hpp::corbaServer::ProblemSolverMapPtr_t psMap) + std::string Server::name () const { - rbprmBuilder_->implementation ().SetProblemSolverMap(psMap); + return "rbprm"; } /// Start corba server void Server::startCorbaServer(const std::string& contextId, - const std::string& contextKind, - const std::string& objectId) + const std::string& contextKind) { + bool mThd = parent()->multiThread(); + rbprmBuilder_ = new corba::Server <impl::RbprmBuilder> (0, NULL, mThd, "child"); + rbprmBuilder_->implementation ().setServer (this); + if (rbprmBuilder_->startCorbaServer(contextId, contextKind, - objectId, "rbprmbuilder") != 0) { - HPP_THROW_EXCEPTION (hpp::Exception, - "Failed to start corba rbprm server."); + "rbprm", "rbprmbuilder") != 0) { + HPP_THROW_EXCEPTION (hpp::Exception, + "Failed to start corba rbprm server."); } } } // namespace rbprm } // namespace hpp + +HPP_CORBASERVER_DEFINE_PLUGIN(hpp::rbprm::Server)