00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2010, ISR University of Coimbra. 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/or other materials provided 00017 * with the distribution. 00018 * * Neither the name of the ISR University of Coimbra 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 * Author: Gonçalo Cabrita on 28/11/2010 00036 *********************************************************************/ 00037 #include <ros/ros.h> 00038 #include <lse_sensor_msgs/Nostril.h> 00039 #include <pcl_ros/publisher.h> 00040 #include <tf/transform_listener.h> 00041 #include <tf/message_filter.h> 00042 #include <message_filters/subscriber.h> 00043 #include <nav_msgs/GridCells.h> 00044 #include <vector> 00045 00046 #include "Particle.h" 00047 00048 namespace particle_plume 00049 { 00058 class ParticlePlume 00059 { 00060 public: 00062 ParticlePlume(); 00064 ~ParticlePlume(); 00065 00067 00070 void publishPlume(); 00071 00072 private: 00073 00075 struct BubbleData 00076 { 00078 geometry_msgs::PointStamped bubble_center; 00080 int number_of_particles; 00081 }; 00082 00084 struct CellCandidate 00085 { 00086 geometry_msgs::Point point; 00087 bool push; 00088 }; 00089 00091 ros::NodeHandle n_; 00093 ros::NodeHandle pn_; 00094 00096 pcl_ros::Publisher<Particle> plume_pub_; 00098 ros::Publisher cells_pub_; 00099 00101 message_filters::Subscriber<lse_sensor_msgs::Nostril> nose_sub_; 00103 tf::TransformListener tf_; 00104 tf::MessageFilter<lse_sensor_msgs::Nostril> * tf_filter_; 00105 00107 pcl::PointCloud<Particle> plume_; 00108 00110 nav_msgs::GridCells cells_; 00111 00113 std::vector<ros::Time> cells_birth_; 00114 00116 bool cells_changed_; 00117 00119 std::vector<BubbleData> odor_readings_; 00120 00122 std::string global_frame_id_; 00123 00125 00128 double bubble_radius_; 00130 00133 int max_particles_per_bubble_; 00135 00138 int particle_life_time_; 00140 00143 double publish_frequency_; 00145 00148 double cell_size_; 00150 00153 std::string sensor_model_; 00154 00156 00161 void noseCallback(const boost::shared_ptr<const lse_sensor_msgs::Nostril>& msg); 00162 00164 00169 float drand(); 00171 00176 double randomNormal(); 00177 }; 00178 } 00179 00180 // EOF 00181