00001 /* 00002 * Copyright (c) 2008, Willow Garage, Inc. 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 the Willow Garage, Inc. 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 * $Id$ 00030 * 00031 */ 00032 00033 #ifndef RVIZ_COLLISION_MAP_DISPLAY_H_ 00034 #define RVIZ_COLLISION_MAP_DISPLAY_H_ 00035 00036 #include "rviz/display.h" 00037 #include "rviz/helpers/color.h" 00038 00039 #include <boost/thread/mutex.hpp> 00040 00041 #include <boost/shared_ptr.hpp> 00042 00043 #include <arm_navigation_msgs/OrientedBoundingBox.h> 00044 #include <arm_navigation_msgs/CollisionMap.h> 00045 00046 #include <message_filters/subscriber.h> 00047 #include <tf/message_filter.h> 00048 00049 namespace rviz 00050 { 00051 class PointCloud; 00052 class ColorProperty; 00053 class RosTopicProperty; 00054 class BoolProperty; 00055 class EnumProperty; 00056 class FloatProperty; 00057 } 00058 00059 namespace Ogre 00060 { 00061 class SceneNode; 00062 class ManualObject; 00063 } 00064 00065 namespace mapping_rviz_plugin 00066 { 00067 00068 namespace collision_render_ops 00069 { 00070 enum CollisionRenderOp 00071 { 00072 CBoxes, CPoints, CCount, 00073 }; 00074 } 00075 typedef collision_render_ops::CollisionRenderOp CollisionRenderOp; 00076 00081 class CollisionMapDisplay : public rviz::Display 00082 { 00083 public: 00084 CollisionMapDisplay(); 00085 00086 virtual ~CollisionMapDisplay(); 00087 00088 virtual void onInitialize(); 00089 00090 void changedTopic(); 00091 00092 void changedColor(); 00093 void changedOverrideColor(); 00094 00095 void changedRenderOperation(); 00096 void changedPointSize(); 00097 void changedAlpha(); 00098 00099 00100 virtual void update(float wall_dt, float ros_dt); 00101 virtual void reset(); 00102 00103 protected: 00104 void subscribe(); 00105 void unsubscribe(); 00106 void clear(); 00107 void incomingMessage(const arm_navigation_msgs::CollisionMap::ConstPtr& message); 00108 void processMessage(const arm_navigation_msgs::CollisionMap::ConstPtr& message); 00109 00110 // overrides from Display 00111 virtual void onEnable(); 00112 virtual void onDisable(); 00113 virtual void fixedFrameChanged(); 00114 00115 std::string topic_; 00116 rviz::Color color_; 00117 int render_operation_; 00118 bool override_color_; 00119 float point_size_; 00120 float alpha_; 00121 00122 Ogre::SceneNode* scene_node_; 00123 rviz::PointCloud* cloud_; 00124 00125 arm_navigation_msgs::CollisionMap::ConstPtr current_message_; 00126 message_filters::Subscriber<arm_navigation_msgs::CollisionMap> sub_; 00127 tf::MessageFilter<arm_navigation_msgs::CollisionMap>* tf_filter_; 00128 00129 rviz::ColorProperty* color_property_; 00130 rviz::RosTopicProperty* topic_property_; 00131 rviz::BoolProperty* override_color_property_; 00132 rviz::EnumProperty* render_operation_property_; 00133 rviz::FloatProperty* point_size_property_; 00134 rviz::FloatProperty* alpha_property_; 00135 }; 00136 00137 } // namespace mapping_rviz_plugin 00138 00139 #endif /* RVIZ_COLLISION_MAP_DISPLAY_H_ */