diff --git a/CMakeLists.txt b/CMakeLists.txt index 58b4c764a50d8f6262f54571c6edd95eb379d5e8..7bce72dafedb872729a74c272e5fb8f35c304c0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ dynamic_graph_bridge_msgs) add_required_dependency(roscpp) add_required_dependency(tf) add_required_dependency("realtime_tools >= 1.8") -add_required_dependency(bullet) +add_required_dependency(tf2_bullet) ADD_REQUIRED_DEPENDENCY("pinocchio") ADD_REQUIRED_DEPENDENCY("dynamic-graph >= 3.0.0") ADD_REQUIRED_DEPENDENCY("dynamic-graph-python >= 3.0.0") @@ -89,7 +89,7 @@ add_library(ros_bridge include/dynamic_graph_bridge/ros_init.hh src/ros_init.cpp src/sot_to_ros.hh src/sot_to_ros.cpp ) -pkg_config_use_dependency(ros_bridge bullet) +pkg_config_use_dependency(ros_bridge tf2_bullet) pkg_config_use_dependency(ros_bridge dynamic_graph_bridge_msgs) install(TARGETS ros_bridge DESTINATION lib) @@ -184,7 +184,7 @@ generate_messages( DEPENDENCIES std_msgs ) # This is necessary so that the pc file generated by catking is similar to the on # done directly by jrl-cmake-modules -catkin_package(CATKIN_DEPENDS message_runtime roscpp realtime_tools bullet ${SOT_PKGNAMES} tf +catkin_package(CATKIN_DEPENDS message_runtime roscpp realtime_tools tf2_bullet ${SOT_PKGNAMES} tf LIBRARIES ros_bridge ros_interpreter sot_loader ) diff --git a/include/dynamic_graph_bridge/sot_loader_basic.hh b/include/dynamic_graph_bridge/sot_loader_basic.hh index 6f7fbdfdc71521f2a1aad80f7c3e005927ffbb7c..b561d48a859513ab815807dbb8b07ce8e372e458 100644 --- a/include/dynamic_graph_bridge/sot_loader_basic.hh +++ b/include/dynamic_graph_bridge/sot_loader_basic.hh @@ -60,6 +60,8 @@ protected: po::variables_map vm_; std::string dynamicLibraryName_; + /// \brief Handle on the SoT library. + void * sotRobotControllerLibrary_; /// \brief Map between SoT state vector and some joint_state_links XmlRpc::XmlRpcValue stateVectorMap_; @@ -89,9 +91,12 @@ public: // \brief Read user input to extract the path of the SoT dynamic library. int parseOptions(int argc, char *argv[]); - // \brief Load the SoT + /// \brief Load the SoT device corresponding to the robot. void Initialization(); + /// \brief Unload the library which handles the robot device. + void CleanUp(); + // \brief Create a thread for ROS. virtual void initializeRosNode(int argc, char *argv[]); diff --git a/package.xml b/package.xml index c4370a761fefda7c1cf9e5121ae838ec6341074b..7bdb5a63bfaeacc351e0f76f2316aecf28d465ac 100644 --- a/package.xml +++ b/package.xml @@ -1,6 +1,6 @@ <package format="2"> <name>dynamic_graph_bridge</name> - <version>3.0.4</version> + <version>3.0.6</version> <description> ROS bindings for dynamic graph. @@ -27,7 +27,7 @@ <depend>realtime_tools</depend> <depend>message_generation</depend> <depend>message_runtime</depend> - <depend>bullet</depend> + <depend>tf2_bullet</depend> <depend>dynamic-graph</depend> <depend>dynamic-graph-python</depend> <depend>sot-core</depend> diff --git a/src/sot_loader_basic.cpp b/src/sot_loader_basic.cpp index e9c3f19346156dc20de34f63ad05bc829151df41..4193a9bd8781f0fd369b9bf6cd63b99a3c3ebabe 100644 --- a/src/sot_loader_basic.cpp +++ b/src/sot_loader_basic.cpp @@ -54,7 +54,8 @@ void createRosSpin(SotLoaderBasic *aSotLoaderBasic) SotLoaderBasic::SotLoaderBasic(): - dynamic_graph_stopped_(true) + dynamic_graph_stopped_(true), + sotRobotControllerLibrary_(0) { readSotVectorStateParam(); initPublication(); @@ -192,9 +193,9 @@ void SotLoaderBasic::Initialization() { // Load the SotRobotBipedController library. - void * SotRobotControllerLibrary = dlopen( dynamicLibraryName_.c_str(), + sotRobotControllerLibrary_ = dlopen( dynamicLibraryName_.c_str(), RTLD_LAZY | RTLD_GLOBAL ); - if (!SotRobotControllerLibrary) { + if (!sotRobotControllerLibrary_) { std::cerr << "Cannot load library: " << dlerror() << '\n'; return ; } @@ -206,7 +207,7 @@ void SotLoaderBasic::Initialization() createSotExternalInterface_t * createSot = reinterpret_cast<createSotExternalInterface_t *> (reinterpret_cast<long> - (dlsym(SotRobotControllerLibrary, + (dlsym(sotRobotControllerLibrary_, "createSotExternalInterface"))); const char* dlsym_error = dlerror(); if (dlsym_error) { @@ -219,6 +220,12 @@ void SotLoaderBasic::Initialization() cout <<"Went out from Initialization." << endl; } +void SotLoaderBasic::CleanUp() +{ + /// Uncount the number of access to this library. + dlclose(sotRobotControllerLibrary_); +} + bool SotLoaderBasic::start_dg(std_srvs::Empty::Request& ,