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

ROS CppStyleGuide formatting and catkin_lint fixes #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 74 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
cmake_minimum_required(VERSION 2.8.3)
project(gpd_ros)

add_compile_options(-std=c++14)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS cmake_modules eigen_conversions message_generation roscpp rospy sensor_msgs std_msgs)
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
cmake_modules
eigen_conversions
geometry_msgs
message_generation
pcl_conversions
roscpp
sensor_msgs
std_msgs
visualization_msgs
)

# PCL
find_package(PCL REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

## System dependencies are found with CMake's conventions
find_library(GPD_LIB NAMES gpd PATHS /usr/local/lib PATH_SUFFIXES lib NO_DEFAULT_PATH)
Expand All @@ -22,11 +30,15 @@ endif()
include_directories(${GPD_LIB_INCLUDE_DIR})
message(STATUS "gpd_include_dir: ${GPD_LIB_INCLUDE_DIR}")

set(CMAKE_CXX_FLAGS "-O3 -fopenmp -fPIC -Wno-deprecated -Wenum-compare -Wno-ignored-attributes -std=c++14")

## Generate messages in the 'msg' folder
add_message_files(FILES CloudIndexed.msg CloudSamples.msg CloudSources.msg GraspConfig.msg GraspConfigList.msg
SamplesMsg.msg)
add_message_files(FILES
CloudIndexed.msg
CloudSamples.msg
CloudSources.msg
GraspConfig.msg
GraspConfigList.msg
SamplesMsg.msg
)

## Generate services in the 'srv' folder
add_service_files(FILES detect_grasps.srv)
Expand All @@ -44,11 +56,22 @@ generate_messages(DEPENDENCIES geometry_msgs sensor_msgs std_msgs)
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS cmake_modules eigen_conversions geometry_msgs message_runtime roscpp sensor_msgs std_msgs
DEPENDS PCL
# CATKIN_DEPENDS cmake_modules eigen_conversions geometry_msgs message_runtime roscpp sensor_msgs std_msgs
# DEPENDS Eigen OpenCV PCL
INCLUDE_DIRS include
LIBRARIES
${PROJECT_NAME}_grasp_messages
${PROJECT_NAME}_grasp_plotter
CATKIN_DEPENDS
cmake_modules
eigen_conversions
geometry_msgs
message_generation
message_runtime
pcl_conversions
roscpp
sensor_msgs
std_msgs
visualization_msgs
DEPENDS PCL
)

###########
Expand All @@ -61,9 +84,11 @@ include_directories(include ${catkin_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS})

## Declare a C++ library
add_library(${PROJECT_NAME}_grasp_messages src/${PROJECT_NAME}/grasp_messages.cpp)
add_dependencies(${PROJECT_NAME}_grasp_messages ${catkin_EXPORTED_TARGETS})
add_library(${PROJECT_NAME}_grasp_plotter src/${PROJECT_NAME}/grasp_plotter.cpp)

## Add cmake target dependencies of the library (message generation needs to be built before libraries)
add_dependencies(${PROJECT_NAME}_grasp_messages ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable
add_executable(${PROJECT_NAME}_detect_grasps src/gpd_ros/grasp_detection_node.cpp)
add_executable(${PROJECT_NAME}_detect_grasps_server src/gpd_ros/grasp_detection_server.cpp)
Expand Down Expand Up @@ -91,3 +116,36 @@ target_link_libraries(${PROJECT_NAME}_grasp_plotter
target_link_libraries(${PROJECT_NAME}_grasp_messages
${GPD_LIB}
${catkin_LIBRARIES})


#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executables and/or libraries for installation
install(TARGETS
${PROJECT_NAME}_detect_grasps
${PROJECT_NAME}_detect_grasps_server
${PROJECT_NAME}_grasp_messages
${PROJECT_NAME}_grasp_plotter

ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN "*.git" EXCLUDE
)

## Mark other files for installation (e.g. launch and bag files, etc.)
install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
PATTERN ".git" EXCLUDE
)
24 changes: 11 additions & 13 deletions include/gpd_ros/grasp_detection_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,20 @@ typedef pcl::PointCloud<pcl::PointNormal> PointCloudPointNormal;
* \brief A ROS node that can detect grasp poses in a point cloud.
*
* This class is a ROS node that handles all the ROS topics.
*
*/
*/
class GraspDetectionNode
{
public:

/**
* \brief Constructor.
* \param node the ROS node
*/
*/
GraspDetectionNode(ros::NodeHandle& node);

/**
* \brief Destructor.
*/
*/
~GraspDetectionNode()
{
delete cloud_camera_;
Expand All @@ -100,16 +99,15 @@ class GraspDetectionNode

/**
* \brief Run the ROS node. Loops while waiting for incoming ROS messages.
*/
*/
void run();

/**
* \brief Detect grasp poses in a point cloud received from a ROS topic.
* \return the list of grasp poses
*/
*/
std::vector<std::unique_ptr<gpd::candidate::Hand>> detectGraspPoses();


private:

/**
Expand All @@ -118,25 +116,25 @@ class GraspDetectionNode
* \param centroid the centroid of the ball
* \param radius the radius of the ball
* \return the indices of the points in the point cloud that lie within the ball
*/
*/
std::vector<int> getSamplesInBall(const PointCloudRGBA::Ptr& cloud, const pcl::PointXYZRGBA& centroid, float radius);

/**
* \brief Callback function for the ROS topic that contains the input point cloud.
* \param msg the incoming ROS message
*/
*/
void cloud_callback(const sensor_msgs::PointCloud2& msg);

/**
* \brief Callback function for the ROS topic that contains the input point cloud and a list of indices.
* \param msg the incoming ROS message
*/
*/
void cloud_indexed_callback(const gpd_ros::CloudIndexed& msg);

/**
* \brief Callback function for the ROS topic that contains the input point cloud and a list of (x,y,z) samples.
* \param msg the incoming ROS message
*/
*/
void cloud_samples_callback(const gpd_ros::CloudSamples& msg);

/**
Expand All @@ -148,7 +146,7 @@ class GraspDetectionNode
/**
* \brief Callback function for the ROS topic that contains the input samples.
* \param msg the incoming ROS message
*/
*/
void samples_callback(const gpd_ros::SamplesMsg& msg);

Eigen::Matrix3Xd fillMatrixFromFile(const std::string& filename, int num_normals);
Expand All @@ -171,7 +169,7 @@ class GraspDetectionNode
std::vector<double> workspace_; ///< workspace limits

gpd::GraspDetector* grasp_detector_; ///< used to run the GPD algorithm
//gpd::SequentialImportanceSampling* importance_sampling_; ///< sequential importance sampling variation of GPD algorithm
// gpd::SequentialImportanceSampling* importance_sampling_; ///< sequential importance sampling variation of GPD algorithm
GraspPlotter* rviz_plotter_; ///< used to plot detected grasps in rviz

/** constants for input point cloud types */
Expand Down
7 changes: 2 additions & 5 deletions include/gpd_ros/grasp_detection_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/


#ifndef GRASP_DETECTION_SERVER_H_
#define GRASP_DETECTION_SERVER_H_


// ROS
#include <eigen_conversions/eigen_msg.h>
#include <pcl_conversions/pcl_conversions.h>
Expand Down Expand Up @@ -66,12 +64,12 @@ class GraspDetectionServer
/**
* \brief Constructor.
* \param node the ROS node
*/
*/
GraspDetectionServer(ros::NodeHandle& node);

/**
* \brief Destructor.
*/
*/
~GraspDetectionServer()
{
delete cloud_camera_;
Expand All @@ -86,7 +84,6 @@ class GraspDetectionServer
*/
bool detectGrasps(gpd_ros::detect_grasps::Request& req, gpd_ros::detect_grasps::Response& res);


private:

ros::Publisher grasps_pub_; ///< ROS publisher for grasp list messages
Expand Down
7 changes: 4 additions & 3 deletions include/gpd_ros/grasp_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@

namespace GraspMessages
{
gpd_ros::GraspConfigList createGraspListMsg(const std::vector<std::unique_ptr<gpd::candidate::Hand>>& hands, const std_msgs::Header& header);
gpd_ros::GraspConfigList createGraspListMsg(const std::vector<std::unique_ptr<gpd::candidate::Hand>>& hands,
const std_msgs::Header& header);

gpd_ros::GraspConfig convertToGraspMsg(const gpd::candidate::Hand& hand);
};
gpd_ros::GraspConfig convertToGraspMsg(const gpd::candidate::Hand& hand);
}

#endif /* GRASP_MESSAGES_H_ */
15 changes: 6 additions & 9 deletions include/gpd_ros/grasp_plotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/


#ifndef GRASP_PLOTTER_H_
#define GRASP_PLOTTER_H_

Expand All @@ -43,13 +42,11 @@
#include <gpd/candidate/hand.h>
#include <gpd/candidate/hand_geometry.h>


/** GraspPlotter class
*
* \brief Draw grasps in rviz.
*
* This class provides functions to draw grasps in rviz.
*
*/
class GraspPlotter
{
Expand All @@ -58,7 +55,7 @@ class GraspPlotter
/**
* \brief Constructor.
* \param node the ROS node
*/
*/
GraspPlotter(ros::NodeHandle& node, const gpd::candidate::HandGeometry& params);

/**
Expand All @@ -73,8 +70,8 @@ class GraspPlotter
* \param hands list of grasps
* \param frame_id the name of the frame that the grasp is in
*/
visualization_msgs::MarkerArray convertToVisualGraspMsg(const std::vector<std::unique_ptr<gpd::candidate::Hand>>& hands,
const std::string& frame_id);
visualization_msgs::MarkerArray convertToVisualGraspMsg(
const std::vector<std::unique_ptr<gpd::candidate::Hand>>& hands, const std::string& frame_id);

/**
* \brief Convert a list of grasps to a ROS message that can be published to rviz.
Expand All @@ -87,7 +84,7 @@ class GraspPlotter
* \param frame_id the name of the frame that the grasp is in
*/
visualization_msgs::Marker createFingerMarker(const Eigen::Vector3d& center, const Eigen::Matrix3d& rot,
const Eigen::Vector3d& lwh, int id, const std::string& frame_id);
const Eigen::Vector3d& lwh, int id, const std::string& frame_id);

/**
* \brief Convert a list of grasps to a ROS message that can be published to rviz.
Expand All @@ -96,8 +93,8 @@ class GraspPlotter
* \param frame_id the name of the frame that the grasp is in
*/
visualization_msgs::Marker createHandBaseMarker(const Eigen::Vector3d& start, const Eigen::Vector3d& end,
const Eigen::Matrix3d& frame, double length, double height, int id, const std::string& frame_id);

const Eigen::Matrix3d& frame, double length, double height, int id,
const std::string& frame_id);

private:

Expand Down
6 changes: 1 addition & 5 deletions launch/ur5.launch
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<node name="detect_grasps" pkg="gpd_ros" type="detect_grasps" output="screen">

<!-- If sequential importance sampling is used (default: false) -->
<!--
<param name="use_importance_sampling" value="false" />
-->
<!-- <param name="use_importance_sampling" value="false" /> -->

<!-- What type of point cloud is used and what ROS topic it comes from -->
<param name="cloud_type" value="2" /> <!-- 0: PointCloud2, 1: CloudIndexed, 2: CloudSamples -->
Expand All @@ -18,7 +16,5 @@
<param name="config_file" value="/home/ur5/projects/gpd/cfg/ros_vino_params.cfg" />

<param name="rviz_topic" value="plot_grasps" />

</node>

</launch>
Loading