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 00030 #ifndef MOTION_PLANNING_RVIZ_PLUGIN_PLANNING_DISPLAY_H 00031 #define MOTION_PLANNING_RVIZ_PLUGIN_PLANNING_DISPLAY_H 00032 00033 #include "rviz/display.h" 00034 #include "rviz/properties/forwards.h" 00035 00036 #include <motion_planning_msgs/DisplayTrajectory.h> 00037 #include <std_msgs/Bool.h> 00038 00039 #include <ros/ros.h> 00040 00041 #include <map> 00042 00043 namespace Ogre 00044 { 00045 class Entity; 00046 class SceneNode; 00047 } 00048 00049 namespace planning_models 00050 { 00051 class KinematicModel; 00052 } 00053 00054 namespace planning_environment 00055 { 00056 class RobotModels; 00057 } 00058 00059 namespace rviz 00060 { 00061 class Robot; 00062 } 00063 00064 namespace motion_planning_rviz_plugin 00065 { 00066 00071 class PlanningDisplay : public rviz::Display 00072 { 00073 public: 00074 PlanningDisplay( const std::string& name, rviz::VisualizationManager* manager ); 00075 virtual ~PlanningDisplay(); 00076 00082 void initialize( const std::string& description_param, const std::string& kinematic_path_topic ); 00083 00088 void setRobotDescription( const std::string& description_param ); 00089 00094 void setTopic( const std::string& topic ); 00095 00100 void setStateDisplayTime( float time ); 00101 00106 void setVisualVisible( bool visible ); 00107 00112 void setCollisionVisible( bool visible ); 00113 00114 const std::string& getRobotDescription() { return description_param_; } 00115 const std::string& getTopic() { return kinematic_path_topic_; } 00116 float getStateDisplayTime() { return state_display_time_; } 00117 00118 float getAlpha() { return alpha_; } 00119 void setAlpha( float alpha ); 00120 00121 bool getLoopDisplay() { return loop_display_; } 00122 void setLoopDisplay(bool loop_display); 00123 00124 bool isVisualVisible(); 00125 bool isCollisionVisible(); 00126 00127 virtual void update(float wall_dt, float ros_dt); 00128 00129 // Overrides from Display 00130 virtual void targetFrameChanged(); 00131 virtual void fixedFrameChanged() {} 00132 virtual void createProperties(); 00133 00134 00135 protected: 00139 void subscribe(); 00143 void unsubscribe(); 00144 00148 void advertise(); 00149 00153 void unadvertise(); 00154 00158 void load(); 00159 00163 void incomingJointPath(const motion_planning_msgs::DisplayTrajectory::ConstPtr& msg); 00164 00168 void calculateRobotPosition(); 00169 00170 // overrides from Display 00171 virtual void onEnable(); 00172 virtual void onDisable(); 00173 00174 std::string description_param_; 00175 00176 rviz::Robot* robot_; 00177 00178 ros::Subscriber sub_; 00179 std::string kinematic_path_topic_; 00180 planning_environment::RobotModels* env_models_; 00181 boost::shared_ptr<planning_models::KinematicModel> kinematic_model_; 00182 motion_planning_msgs::DisplayTrajectory::ConstPtr incoming_kinematic_path_message_; 00183 motion_planning_msgs::DisplayTrajectory::ConstPtr displaying_kinematic_path_message_; 00184 bool new_kinematic_path_; 00185 bool animating_path_; 00186 int current_state_; 00187 bool loop_display_; 00188 float state_display_time_; 00189 float current_state_time_; 00190 float alpha_; 00191 00192 rviz::BoolPropertyWPtr visual_enabled_property_; 00193 rviz::BoolPropertyWPtr collision_enabled_property_; 00194 rviz::FloatPropertyWPtr state_display_time_property_; 00195 rviz::StringPropertyWPtr robot_description_property_; 00196 rviz::ROSTopicStringPropertyWPtr topic_property_; 00197 rviz::FloatPropertyWPtr alpha_property_; 00198 rviz::BoolPropertyWPtr loop_display_property_; 00199 00200 ros::Publisher state_publisher_; 00201 00202 }; 00203 00204 } // namespace motion_planning_rviz_plugin 00205 00206 #endif 00207 00208