2 #include "handle_detector/CylinderArrayMsg.h" 3 #include "handle_detector/CylinderMsg.h" 4 #include "handle_detector/HandleListMsg.h" 12 #include <pcl/point_cloud.h> 13 #include <pcl/point_types.h> 14 #include <pcl/io/pcd_io.h> 15 #include <pcl/visualization/cloud_viewer.h> 17 #include <sensor_msgs/PointCloud2.h> 26 #define EIGEN_DONT_PARALLELIZE 37 std::vector<std::vector<CylindricalShell> >
g_handles;
57 double start_time = omp_get_wtime();
61 printf(
"No handles found!\n");
70 printf(
"Affordance and handle search done in %.3f sec.\n", omp_get_wtime() - start_time);
77 int main(
int argc,
char** argv)
80 const int PCD_FILE = 0;
91 std::string cloud_topic;
104 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_vis(
new pcl::PointCloud<pcl::PointXYZRGB>);
110 std::string file = g_affordances.
getPCDFile();
113 if (pcl::io::loadPCDFile<pcl::PointXYZRGBA>(file, *
g_cloud) == -1)
115 std::cerr <<
"Couldn't read pcd file" << std::endl;
118 printf(
"Loaded *.pcd-file: %s\n", file.c_str());
120 pcl::copyPointCloud(*
g_cloud, *cloud_vis);
126 double start_time = omp_get_wtime();
137 printf(
"Affordance and handle search done in %.3f sec.\n", omp_get_wtime() - start_time);
140 else if (!cloud_topic.empty())
143 printf(
"Reading point cloud data from sensor topic: %s\n", cloud_topic.c_str());
149 sensor_msgs::PointCloud2 pc2msg;
155 "visualization_handle_numbers", 1);
156 std::vector<visualization_msgs::MarkerArray> marker_arrays;
166 std::vector<ros::Publisher> handle_pubs;
167 handle_detector::CylinderArrayMsg cylinder_list_msg;
168 handle_detector::HandleListMsg handle_list_msg;
173 double prev_time = omp_get_wtime();
192 for (std::size_t i = 0; i < handle_pubs.size(); i++)
194 "visualization_handle_" + boost::lexical_cast < std::string > (i), 10);
207 pcl_pub.publish(pc2msg);
210 marker_array_pub.
publish(marker_array_msg);
213 for (std::size_t i = 0; i < handle_pubs.size(); i++)
214 handle_pubs[i].publish(marker_arrays[i]);
217 marker_array_pub_handles.publish(marker_array_msg_handles);
220 marker_array_pub_handle_numbers.publish(marker_array_msg_handle_numbers);
223 cylinder_pub.
publish(cylinder_list_msg);
226 handles_pub.publish(handle_list_msg);
std::vector< std::vector< CylindricalShell > > g_handles
int getNumSamples()
Return the number of samples, i.e., the number of neighborhoods to be searched for.
tf::StampedTransform g_transform
std::vector< CylindricalShell > g_cylindrical_shells
void initParams(ros::NodeHandle node)
Read the parameters from a ROS launch file.
void publish(const boost::shared_ptr< M > &message) const
int main(int argc, char **argv)
std::string g_sensor_frame
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void chatterCallback(const sensor_msgs::PointCloud2ConstPtr &input)
MarkerArray createCylinders(const std::vector< CylindricalShell > &list, const std::string &frame)
Create a MarkerArray message from a list of cylindrical shells.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
Affordances g_affordances
void fromROSMsg(const sensor_msgs::PointCloud2 &cloud, pcl::PointCloud< T > &pcl_cloud)
handle_detector::CylinderArrayMsg createCylinderArray(const std::vector< CylindricalShell > &list, std::string frame)
Create a CylinderArray message from a list of cylindrical shells.
visualization_msgs::MarkerArray MarkerArray
std::vector< CylindricalShell > searchAffordances(const PointCloud::Ptr &cloud, tf::StampedTransform *transform=NULL)
Search grasp affordances (cylindrical shells) in a given point cloud.
const std::string RANGE_SENSOR_TOPIC
MarkerArray createHandleNumbers(const std::vector< std::vector< CylindricalShell > > &handles, const std::string &frame)
Create a MarkerArray message from a list of cylindrical shells.
std::vector< int > createRandomIndices(const PointCloud::Ptr &cloud, int size)
handle_detector::HandleListMsg createHandleList(const std::vector< std::vector< CylindricalShell > > &handles, std::string frame)
Create a HandleList message from a list of cylindrical shells.
std::string getPCDFile()
Return the *.pcd file given by the corresponding parameter in the ROS launch file.
pcl::PointCloud< pcl::PointXYZRGBA > PointCloud
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::vector< std::vector< CylindricalShell > > searchHandles(const PointCloud::Ptr &cloud, std::vector< CylindricalShell > shells)
Search handles in a set of cylindrical shells. If occlusion filtering is turned on (using the corresp...
Affordances localizes grasp affordances and handles in a point cloud. It also provides helper methods...
void createHandles(const std::vector< std::vector< CylindricalShell > > &handles, const std::string &frame, std::vector< MarkerArray > &marker_arrays, MarkerArray &all_handle_markers)
Create a list of MarkerArray messages and a MarkerArray from a list of handles. The former represents...
PointCloud::Ptr g_cloud(new PointCloud)
Messages creates custom ROS messages to publish the results of the localization. The messages that ca...
void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
pcl::PointCloud< pcl::PointXYZRGBA > PointCloud
ROSCPP_DECL void spinOnce()
Visualizer creates ROS messages to visualize the results of the localization in RViz. The possible objects that can be visualized are: neighborhoods, cylindrical shells, and handles.