diff --git a/CMakeLists.txt b/CMakeLists.txt index d72852b9b4897da8b31d4f1d087cd34a565cbf43..f7df51814750b746271c8bb54dcd41bc7eccaf67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,18 @@ -# Copyright (c) 2012 CNRS -# Author: Florent Lamiraux +# Copyright (c) 2014 CNRS +# Author: Mathieu Geisert, Florent Lamiraux # -# This file is part of hpp-corbaserver. -# hpp-corbaserver is free software: you can redistribute it +# This file is part of gepetto-viewer-corba. +# gepetto-viewer-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-corbaserver is distributed in the hope that it will be +# gepetto-viewer-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-corbaserver. If not, see +# gepetto-viewer-corba. If not, see # <http://www.gnu.org/licenses/>. # Requires at least CMake 2.6 to configure the package. @@ -21,17 +21,17 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(CXX_DISABLE_WERROR true) INCLUDE(cmake/base.cmake) -INCLUDE(cmake/cpack.cmake) INCLUDE(cmake/idl.cmake) INCLUDE(cmake/python.cmake) INCLUDE(cmake/boost.cmake) -SET(PROJECT_NAME SceneViewer-corba) -SET(PROJECT_DESCRIPTION "Corba server for SceneViewer") +SET(PROJECT_NAME gepetto-viewer-corba) +SET(PROJECT_DESCRIPTION "Corba server for gepetto-viewer") SET(PROJECT_URL "") SET(${PROJECT_NAME}_HEADERS - src/client-cpp.hh + include/gepetto/viewer/corba/client.hh + include/gepetto/viewer/corba/se3.hh ) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) @@ -41,9 +41,8 @@ SETUP_PROJECT () # Dependencies ADD_REQUIRED_DEPENDENCY("omniORB4 >= 4.1.4") -ADD_REQUIRED_DEPENDENCY("openscenegraph >= 3.2") ADD_REQUIRED_DEPENDENCY("openthreads >= 3.2") -ADD_REQUIRED_DEPENDENCY("SceneViewer") +ADD_REQUIRED_DEPENDENCY("gepetto-viewer") ADD_REQUIRED_DEPENDENCY("urdfdom") ADD_REQUIRED_DEPENDENCY("eigen3 >= v3.0.5") SEARCH_FOR_BOOST() @@ -53,4 +52,3 @@ INCLUDE_DIRECTORIES(SYSTEM ${EIGEN3_INCLUDE_DIRS}) ADD_SUBDIRECTORY(src) SETUP_PROJECT_FINALIZE() -#SETUP_PROJECT_CPACK() diff --git a/idl/Graphics/corbaserver/graphicalinterface.idl b/idl/gepetto/viewer/graphical-interface.idl similarity index 99% rename from idl/Graphics/corbaserver/graphicalinterface.idl rename to idl/gepetto/viewer/graphical-interface.idl index 6341ac546fc1660196aba6ec5741e023bff4de3a..b0b3febd9d0fffa4a1daa9bd179fff4e54435497 100644 --- a/idl/Graphics/corbaserver/graphicalinterface.idl +++ b/idl/gepetto/viewer/graphical-interface.idl @@ -1,5 +1,5 @@ // file graphicalinterface.idl -module Graphics { +module gepetto { module corbaserver { // Comments : @@ -16,7 +16,7 @@ typedef double Position [3]; typedef double Color [4]; /// Corba exception travelling through the Corba channel - interface Graphicalinterface { + interface GraphicalInterface { /// Set time between window frames /// \param input rate : waiting time (ms) between two frames. diff --git a/src/client-cpp.hh b/include/gepetto/viewer/corba/client.hh similarity index 93% rename from src/client-cpp.hh rename to include/gepetto/viewer/corba/client.hh index 7361b9adf5e05fec9070fd8df13089b0982e3fff..f40f0993b95a6058c3f9b6733c8c740fddd44c21 100644 --- a/src/client-cpp.hh +++ b/include/gepetto/viewer/corba/client.hh @@ -11,18 +11,18 @@ #include <iostream> #include <omniORB4/CORBA.h> -#include "se3.hpp" -#include "graphicalinterface.hh" +#include <gepetto/viewer/corba/se3.hh> +#include <gepetto/viewer/corba/graphical-interface.hh> -namespace Graphics { +namespace graphics { namespace corbaServer { class ClientCpp { private: CORBA::ORB_var orb_; - Graphics::corbaserver::Graphicalinterface_var manager_; + gepetto::corbaserver::GraphicalInterface_var manager_; static void se3ToCorba(CORBA::Double* corbaPosition, const se3::SE3& se3position); @@ -86,6 +86,6 @@ public: }; //end of class ClientCpp } //end of namespace corbaserver -} //end of namespace Graphics +} //end of namespace graphics #endif // SCENEVIEWER_CORBASERVER_CLIENTCPP_HH diff --git a/src/se3.hpp b/include/gepetto/viewer/corba/se3.hh similarity index 100% rename from src/se3.hpp rename to include/gepetto/viewer/corba/se3.hh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5eac5764e52df085bac5ee9e2107257919d87b22..949ec3c283d430c82fe7aaca8b5aa117ee141ff6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,102 +17,116 @@ SET(LIBRARY_NAME ${PROJECT_NAME}) SET(IDL_SOURCES - graphicalinterface + graphical-interface ) OMNIIDL_INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/idl) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/src) FOREACH(IDL ${IDL_SOURCES}) GENERATE_IDL_FILE (${IDL} - ${CMAKE_SOURCE_DIR}/idl/Graphics/corbaserver) + ${CMAKE_SOURCE_DIR}/idl/gepetto/viewer) + FILE(MAKE_DIRECTORY gepetto/viewer/corba) ENDFOREACH() ADD_LIBRARY(${LIBRARY_NAME} SHARED - graphicalinterface.hh - graphicalinterfaceSK.cc - GraphicalInterface.impl.cpp - GraphicalInterface.impl.hh + graphical-interfaceSK.cc + graphical-interface.impl.cpp + graphical-interface.impl.hh server.hh server.cc server-private.cc server-private.hh client-cpp.cc - client-cpp.hh - se3.hpp - ${CMAKE_CURRENT_BINARY_DIR}/Graphics/corbaserver/graphicalinterface_idl.py + ${CMAKE_CURRENT_BINARY_DIR}/gepetto/corbaserver/graphical-interface_idl.py + ${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba/graphical-interface.hh ) PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} omniORB4) -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} openscenegraph) -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} openthreads) -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} SceneViewer) +PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} gepetto-viewer) PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} urdfdom) -#PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} eigen3) -#PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} boost) +TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES}) INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION lib) # search for python FINDPYTHON() +MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba) + FOREACH (IDL ${IDL_SOURCES}) ADD_CUSTOM_COMMAND( OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/Graphics/corbaserver/${IDL}_idl.py + ${CMAKE_CURRENT_BINARY_DIR}/gepetto/corbaserver/${IDL}_idl.py COMMAND ${OMNIIDL} ARGS -bpython -Wbpackage="" -I${CMAKE_SOURCE_DIR}/idl - ${CMAKE_SOURCE_DIR}/idl/Graphics/corbaserver/${IDL}.idl + ${CMAKE_SOURCE_DIR}/idl/gepetto/viewer/${IDL}.idl + MAIN_DEPENDENCY + ${CMAKE_SOURCE_DIR}/idl/gepetto/viewer/${IDL}.idl + ) + ADD_CUSTOM_COMMAND( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba/${IDL}.hh + COMMAND ${OMNIIDL} + ARGS -bcxx -C${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba + -I${CMAKE_SOURCE_DIR}/idl + ${CMAKE_SOURCE_DIR}/idl/gepetto/viewer/${IDL}.idl MAIN_DEPENDENCY - ${CMAKE_SOURCE_DIR}/idl/Graphics/corbaserver/${IDL}.idl + ${CMAKE_SOURCE_DIR}/idl/gepetto/viewer/${IDL}.idl ) SET_SOURCE_FILES_PROPERTIES( ${CMAKE_CURRENT_BINARY_DIR}/${IDL}_idl.py + ${CMAKE_CURRENT_BINARY_DIR}/${IDL}.hh + ${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba/${IDL}.hh GENERATED=ON ) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${IDL}.hh + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gepetto/viewer/corba) + + STRING(REGEX REPLACE "-" "_" + IDL_UNDERSCORE "${IDL}") + INSTALL( FILES - ${CMAKE_CURRENT_BINARY_DIR}/${IDL}_idl.py - DESTINATION ${PYTHON_SITELIB}/Graphics/corbaserver + ${CMAKE_CURRENT_BINARY_DIR}/${IDL_UNDERSCORE}_idl.py + DESTINATION ${PYTHON_SITELIB}/gepetto/corbaserver ) ENDFOREACH() INSTALL( FILES - ${CMAKE_CURRENT_SOURCE_DIR}/Graphics/__init__.py - ${CMAKE_CURRENT_SOURCE_DIR}/Graphics/quaternion.py - DESTINATION ${PYTHON_SITELIB}/Graphics + ${CMAKE_CURRENT_SOURCE_DIR}/gepetto/__init__.py + ${CMAKE_CURRENT_SOURCE_DIR}/gepetto/quaternion.py + DESTINATION ${PYTHON_SITELIB}/gepetto ) INSTALL( FILES - ${CMAKE_CURRENT_SOURCE_DIR}/Graphics/corbaserver/__init__.py - DESTINATION ${PYTHON_SITELIB}/Graphics/corbaserver + ${CMAKE_CURRENT_SOURCE_DIR}/gepetto/corbaserver/__init__.py + DESTINATION ${PYTHON_SITELIB}/gepetto/corbaserver ) INSTALL( FILES - ${CMAKE_CURRENT_SOURCE_DIR}/Graphics/corbaserver/client.py - DESTINATION ${PYTHON_SITELIB}/Graphics/corbaserver + ${CMAKE_CURRENT_SOURCE_DIR}/gepetto/corbaserver/client.py + DESTINATION ${PYTHON_SITELIB}/gepetto/corbaserver ) INSTALL( FILES - ${CMAKE_SOURCE_DIR}/idl/Graphics/corbaserver/graphicalinterface.idl - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/idl/Graphics/corbaserver + ${CMAKE_SOURCE_DIR}/idl/gepetto/viewer/graphical-interface.idl + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/idl/gepetto/corbaserver ) -# Standalone corba server -ADD_EXECUTABLE (SceneViewercorbaserver SceneViewer-corbaserver.cc) -TARGET_LINK_LIBRARIES(SceneViewercorbaserver ${LIBRARY_NAME}) -TARGET_LINK_LIBRARIES(SceneViewercorbaserver SceneViewer) -TARGET_LINK_LIBRARIES(SceneViewercorbaserver urdfdom_model) -TARGET_LINK_LIBRARIES(SceneViewercorbaserver ${Boost_LIBRARIES}) +INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/graphical-interface.hh + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gepetto/viewer/corba + ) +# Standalone corba server +ADD_EXECUTABLE (gepetto-viewer-server corbaserver.cc) +TARGET_LINK_LIBRARIES(gepetto-viewer-server ${LIBRARY_NAME}) +#TARGET_LINK_LIBRARIES(gepetto-viewer-server ${Boost_LIBRARIES}) -ADD_EXECUTABLE (clientTest ../test/test-client-cpp.cc) -TARGET_LINK_LIBRARIES(clientTest ${LIBRARY_NAME}) -TARGET_LINK_LIBRARIES(clientTest SceneViewer) -TARGET_LINK_LIBRARIES(clientTest urdfdom_model) -TARGET_LINK_LIBRARIES(clientTest ${Boost_LIBRARIES}) -#TARGET_LINK_LIBRARIES(clientTest eigen3) +ADD_EXECUTABLE (client-test test-client-cpp.cc) +TARGET_LINK_LIBRARIES(client-test ${LIBRARY_NAME}) +PKG_CONFIG_USE_DEPENDENCY(client-test gepetto-viewer) -INSTALL (TARGETS SceneViewercorbaserver DESTINATION bin) -INSTALL (TARGETS clientTest DESTINATION bin) +INSTALL (TARGETS gepetto-viewer-server DESTINATION bin) +INSTALL (TARGETS client-test DESTINATION bin) diff --git a/src/Graphics/corbaserver/__init__.py b/src/Graphics/corbaserver/__init__.py deleted file mode 100644 index c6115dd6f3195e9a7cdb0c287adaccbd964108f6..0000000000000000000000000000000000000000 --- a/src/Graphics/corbaserver/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -import omniORB -omniORB.updateModule("Graphics.corbaserver") - -import graphicalinterface_idl - -from client import Client - diff --git a/src/Graphics/corbaserver/__init__.py~ b/src/Graphics/corbaserver/__init__.py~ deleted file mode 100644 index 5bba82f9659a12e267958a4f83b5d88ddba79d46..0000000000000000000000000000000000000000 --- a/src/Graphics/corbaserver/__init__.py~ +++ /dev/null @@ -1,7 +0,0 @@ -import omniORB -omniORB.updateModule("Graphics.corbaserver") - -import sceneViewer_idl - -from client import Client - diff --git a/src/Graphics/corbaserver/client.py~ b/src/Graphics/corbaserver/client.py~ deleted file mode 100644 index 7cdd9bfb2541a533cd602019872ee02e5e44eb35..0000000000000000000000000000000000000000 --- a/src/Graphics/corbaserver/client.py~ +++ /dev/null @@ -1,65 +0,0 @@ -""" -Provide a client for CORBA services which initialize CORBA automatically and -create client to wanted HPP services. -""" -from omniORB import CORBA -import CosNaming - -import Graphics.corbaserver - -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 all HPP services. - """ - - defaultClients = ['graphicalinterface'] - - def makeClient(self, serviceName): - """ - Create a client to a new CORBA service and add it to this class. - """ - serviceName = serviceName.lower () - name = [CosNaming.NameComponent ("Graphics", "corbaserver"), - CosNaming.NameComponent ("basic", serviceName)] - - try: - obj = self.rootContext.resolve (name) - except CosNaming.NamingContext.NotFound, ex: - raise CorbaError ( - 'failed to find the service ``{0}\'\''.format (serviceName)) - - try: - client = obj._narrow (Graphics.corbaserver.__dict__[serviceName.capitalize ()]) - except KeyError: - raise CorbaError ('invalid service name ``{0}\'\''.format (serviceName)) - - if client is None: - # This happens when stubs from client and server are not synchronized. - raise CorbaError ( - 'failed to narrow client for service named ``{0}\'\''.format - (serviceName)) - self.__dict__[serviceName] = client - - - def __init__(self, clients = defaultClients): - """ - 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') - - for client in clients: - self.makeClient (client) diff --git a/src/Graphics/corbaserver/parser.py~ b/src/Graphics/corbaserver/parser.py~ deleted file mode 100644 index 5e68be99410e751075da06681ab77f8b7fd21d26..0000000000000000000000000000000000000000 --- a/src/Graphics/corbaserver/parser.py~ +++ /dev/null @@ -1,49 +0,0 @@ -from xml.dom.minidom import parse - -def isFloat (string): - try: - float (string) - return True - except ValueError: - return False - -class Parser (object): - """ - Parser of srdf file that looks for robot grippers. - """ - def __init__ (self, client, objectName, filename): - """ - Constructor takes a client to corba server. - """ - self.objectName = objectName - self.filename = filename - self.client = client - self.tree = parse (filename) - -def parseGrippers (self): - nodeList = self.tree.getElementsByTagName ('robot') - if nodeList.length is 0: - raise RuntimeError ("file " + - self.filename + ' has no node "robot"') - robotElement = nodeList [0] - # Parse grippers - grippers = robotElement.getElementsByTagName ('gripper') - for h in grippers: - gripperName = str (h.attributes ['name'].nodeValue) - handlePositionsInJoint = h.getElementsByTagName ('handle_position_in_joint') - if not handlePositionsInJoint.length is 1: - raise RuntimeError ('expected 1 tag "local_position", ' + - 'but found %i.'%handlePositionsInJoint.length) - handlePositionInJoint = handlePositionsInJoint [0] - position = handlePositionInJoint.childNodes [0].nodeValue - handlePositionInJoint = map (float, (filter (isFloat, - position.split (' ')))) - links = h.getElementsByTagName ('link') - if not links.length is 1: - raise RuntimeError ('expected 1 tag "link", ' + - 'but found %i.'%links.length) - link = links [0] - linkName = str (link.attributes ['name'].nodeValue) - - self.client.robot.addGripper (self.objectName, linkName, gripperName, - handlePositionInJoint) diff --git a/src/Graphics/corbaserver/robot.py~ b/src/Graphics/corbaserver/robot.py~ deleted file mode 100644 index 30e283a7548f18af2ccb95f1b304b0d1b387a634..0000000000000000000000000000000000000000 --- a/src/Graphics/corbaserver/robot.py~ +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2014 CNRS -# Author: Florent Lamiraux -# -# This file is part of hpp-corbaserver. -# hpp-corbaserver 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-corbaserver 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-corbaserver. If not, see -# <http://www.gnu.org/licenses/>. - -from hpp.corbaserver.client import Client -from srdf_parser import Parser as SrdfPerser - -class Robot (object): - def __init__ (self, robotName, rootJointType): - self.tf_root = "base_link" - self.rootJointType = rootJointType - self.client = Client () - self.loadModel (robotName, rootJointType) - self.jointNames = self.client.robot.getJointNames () - self.rankInConfiguration = dict () - self.rankInVelocity = dict () - rankInConfiguration = rankInVelocity = 0 - for j in self.jointNames: - self.rankInConfiguration [j] = rankInConfiguration - rankInConfiguration += self.client.robot.getJointConfigSize (j) - self.rankInVelocity [j] = rankInVelocity - rankInVelocity += self.client.robot.getJointNumberDof (j) - - def loadModel (self, robotName, rootJointType): - self.client.robot.loadRobotModel (robotName, rootJointType, - self.packageName, self.urdfName, - self.urdfSuffix, self.srdfSuffix) - self.ParseGrippers(robotName) - - def ParseGrippers(self, robotName): - # Read srdf file for object specific informations (gripper). - # Build filename from ROS_PACKAGE_PATH - import os - ros_package_path = os.getenv ('ROS_PACKAGE_PATH').split(":") - path = None - for p in ros_package_path: - if os.path.exists (p + '/' + self.packageName): - path = p + '/' + self.packageName - break - if not path: - raise IOError ("package " + self.packageName + " not found") - filename = path + '/' + 'srdf/' + self.urdfName + self.srdfSuffix + '.srdf' - parser = SrdfParser (self.client, robotName, filename) - parser.parseGrippers () - - ## Get size of configuration - # \return size of configuration - def getConfigSize (self): - return self.client.robot.getConfigSize () - - # Get size of velocity - # \return size of velocity - def getNumberDof (self): - return self.client.robot.getNumberDof () - ## \} - - ## \name Joints - #\{ - - ## Get joint names in the same order as in the configuration. - def getJointNames (self): - return self.client.robot.getJointNames () - - ## Get joint position. - def getJointPosition (self, jointName): - return self.client.robot.getJointPosition (jointName) - - ## Get joint number degrees of freedom. - def getJointNumberDof (self, jointName): - return self.client.robot.getJointNumberDof (jointName) - - ## Get joint number config size. - def getJointConfigSize (self, jointName): - return self.client.robot.getJointConfigSize (jointName) - - ## set bounds for the joint - def setJointBounds (self, jointName, inJointBound): - return self.client.robot.setJointBounds (jointName, inJointBound) - - ## Set bounds on the translation part of the freeflyer joint. - # - # Valid only if the robot has a freeflyer joint. - def setTranslationBounds (self, xmin, xmax, ymin, ymax, zmin, zmax): - self.client.robot.setJointBounds ("base_joint_x", [xmin, xmax]) - self.client.robot.setJointBounds ("base_joint_y", [ymin, ymax]) - self.client.robot.setJointBounds ("base_joint_z", [zmin, zmax]) - ## \} - - ## \name Configurations - #\{ - - ## Set current configuration of composite robot - # - # \param q configuration of the composite robot - def setCurrentConfig (self, q): - self.client.robot.setCurrentConfig (q) - - ## Get current configuration of composite robot - # - # \return configuration of the composite robot - def getCurrentConfig (self): - return self.client.robot.getCurrentConfig () - - ## Shoot random configuration - # \return dofArray Array of degrees of freedom. - def shootRandomConfig(self): - return self.client.robot.shootRandomConfig () - - ## \} - - ## \name Collision checking and distance computation - # \{ - - ## Test collision with obstacles and auto-collision. - # - # Check whether current configuration of robot is valid by calling - # CkwsDevice::collisionTest (). - # \return whether configuration is valid - def collisionTest (self): - return self.client.robot.collisionTest () - - ## Compute distances between bodies and obstacles - # - # \return list of distances, - # \return names of the objects belonging to a body - # \return names of the objects tested with inner objects, - # \return closest points on the body, - # \return closest points on the obstacles - # \note outer objects for a body can also be inner objects of another - # body. - def distancesToCollision (self): - return self.client.robot.distancesToCollision () - ## \} - ## \name Mass and inertia - # \{ - - ## Get mass of robot - def getMass (self): - return self.client.robot.getMass () - - ## Get position of center of mass - def getCenterOfMass (self): - return self.client.robot.getCenterOfMass () - ## Get Jacobian of the center of mass - def getJacobianCenterOfMass (self): - return self.client.robot.getJacobianCenterOfMass () - ##\} - -## Humanoid robot -# -# Method loadModel builds a humanoid robot. -class HumanoidRobot (Robot): - - def __init__ (self, robotName, rootJointType): - Robot.__init__ (self, robotName, rootJointType) - def loadModel (self, robotName, rootJointType): - self.client.robot.loadHumanoidModel (robotName, rootJointType, - self.packageName, self.urdfName, - self.urdfSuffix, self.srdfSuffix) - self.ParseGrippers(robotName) diff --git a/src/client-cpp.cc b/src/client-cpp.cc index 9ceec770d21d48cb14d241455946178f9f08567c..fde7f70ab449e8c4976826ce207ebea5f2688e20 100644 --- a/src/client-cpp.cc +++ b/src/client-cpp.cc @@ -6,9 +6,9 @@ // Copyright (c) 2014 LAAS-CNRS. All rights reserved. // -#include "client-cpp.hh" +#include <gepetto/viewer/corba/client.hh> -namespace Graphics { +namespace graphics { namespace corbaServer { void ClientCpp::se3ToCorba(CORBA::Double* corbaPosition, const se3::SE3& se3position) @@ -37,14 +37,15 @@ ClientCpp::ClientCpp() CosNaming::Name name; name.length(2); - name[0].id = (const char *) "Graphics"; - name[0].kind = (const char *) "corbaserver"; - name[1].id = (const char *) "basic"; - name[1].kind = (const char *) "graphicalinterface"; + name[0].id = (const char *) "gepetto"; + name[0].kind = (const char *) "viewer"; + name[1].id = (const char *) "corbaserver"; + name[1].kind = (const char *) "gui"; // Invoke the root context to retrieve the object reference CORBA::Object_var managerObj = nc->resolve(name); // Narrow the previous object to obtain the correct type - manager_ = Graphics::corbaserver::Graphicalinterface::_narrow(managerObj.in()); + manager_ = + gepetto::corbaserver::GraphicalInterface::_narrow(managerObj.in()); } ClientCpp::~ClientCpp() @@ -211,4 +212,4 @@ bool ClientCpp::setLightingMode(const char* nodeName, const char* lightingMode) } } // end of namespace corbaserver -} // end of namespace Graphics +} // end of namespace graphics diff --git a/src/SceneViewer-corbaserver.cc b/src/corbaserver.cc similarity index 93% rename from src/SceneViewer-corbaserver.cc rename to src/corbaserver.cc index 8ecb0cdec7e55ade997b46c36675bab59c1a98fb..d0e33171c684d46e600db8cac7eb4a49ff21b2b5 100644 --- a/src/SceneViewer-corbaserver.cc +++ b/src/corbaserver.cc @@ -11,7 +11,7 @@ #include <iostream> #include "server.hh" -using Graphics::corbaServer::Server; +using graphics::corbaServer::Server; int main (int argc, const char* argv[]) diff --git a/src/fwd.hh b/src/fwd.hh index a04b44dd96ed45ca713979a9e3e0ee7f7d847b0f..f3686f207fbbf76ab180a7043ce80628026e666d 100644 --- a/src/fwd.hh +++ b/src/fwd.hh @@ -14,7 +14,7 @@ //FIXME: should be replaced by CORBA base types forward declarations. # include <omniORB4/CORBA.h> -namespace Graphics +namespace graphics { namespace corbaServer { diff --git a/src/Graphics/__init__.py b/src/gepetto/__init__.py similarity index 100% rename from src/Graphics/__init__.py rename to src/gepetto/__init__.py diff --git a/src/gepetto/corbaserver/__init__.py b/src/gepetto/corbaserver/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..7b40fdd1f95d57590b9279274f126ff31c900bfe --- /dev/null +++ b/src/gepetto/corbaserver/__init__.py @@ -0,0 +1,7 @@ +import omniORB +omniORB.updateModule("gepetto.corbaserver") + +import graphical_interface_idl + +from client import Client + diff --git a/src/Graphics/corbaserver/client.py b/src/gepetto/corbaserver/client.py similarity index 77% rename from src/Graphics/corbaserver/client.py rename to src/gepetto/corbaserver/client.py index 93e6e3826022b29f74d75170bd1e1a1d1afc0f0d..ed630b4de42537d1ca2e502896b0f978f6a8f779 100644 --- a/src/Graphics/corbaserver/client.py +++ b/src/gepetto/corbaserver/client.py @@ -5,7 +5,7 @@ create client to wanted HPP services. from omniORB import CORBA import CosNaming -import Graphics.corbaserver +import gepetto.corbaserver class CorbaError(Exception): """ @@ -21,33 +21,34 @@ class Client: Connect and create clients for all HPP services. """ - defaultClients = ["graphicalinterface"] + defaultClients = [('gui', 'GraphicalInterface')] def makeClient(self, serviceName): """ Create a client to a new CORBA service and add it to this class. """ - serviceName = serviceName.lower () - name = [CosNaming.NameComponent ("Graphics", "corbaserver"), - CosNaming.NameComponent ("basic", serviceName)] + name = [CosNaming.NameComponent ("gepetto", "viewer"), + CosNaming.NameComponent ("corbaserver", serviceName [0])] try: obj = self.rootContext.resolve (name) except CosNaming.NamingContext.NotFound, ex: raise CorbaError ( - 'failed to find the service ``{0}\'\''.format (serviceName)) + 'failed to find the service ``{0}\'\''.format (serviceName [0])) try: - client = obj._narrow (Graphics.corbaserver.__dict__[serviceName.capitalize ()]) + client = obj._narrow (gepetto.corbaserver.__dict__ + [serviceName [1]]) except KeyError: - raise CorbaError ('invalid service name ``{0}\'\''.format (serviceName)) + raise CorbaError ('invalid service name ``{0}\'\''.format \ + (serviceName [0])) if client is None: # This happens when stubs from client and server are not synchronized. raise CorbaError ( 'failed to narrow client for service named ``{0}\'\''.format - (serviceName)) - self.__dict__[serviceName] = client + (serviceName [0])) + self.__dict__[serviceName [0]] = client def __init__(self, clients = defaultClients): diff --git a/src/Graphics/quaternion.py b/src/gepetto/quaternion.py similarity index 100% rename from src/Graphics/quaternion.py rename to src/gepetto/quaternion.py diff --git a/src/GraphicalInterface.impl.cpp b/src/graphical-interface.impl.cpp similarity index 99% rename from src/GraphicalInterface.impl.cpp rename to src/graphical-interface.impl.cpp index 474b04979abe3f2daf645dd6a3fa2215dbda79aa..ae3b775a1e8a289c4fbe3fd212429facded45a26 100644 --- a/src/GraphicalInterface.impl.cpp +++ b/src/graphical-interface.impl.cpp @@ -6,9 +6,9 @@ // Copyright (c) 2014 LAAS-CNRS. All rights reserved. // -#include "GraphicalInterface.impl.hh" +#include "graphical-interface.impl.hh" -namespace Graphics { +namespace graphics { namespace corbaServer { namespace impl { @@ -502,7 +502,8 @@ bool GraphicalInterface::addURDF(const char* urdfNameCorba, const char* urdfPath return false; } else { - GroupNodePtr_t urdf = URDFparser::parse(urdfName, urdfPath, urdfPackagePath); + GroupNodePtr_t urdf = urdfParser::parse + (urdfName, urdfPath, urdfPackagePath); NodePtr_t link; for (int i=0 ; i< urdf->getNumOfChildren() ; i++) { link = urdf->getChild(i); @@ -614,4 +615,4 @@ bool GraphicalInterface::setLightingMode(const char* nodeNameCorba, const char* } } //end namespace impl } //end namespace corbaServer -} //end namespace Graphics +} //end namespace graphics diff --git a/src/GraphicalInterface.impl.hh b/src/graphical-interface.impl.hh similarity index 85% rename from src/GraphicalInterface.impl.hh rename to src/graphical-interface.impl.hh index 2d127b2bfc50ce5f2ee7afdd3a5d1d9012f002ba..8f2f7630201a9d03850542d2a5413e5c7fbc5f2a 100644 --- a/src/GraphicalInterface.impl.hh +++ b/src/graphical-interface.impl.hh @@ -13,26 +13,26 @@ #include <boost/thread.hpp> #include <boost/thread/mutex.hpp> -#include <Graphics/WindowManager.h> -#include <Graphics/Node.h> -#include <Graphics/GroupNode.h> -#include <Graphics/LeafNodeBox.h> -#include <Graphics/LeafNodeCapsule.h> -#include <Graphics/LeafNodeCone.h> -#include <Graphics/LeafNodeCylinder.h> -#include <Graphics/LeafNodeLine.h> -#include <Graphics/LeafNodeFace.h> -#include <Graphics/LeafNodeSphere.h> -#include <Graphics/macros.h> -#include <Graphics/config.h> -#include <Graphics/LeafNodeGround.h> -#include <Graphics/LeafNodeCollada.h> -#include <Graphics/URDFparser.h> +#include <gepetto/viewer/window-manager.h> +#include <gepetto/viewer/node.h> +#include <gepetto/viewer/group-node.h> +#include <gepetto/viewer/leaf-node-box.h> +#include <gepetto/viewer/leaf-node-capsule.h> +#include <gepetto/viewer/leaf-node-cone.h> +#include <gepetto/viewer/leaf-node-cylinder.h> +#include <gepetto/viewer/leaf-node-line.h> +#include <gepetto/viewer/leaf-node-face.h> +#include <gepetto/viewer/leaf-node-sphere.h> +#include <gepetto/viewer/macros.h> +#include <gepetto/viewer/config-osg.h> +#include <gepetto/viewer/leaf-node-ground.h> +#include <gepetto/viewer/leaf-node-collada.h> +#include <gepetto/viewer/urdf-parser.h> #include "server.hh" -#include "graphicalinterface.hh" +#include "graphical-interface.hh" -namespace Graphics { +namespace graphics { namespace corbaServer { namespace impl { @@ -42,7 +42,8 @@ struct NodeConfiguration { osgQuat quat; }; -class GraphicalInterface : public virtual POA_Graphics::corbaserver::Graphicalinterface +class GraphicalInterface : + public virtual POA_gepetto::corbaserver::GraphicalInterface { private: std::map<std::string, WindowManagerPtr_t> windowManagers_; @@ -128,6 +129,6 @@ public: } /* namespace impl */ } /* namespace corbaServer */ -} /* namespace Graphics */ +} /* namespace graphics */ #endif /* SCENEVIEWER_CORBASERVER_GRAPHICALINTERFACE_HH */ diff --git a/src/server-private.cc b/src/server-private.cc index 99f040ff77047d5ae04161096c755f47e3dde948..e70e97d301f049000d32ae66cfc1f6fb8218f438 100644 --- a/src/server-private.cc +++ b/src/server-private.cc @@ -11,11 +11,11 @@ #include <iostream> #include <stdexcept> -#include "GraphicalInterface.impl.hh" +#include "graphical-interface.impl.hh" #include "server-private.hh" #include "fwd.hh" -namespace Graphics +namespace graphics { namespace corbaServer { @@ -74,8 +74,8 @@ namespace Graphics } // Bind a context called "Graphics" to the root context: contextName.length(1); - contextName[0].id = (const char*) "Graphics"; // string copied - contextName[0].kind = (const char*) "corbaserver"; // string copied + contextName[0].id = (const char*) "gepetto"; // string copied + contextName[0].kind = (const char*) "viewer"; // string copied // Note on kind: The kind field is used to indicate the type // of the object. This is to avoid conventions such as that used // by files (name.type -- e.g. Graphics.ps = postscript etc.) @@ -115,4 +115,4 @@ namespace Graphics } } // end of namespace impl. } // end of namespace corbaServer. -} // end of namespace Graphics. +} // end of namespace graphics. diff --git a/src/server-private.hh b/src/server-private.hh index 480c280e64e26dffc5990bcfe59c95f44c57b91b..396ca6baffb1694260f611b15fb770dad1315570 100644 --- a/src/server-private.hh +++ b/src/server-private.hh @@ -11,10 +11,10 @@ #ifndef SCENEVIEWER_CORBASERVER_SERVER_PRIVATE_HH # define SCENVIEWER_CORBASERVER_SERVER_PRIVATE_HH -#include "GraphicalInterface.impl.hh" -#include "fwd.hh" +# include "graphical-interface.impl.hh" +# include "fwd.hh" -namespace Graphics +namespace graphics { namespace corbaServer { @@ -26,7 +26,7 @@ namespace Graphics ~Server (); /// \brief Create and activate the Corba servers. - void createAndActivateServers (Graphics::corbaServer::Server* server); + void createAndActivateServers (graphics::corbaServer::Server* server); private: CORBA::ORB_var orb_; @@ -58,6 +58,6 @@ namespace Graphics } // end of namespace impl. } // end of namespace corbaServer. -} // end of namespace Graphics. +} // end of namespace graphics. #endif // SCENEVIEWER_CORBASERVER_SERVER_PRIVATE_HH diff --git a/src/server.cc b/src/server.cc index 42b3cc58bd1f5b0ebc688717b9f3d43744c2b174..783a83afb4b16a56a5938ab050025fdfdd1aedaf 100644 --- a/src/server.cc +++ b/src/server.cc @@ -17,7 +17,7 @@ #include "server-private.hh" -namespace Graphics +namespace graphics { namespace corbaServer { @@ -113,8 +113,8 @@ namespace Graphics // Bind graphicalInterfaceObj with name graphicalinterface to the Context: CosNaming::Name objectName; objectName.length(1); - objectName[0].id = (const char*) "basic"; // string copied - objectName[0].kind = (const char*) "graphicalinterface"; // string copied + objectName[0].id = (const char*) "corbaserver"; // string copied + objectName[0].kind = (const char*) "gui"; // string copied private_->bindObjectToName(graphicalInterfaceObj, objectName); private_->graphicalInterfaceServant_->_remove_ref(); @@ -139,4 +139,4 @@ namespace Graphics } } // end of namespace corbaServer. -} // end of namespace Graphics. +} // end of namespace graphics. diff --git a/src/server.hh b/src/server.hh index 22cc8ee8bd801283fc106a8483e08a5e199c49d7..65d418b37e0033d9a74cb054679e89554b3eb42d 100644 --- a/src/server.hh +++ b/src/server.hh @@ -14,7 +14,7 @@ #include "fwd.hh" -namespace Graphics +namespace graphics { namespace corbaServer { diff --git a/test/test-client-cpp.cc b/src/test-client-cpp.cc similarity index 93% rename from test/test-client-cpp.cc rename to src/test-client-cpp.cc index e930f02984f66b3ac876b1079a3992a9525254a3..15f0fe65633c989bdf9d87b39ce81bfd6b9a599b 100644 --- a/test/test-client-cpp.cc +++ b/src/test-client-cpp.cc @@ -6,11 +6,11 @@ // Copyright (c) 2014 LAAS-CNRS. All rights reserved. // -#include "../src/client-cpp.hh" +#include <gepetto/viewer/corba/client.hh> -int main(int argc, const char * argv[]) +int main(int, const char **) { - using namespace Graphics; + using namespace graphics; using namespace corbaServer; using namespace std;