Commit 990155ca authored by Florent Lamiraux's avatar Florent Lamiraux Committed by Florent Lamiraux florent@laas.fr
Browse files

Corba server to control hpp-wholebody-step-planner library.

parents
[submodule "cmake"]
path = cmake
url = git://github.com/jrl-umi3218/jrl-cmakemodules.git
# Copyright (c) 2011 CNRS
# Author: Florent Lamiraux
#
# This file is part of hpp-wholebody-step-corba.
# hpp-wholebody-step-corba is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# hpp-wholebody-step-corba is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# hpp-wholebody-step-corba. If not, see
# <http://www.gnu.org/licenses/>.
# Requires at least CMake 2.6 to configure the package.
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(CXX_DISABLE_WERROR true)
SET(CUSTOM_HEADER_DIR "hpp/wholebody-step-corba")
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/cpack.cmake)
INCLUDE(cmake/idl.cmake)
INCLUDE(cmake/python.cmake)
SET(PROJECT_NAME hpp-wholebody-step-corba)
SET(PROJECT_DESCRIPTION "Corba server and python client for hpp-wholebody-step-planner")
SET(PROJECT_URL "http://github.com/laas/hpp-wholebody-step-corba")
SET(${PROJECT_NAME}_HEADERS
include/hpp/corbaserver/wholebody-step/server.hh
include/hpp/corbaserver/wholebody-step/fwd.hh
)
SET(CUSTOM_HEADER_DIR hpp/corbaserver/wholebody-step)
SETUP_PROJECT()
# Search for dependencies.
ADD_REQUIRED_DEPENDENCY("hpp-wholebody-step-planner >= 0.1")
ADD_REQUIRED_DEPENDENCY("hpp-template-corba >= 1.1")
ADD_REQUIRED_DEPENDENCY("hpp-util >= 0.4")
# This dependency ensures us that the intermediate __init__.py files are
# already installed.
ADD_REQUIRED_DEPENDENCY("hpp-corbaserver >= 1.13")
# Make sure that python submodule is installed in the same prefix as module.
IF (NOT ${HPP_CORBASERVER_PREFIX} STREQUAL ${CMAKE_INSTALL_PREFIX})
MESSAGE(WARNING
" THIS PACKAGE SHOULD BE INSTALLED IN THE SAME PREFIX AS HPP-CORBASERVER,\n"
" SINCE IT INSTALLS A PYTHON SUBMODULE OF HPP.CORBASERVER.")
MESSAGE("CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
MESSAGE("HPP_CORBASERVER_PREFIX=${HPP_CORBASERVER_PREFIX}")
ENDIF()
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
ADD_SUBDIRECTORY(src)
SETUP_PROJECT_FINALIZE()
SETUP_PROJECT_CPACK()
This package implements a corba server and client to control
hpp-wholebody-step-planner library.
Subproject commit e86b0c1b045507ed20bd32434e248a688e43e077
INPUT = @CMAKE_SOURCE_DIR@/include @CMAKE_SOURCE_DIR@/idl
TAGFILES =\
@HPP_TEMPLATE_CORBA_DOXYGENDOCDIR@/hpp-template-corba.doxytag=@HPP_TEMPLATE_CORBA_DOXYGENDOCDIR@
FILE_PATTERNS = *.hh *.hxx *.idl
// Copyright (C) 2011,2012 CNRS-LAAS
// Author: Sebastien Dalibard.
//
// This file is part of the hpp-wholebody-step-corba.
//
// hpp-wholebody-step-corba is free software: you can redistribute
// it and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// hpp-wholebody-step-corba is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with hpp-wholebody-step-corba. If not, see
// <http://www.gnu.org/licenses/>.
module hpp {
interface WholeBodyStep {
/// Generate a goal configuration.
/// \param x, y, z: desired position of the end effector (right hand)
/// \param nbConfig Number of goal configurations to generate.
short generateGoalConfig (in double x, in double y, in double z,
in unsigned short nbConfig);
}; //interface Problem
}; // module hpp
\ No newline at end of file
// Copyright (C) 2011,2012 CNRS-LAAS
// Author: Sebastien Dalibard.
//
// This file is part of the hpp-wholebody-step-corba.
//
// hpp-wholebody-step-corba is free software: you can redistribute
// it and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// hpp-wholebody-step-corba is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with hpp-wholebody-step-corba. If not, see
// <http://www.gnu.org/licenses/>.
#ifndef HPP_WHOLEBODY_STEP_CORBA_FWD_HH
# define HPP_WHOLEBODY_STEP_CORBA_FWD_HH
namespace hpp {
namespace wholeBodyStepPlanner {
class Server;
} // namespace wholeBodyStepPlanner
} // namespace hpp
#endif // HPP_WHOLEBODY_STEP_CORBA_SERVER_HH
// Copyright (C) 2011,2012 CNRS-LAAS
// Author: Sebastien Dalibard.
//
// This file is part of the hpp-wholebody-step-corba.
//
// hpp-wholebody-step-corba is free software: you can redistribute
// it and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// hpp-wholebody-step-corba is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with hpp-wholebody-step-corba. If not, see
// <http://www.gnu.org/licenses/>.
#ifndef HPP_WHOLEBODY_STEP_CORBA_SERVER_HH
# define HPP_WHOLEBODY_STEP_CORBA_SERVER_HH
# include <hpp/corba/template/server.hh>
# include "hpp/wholebody-step-planner/fwd.hh"
namespace hpp {
namespace wholeBodyStepPlanner {
namespace impl {
class WholeBodyStep;
} // namespace impl
class Server
{
public:
Server (int argc, char *argv[], bool multiThread = false,
const std::string& poaName = "child");
~Server ();
/// Set planner that will be controlled by server
void setPlanner (Planner* planner);
/// 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& objectKind);
private:
corba::Server <impl::WholeBodyStep>* impl_;
};
} // namespace wholeBodyStepPlanner
} // namespace hpp
#endif // HPP_WHOLEBODY_STEP_CORBA_SERVER_HH
# Copyright (c) 2011 CNRS
# Author: Florent Lamiraux
#
# This file is part of hpp-wholebody-step-corba.
# hpp-wholebody-step-corba is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# hpp-wholebody-step-corba is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# hpp-wholebody-step-corba. If not, see
# <http://www.gnu.org/licenses/>.
SET(IDL_SOURCES
wholebody_step)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
FOREACH(IDL ${IDL_SOURCES})
GENERATE_IDL_FILE (${IDL}
${CMAKE_SOURCE_DIR}/idl/hpp/corbaserver/wholebody-step)
ENDFOREACH()
SET(LIBRARY_NAME ${PROJECT_NAME})
ADD_LIBRARY(${LIBRARY_NAME}
SHARED
server.cc
wholebody_step.impl.hh
wholebody_step.impl.cc
wholebody_stepSK.cc
${CMAKE_CURRENT_BINARY_DIR}/hpp/corbaserver/wholebody_step/wholebody_step_idl.py
)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-wholebody-step-planner)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-template-corba)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-util)
INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION lib)
# search for python
FINDPYTHON()
# search for omniidl
FIND_PROGRAM(OMNIIDL omniidl)
IF(${OMNIIDL} STREQUAL OMNIIDL-NOTFOUND)
MESSAGE(FATAL_ERROR "cannot find omniidl.")
ENDIF(${OMNIIDL} STREQUAL OMNIIDL-NOTFOUND)
FOREACH (IDL ${IDL_SOURCES})
ADD_CUSTOM_COMMAND(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/hpp/corbaserver/wholebody_step/${IDL}_idl.py
COMMAND ${OMNIIDL}
ARGS -bpython -Wbpackage="hpp.corbaserver.wholebody_step"
${CMAKE_SOURCE_DIR}/idl/hpp/corbaserver/wholebody-step/${IDL}.idl
MAIN_DEPENDENCY
${CMAKE_SOURCE_DIR}/idl/hpp/corbaserver/wholebody-step/${IDL}.idl
)
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_CURRENT_BINARY_DIR}/hpp/corbaserver/wholebody_step/${IDL}_idl.py
GENERATED=ON
)
INSTALL(
FILES
${CMAKE_CURRENT_BINARY_DIR}/hpp/corbaserver/wholebody_step/${IDL}_idl.py
DESTINATION ${PYTHON_SITELIB}/hpp/corbaserver/wholebody_step
)
ENDFOREACH()
INSTALL(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/hpp/corbaserver/wholebody_step/__init__.py
DESTINATION ${PYTHON_SITELIB}/hpp/corbaserver/wholebody_step
)
INSTALL(
FILES
${CMAKE_CURRENT_BINARY_DIR}/hpp/corbaserver/wholebody_step/hpp/__init__.py
DESTINATION ${PYTHON_SITELIB}/hpp/corbaserver/wholebody_step/hpp
)
INSTALL(
FILES
${CMAKE_CURRENT_BINARY_DIR}/hpp/corbaserver/wholebody_step/hpp__POA/__init__.py
DESTINATION ${PYTHON_SITELIB}/hpp/corbaserver/wholebody_step/hpp__POA
)
INSTALL(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/hpp/corbaserver/wholebody_step/client.py
DESTINATION ${PYTHON_SITELIB}/hpp/corbaserver/wholebody_step
)
# Copyright (c) 2011 CNRS
# Author: Florent Lamiraux
#
# This file is part of hpp-wholebody-step-corba.
# hpp-wholebody-step-corba is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# hpp-wholebody-step-corba is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# hpp-wholebody-step-corba. If not, see
# <http://www.gnu.org/licenses/>.
from omniORB import CORBA
import CosNaming
from hpp import WholeBodyStep
class CorbaError(Exception):
"""
Raised when a CORBA error occurs.
"""
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class Client:
"""
Connect and create clients for hpp-wholebody-step-planner library.
"""
def __init__(self):
"""
Initialize CORBA and create default clients.
"""
import sys
self.orb = CORBA.ORB_init (sys.argv, CORBA.ORB_ID)
obj = self.orb.resolve_initial_references("NameService")
self.rootContext = obj._narrow(CosNaming.NamingContext)
if self.rootContext is None:
raise CorbaError ('failed to narrow the root context')
name = [CosNaming.NameComponent ("hpp", "plannerContext"),
CosNaming.NameComponent ("hpp", "wholeBodyStep")]
try:
obj = self.rootContext.resolve (name)
except CosNaming.NamingContext.NotFound, ex:
raise CorbaError ('failed to find wholeBodyStep service.')
try:
client = obj._narrow (WholeBodyStep)
except KeyError:
raise CorbaError ('invalid service name wholebodyStep')
if client is None:
# This happens when stubs from client and server are not synchronized.
raise CorbaError (
'failed to narrow client for service wholebodyStep')
self.problem = client
// Copyright (C) 2011,2012 CNRS-LAAS
// Author: Sebastien Dalibard.
//
// This file is part of the hpp-wholebody-step-corba.
//
// hpp-wholebody-step-corba is free software: you can redistribute
// it and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// hpp-wholebody-step-corba is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with hpp-wholebody-step-corba. If not, see
// <http://www.gnu.org/licenses/>.
#include <hpp/util/exception.hh>
#include "hpp/corbaserver/wholebody-step/server.hh"
#include "wholebody_step.impl.hh"
namespace hpp {
namespace wholeBodyStepPlanner {
Server::Server (int argc, char *argv[], bool multiThread,
const std::string& poaName) :
impl_ (new corba::Server <impl::WholeBodyStep>
(argc, argv, multiThread, poaName)) {}
Server::~Server () { delete impl_;}
void Server::setPlanner (Planner* planner)
{
impl_->implementation ().setPlanner (planner);
}
/// Start corba server
void Server::startCorbaServer(const std::string& contextId,
const std::string& contextKind,
const std::string& objectId,
const std::string& objectKind)
{
if (impl_->startCorbaServer(contextId, contextKind, objectId, objectKind)
!= 0) {
HPP_THROW_EXCEPTION (hpp::Exception, "Failed to start corba server.");
}
}
} // namespace wholeBodyStepPlanner
} // namespace hpp
// Copyright (C) 2011,2012 CNRS-LAAS
// Author: Sebastien Dalibard.
//
// This file is part of the hpp-wholebody-step-corba.
//
// hpp-wholebody-step-corba is free software: you can redistribute
// it and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// hpp-wholebody-step-corba is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with hpp-wholebody-step-corba. If not, see
// <http://www.gnu.org/licenses/>.
#include <cassert>
#include <hpp/wholebody-step-planner/planner.hh>
#include "wholebody_step.impl.hh"
namespace hpp {
namespace wholeBodyStepPlanner {
namespace impl {
WholeBodyStep::WholeBodyStep () : planner_ (0) {}
void WholeBodyStep::setPlanner (Planner* planner)
{
planner_ = planner;
}
CORBA::Short WholeBodyStep::generateGoalConfig
(CORBA::Double x, CORBA::Double y, CORBA::Double z,
CORBA::UShort nbConfig)
{
assert (planner_);
return planner_->generateGoalConfig (x, y, z, nbConfig);
}
} // namespace impl
} // namespace wholeBodyStepPlanner
} // namespace hpp
// Copyright (C) 2011,2012 CNRS-LAAS
// Author: Sebastien Dalibard.
//
// This file is part of the hpp-wholebody-step-corba.
//
// hpp-wholebody-step-corba is free software: you can redistribute
// it and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// hpp-wholebody-step-corba is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with hpp-wholebody-step-corba. If not, see
// <http://www.gnu.org/licenses/>.
#ifndef HPP_WHOLEBODY_STEP_CORBA_WHOLEBODY_STEP_HH
# define HPP_WHOLEBODY_STEP_CORBA_WHOLEBODY_STEP_HH
# include <omniORB4/CORBA.h>
# include <hpp/wholebody-step-planner/fwd.hh>
# include "wholebody_step.hh"
namespace hpp {
namespace wholeBodyStepPlanner {
namespace impl {
class WholeBodyStep : public virtual POA_hpp::WholeBodyStep
{
public:
WholeBodyStep ();
void setPlanner (Planner* planner);
virtual CORBA::Short
generateGoalConfig (CORBA::Double x, CORBA::Double y, CORBA::Double z,
CORBA::UShort nbConfig);
private:
Planner* planner_;
}; // class WholeBodyStep
} // namespace impl
} // namespace wholeBodyStepPlanner
} // namespace hpp
#endif //HPP_WHOLEBODY_STEP_CORBA_WHOLEBODY_STEP_HH
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment