Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build a c++ native library "grap_pose_detection" #58

Closed
wants to merge 7 commits into from

Conversation

sharronliu
Copy link

@sharronliu sharronliu commented Nov 1, 2018

This PR intents to build a c++ native library "grasp_pose_detection" that is independent on ROS. This serves as a common library in either ROS or ROS2.

Fix issue #52

Key changes include:

  • Created CMakeLists.txt for subdir "gpd/src" to build GPD into a native library "libgrasp_pose_detection.so"
  • Added a new class "src/nodes/ros_params.cpp::ROSParameters" to take ROS parameters from NodeHandle
  • Removed ROS dependency from "src/gpd". All parameters passed from the constructors.

How to build the library:
An automatic way is to build the "gpd" package from catkin workspace:
$ catkin_make -DCMAKE_BUILD_TYPE=Release --pkg gpd
# or "catkin_make -DCMAKE_BUILD_TYPE=Release -DUSE_OPENVINO=ON --pkg gpd"
Alternatively, manually kick off the build is supported:
$ cd src/gpd
$ mkdir build && cd build
$ cmake -DUSE_CAFFE=ON ..
# or "cmake -DUSE_OPENVINO=ON .."
$ sudo make install
By default "libgrasp_pose_detection.so" shall be installed to "/usr/local/install".

There are NO changes on build options or launch options :)
This PR is tested working with "USE_CAFFE=ON (default)" or "USE_OPENVINO=ON".
This PR is also tested with "Ubuntu 16.04 + ROS Kinetic" or "Ubuntu 18.04 + ROS Melodic".

@sharronliu sharronliu changed the title Libgpd Build a c++ native library "grap_pose_detection (GPD_LIB)" Nov 1, 2018
@sharronliu sharronliu changed the title Build a c++ native library "grap_pose_detection (GPD_LIB)" Build a c++ native library "grap_pose_detection" Nov 1, 2018
In this patch, ROS nodes are updated to pass "Parameters" structuer to
the constructors of classes under "src/gpd".

The affected ROS nodes/codes are:
src/nodes/classify_candidates.cpp
src/nodes/create_training_data.cpp
src/nodes/grasp_detection_node.cpp::GraspDetectionNode

The ROS nodes now use "ROSParameters" as helping class to get parameters
from the NodeHandle, then pass the parameters to the constructors.

Signed-off-by: Sharron LIU <sharron.liu@intel.com>
Sharron LIU added 4 commits December 31, 2018 16:06
This patch removed the ROS dependency from the classes under "src/gpd"

It affects the constructors of the below classes:
src/gpd/grasp_detector.cpp::GraspDetector
src/gpd/sequential_importance_sampling.cpp::SequentialImportanceSampling
src/gpd/data_generator.cpp::DataGenerator

Now these classes no more take parameters from "ROS::NodeHandle".
Instead, they get the parameters passed from their constructors.

The ROS prints are replaced with std::cout also.

Signed-off-by: Sharron LIU <sharron.liu@intel.com>
In order to separate "src/gpd" from ROS, a new class ROSParameters is
created. This class help to get parameters passed from ROS NodeHandle.

Under "src/gpd", there were three classes taking parameters from ROS:
src/gpd/grasp_detector.cpp::GraspDetector
src/gpd/sequential_importance_sampling.cpp::SequentialImportanceSampling
src/gpd/data_generator.cpp::DataGenerator

ROS parameters passed to these classes were redefined and encapsulated
as a specific "Parameter" structure passed to the constructor of each
class.

Signed-off-by: Sharron LIU <sharron.liu@intel.com>
"CV_RGB2BGR" is replaced with a more generic interface used in OpenCV
version 3 and 4

Signed-off-by: Sharron LIU <sharron.liu@intel.com>
This patch added a new cmake file "src/gpd/CMakeLists.txt" to build
library "libgrasp_pose_detection (GPD_LIB)" independent on ROS.

The cmake file is designed for being invoked in two scenarios:
1. Invoked from parent cmake file via "add_subdirectory(src/gpd)".
   In this way, build options inherit from parent cmake file
2. Invoked from command line via "cmake <build options> path"
   $ cd src/gpd
   $ mkdir build && cd build
   $ cmake -DUSE_CAFFE=OFF -DUSE_OPENVINO=ON ..

The cmake file performs:
1. Set the shared library name "GPD_LIB", visible to parent cmake file
2. Find dependent packages required by "GPD_LIB"
3. Identify source files per build options like OPENVINO or CAFFE
4. Install the built library and headers

The top-level cmake file (CMakeLists.txt) is updated accordingly:
1. While build with ROS catkin, trigger "GPD_LIB" via add_subdirectory()
2. Not necessary to build library for each single souce under "src/gpd"
3. Add "GPD_LIB" as a dependency for the executable targets. This will
   garantee "GPD_LIB" built prior to the executable targets.

Signed-off-by: Sharron LIU <sharron.liu@intel.com>
Added launch option "plane_remove" (default 'false') to remove planes
(e.g. tabletop) from PCL inputs.

Signed-off-by: Sharron LIU <sharron.liu@intel.com>
@sharronliu sharronliu force-pushed the libgpd branch 2 times, most recently from eab315d to fdd6993 Compare March 18, 2019 06:29
PR atenpas#50 atenpas#50

Signed-off-by: Sharron LIU <sharron.liu@intel.com>
@atenpas
Copy link
Owner

atenpas commented Nov 2, 2019

GPD is now a C++14 library.

@atenpas atenpas closed this Nov 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants