00001 // -*- mode: c++ -*- 00002 /********************************************************************* 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2014, JSK Lab 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/o2r other materials provided 00017 * with the distribution. 00018 * * Neither the name of the JSK Lab nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 *********************************************************************/ 00035 00036 00037 #ifndef JSK_PCL_ROS_ATTENTION_CLIPPER_H_ 00038 #define JSK_PCL_ROS_ATTENTION_CLIPPER_H_ 00039 00040 #include <jsk_topic_tools/diagnostic_nodelet.h> 00041 #include <sensor_msgs/CameraInfo.h> 00042 #include "jsk_recognition_utils/pcl_conversion_util.h" 00043 #include "jsk_recognition_utils/geo_util.h" 00044 #include "jsk_pcl_ros/tf_listener_singleton.h" 00045 #include <image_geometry/pinhole_camera_model.h> 00046 #include <jsk_recognition_msgs/ClusterPointIndices.h> 00047 #include <jsk_recognition_msgs/BoundingBoxArray.h> 00048 #include <geometry_msgs/PoseArray.h> 00049 #include <sensor_msgs/Image.h> 00050 00051 namespace jsk_pcl_ros 00052 { 00053 class AttentionClipper: public jsk_topic_tools::DiagnosticNodelet 00054 { 00055 public: 00056 AttentionClipper(): DiagnosticNodelet("AttentionClipper") { } 00057 00058 protected: 00060 // methods 00062 virtual void onInit(); 00063 virtual void clip(const sensor_msgs::CameraInfo::ConstPtr& msg); 00064 virtual void clipPointcloud(const sensor_msgs::PointCloud2::ConstPtr& msg); 00065 virtual void poseCallback(const geometry_msgs::PoseStamped::ConstPtr& pose); 00066 virtual void boxCallback(const jsk_recognition_msgs::BoundingBox::ConstPtr& box); 00067 virtual void poseArrayCallback(const geometry_msgs::PoseArray::ConstPtr& pose); 00068 virtual void boxArrayCallback(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr& box); 00069 virtual jsk_recognition_utils::Vertices cubeVertices(Eigen::Vector3f& dimension); 00070 virtual void subscribe(); 00071 virtual void unsubscribe(); 00072 virtual void updateDiagnostic( 00073 diagnostic_updater::DiagnosticStatusWrapper &stat); 00074 virtual void computeROI( 00075 const sensor_msgs::CameraInfo::ConstPtr& msg, 00076 std::vector<cv::Point2d>& points, 00077 cv::Mat& mask); 00078 virtual void publishBoundingBox(const std_msgs::Header& header); 00079 virtual void initializePoseList(size_t num); 00081 // ROS variables 00083 ros::Subscriber sub_; 00084 ros::Subscriber sub_pose_; 00085 ros::Subscriber sub_box_; 00086 ros::Subscriber sub_points_; 00087 ros::Publisher pub_camera_info_; 00088 ros::Publisher pub_bounding_box_array_; 00089 ros::Publisher pub_mask_; 00090 ros::Publisher pub_indices_; 00091 ros::Publisher pub_cluster_indices_; 00092 std::vector<ros::Publisher> multiple_pub_indices_; 00093 tf::TransformListener* tf_listener_; 00094 boost::mutex mutex_; 00095 00097 // parameters 00099 // only cube is supported 00100 jsk_recognition_utils::Vertices vertices_; 00101 // for multiple attention 00102 std::vector<Eigen::Affine3f> pose_list_; 00103 std::vector<Eigen::Affine3f> transformed_pose_list_; 00104 std::vector<std::string> frame_id_list_; 00105 jsk_recognition_utils::Vertices dimensions_; 00106 std::vector<std::string > prefixes_; 00107 00108 bool use_multiple_attention_; 00109 bool negative_; 00110 private: 00111 00112 }; 00113 } 00114 00115 #endif