00001 /* 00002 * Copyright (c) 2013, Yujin Robot. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of Yujin Robot nor the names of its 00014 * contributors may be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00044 #ifndef _ROCH_SENSORPC_HPP_ 00045 #define _ROCH_SENSORPC_HPP_ 00046 00047 /***************************************************************************** 00048 ** Includes 00049 *****************************************************************************/ 00050 00051 #include <ros/ros.h> 00052 00053 #include <sensor_msgs/PointCloud2.h> 00054 00055 #include <roch_msgs/SensorState.h> 00056 00057 /***************************************************************************** 00058 ** Namespace 00059 *****************************************************************************/ 00060 00061 namespace roch_sensorpc 00062 { 00063 00067 class SensorPcNodelet 00068 { 00069 public: 00070 SensorPcNodelet(ros::NodeHandle nh_, ros::NodeHandle private_nh) 00071 : P_INF_X(+100*sin(0.34906585)), 00072 P_INF_Y(+100*cos(0.34906585)), 00073 N_INF_Y(-100*cos(0.34906585)), 00074 ZERO(0), prev_leftcliff(0), prev_rightcliff(0), prev_leftult(0), prev_centerult(0), prev_rightult(0), prev_leftpsd(0), prev_centerpsd(0), prev_rightpsd(0), 00075 ult_enable_(true),psd_enable_(true),cliff_enable_(true), 00076 nh(nh_),private_nh_(private_nh){ onInit(); } 00077 ~SensorPcNodelet() { } 00078 00079 void onInit(); 00080 00081 private: 00082 const float P_INF_X; // somewhere out of reach from the robot (positive x) 00083 const float P_INF_Y; // somewhere out of reach from the robot (positive y) 00084 const float N_INF_Y; // somewhere out of reach from the robot (negative y) 00085 const float ZERO; 00086 00087 uint8_t prev_leftcliff; 00088 uint8_t prev_rightcliff; 00089 uint8_t prev_leftult; 00090 uint8_t prev_centerult; 00091 uint8_t prev_rightult; 00092 uint8_t prev_leftpsd; 00093 uint8_t prev_centerpsd; 00094 uint8_t prev_rightpsd; 00095 00096 float pc_radius_; 00097 float pc_height_; 00098 float p_side_x_; 00099 float p_side_y_; 00100 float n_side_y_; 00101 00102 bool ult_enable_; 00103 bool psd_enable_; 00104 bool cliff_enable_; 00105 00106 ros::Publisher pointcloud_pub_; 00107 ros::Subscriber core_sensor_sub_; 00108 00109 ros::NodeHandle nh ; 00110 ros::NodeHandle private_nh_ ; 00111 sensor_msgs::PointCloud2 pointcloud_; 00112 00117 void coreSensorCB(const roch_msgs::SensorState::ConstPtr& msg); 00118 }; 00119 00120 } // namespace roch_bumper2pc 00121 00122 #endif // _ROCH_SENSORPC_HPP_