00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef OMPL_VISUAL_TOOLS__OMPL_VISUAL_TOOLS_
00040 #define OMPL_VISUAL_TOOLS__OMPL_VISUAL_TOOLS_
00041
00042
00043 #include <ros/ros.h>
00044 #include <visualization_msgs/Marker.h>
00045 #include <geometry_msgs/Point.h>
00046
00047
00048 #include <ompl/base/SpaceInformation.h>
00049 #include <ompl/base/Planner.h>
00050 #include <ompl/geometric/PathGeometric.h>
00051 #include <ompl/base/ScopedState.h>
00052
00053
00054 #include <ompl_visual_tools/costs/cost_map_2d_optimization_objective.h>
00055
00056
00057 #include <moveit/robot_model/link_model.h>
00058
00059
00060 #include <moveit_visual_tools/moveit_visual_tools.h>
00061
00062 namespace ob = ompl::base;
00063 namespace og = ompl::geometric;
00064 namespace bnu = boost::numeric::ublas;
00065
00066
00067 namespace ompl
00068 {
00069 namespace base
00070 {
00071 class PlannerData;
00072 typedef boost::shared_ptr<PlannerData> PlannerDataPtr;
00073 }}
00074
00075 namespace ompl_interface
00076 {
00077 class ModelBasedPlanningContext;
00078 typedef boost::shared_ptr<ModelBasedPlanningContext> ModelBasedPlanningContextPtr;
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 namespace ompl_visual_tools
00090 {
00091
00092
00093 static const std::string RVIZ_MARKER_TOPIC = "/ompl_rviz_markers";
00094 static const double COST_HEIGHT_OFFSET = 0.5;
00095
00096 typedef std::map< std::string, std::list<std::size_t> > MarkerList;
00097
00098 class OmplVisualTools : public moveit_visual_tools::MoveItVisualTools
00099 {
00100 private:
00101
00102
00103 intMatrixPtr cost_;
00104
00105
00106 ompl::base::SpaceInformationPtr si_;
00107
00108
00109 geometry_msgs::Point temp_point_;
00110
00111
00112 bool disable_3d_;
00113
00114 public:
00115
00119 OmplVisualTools(const std::string& base_link,
00120 const std::string& marker_topic = ompl_visual_tools::RVIZ_MARKER_TOPIC,
00121 robot_model::RobotModelConstPtr robot_model = robot_model::RobotModelConstPtr());
00122
00126 void setStateSpace(ompl::base::StateSpacePtr space);
00127 void setSpaceInformation(ompl::base::SpaceInformationPtr si);
00128
00132 void setCostMap(intMatrixPtr cost);
00133
00137 bool getDisable3D();
00138
00142 void setDisable3D(bool disable_3d);
00143
00147 double getCost(const geometry_msgs::Point &point);
00148
00153 double getCostHeight(const geometry_msgs::Point &point);
00154
00158 bool publishCostMap(PPMImage *image, bool static_id = true);
00159
00163 bool publishTriangle( int x, int y, visualization_msgs::Marker* marker, PPMImage *image );
00164
00168 bool interpolateLine( const geometry_msgs::Point &p1, const geometry_msgs::Point &p2, visualization_msgs::Marker* marker,
00169 const std_msgs::ColorRGBA color );
00170
00174 bool publishStartGoalSpheres(ob::PlannerDataPtr planner_data, const std::string& ns);
00175
00179 bool publishGraph(ob::PlannerDataPtr planner_data, const rviz_visual_tools::colors& color = rviz_visual_tools::BLUE, const double thickness = 0.2,
00180 const std::string& ns = "space_exploration");
00181
00185 MOVEIT_DEPRECATED bool publishSamples( const ob::PlannerDataPtr& planner_data, const rviz_visual_tools::colors color = rviz_visual_tools::RED,
00186 const rviz_visual_tools::scales scale = rviz_visual_tools::SMALL, const std::string& ns = "sample_locations" );
00187
00188
00189 MOVEIT_DEPRECATED bool publishSamples( const og::PathGeometric& path, const rviz_visual_tools::colors color = rviz_visual_tools::RED,
00190 const rviz_visual_tools::scales scale = rviz_visual_tools::SMALL, const std::string& ns = "sample_locations" );
00191
00200 bool publishSpheres( const ob::PlannerDataPtr& planner_data, const rviz_visual_tools::colors color = rviz_visual_tools::RED,
00201 const rviz_visual_tools::scales scale = rviz_visual_tools::SMALL, const std::string& ns = "planner_data_spheres" );
00202 bool publishSpheres( const og::PathGeometric& path, const rviz_visual_tools::colors color = rviz_visual_tools::RED,
00203 double scale = 0.1, const std::string& ns = "path_spheres" );
00204 bool publishSpheres( const og::PathGeometric& path, const rviz_visual_tools::colors color = rviz_visual_tools::RED,
00205 const rviz_visual_tools::scales scale = rviz_visual_tools::SMALL, const std::string& ns = "path_spheres" );
00206 bool publishSpheres( const og::PathGeometric& path, const rviz_visual_tools::colors color,
00207 const geometry_msgs::Vector3 &scale, const std::string& ns = "path_spheres");
00208
00215 bool publishEdge(const ob::State* stateA, const ob::State* stateB, const rviz_visual_tools::colors color = rviz_visual_tools::BLUE,
00216 const rviz_visual_tools::scales scale = rviz_visual_tools::REGULAR);
00217
00221 bool publishSampleIDs( const og::PathGeometric& path, const rviz_visual_tools::colors color = rviz_visual_tools::RED,
00222 const rviz_visual_tools::scales scale = rviz_visual_tools::SMALL, const std::string& ns = "sample_labels" );
00223
00229 void convertPlannerData(const ob::PlannerDataPtr planner_data, og::PathGeometric &path);
00230
00235 bool publishStates(std::vector<const ompl::base::State*> states);
00236
00242 bool publishRobotState( const ompl::base::State *state );
00243
00249 bool publishRobotPath( const ompl::base::PlannerDataPtr &path, robot_model::JointModelGroup* joint_model_group,
00250 const std::vector<const robot_model::LinkModel*> &tips, bool show_trajectory_animated);
00251
00257 bool publishRobotGraph( const ompl::base::PlannerDataPtr &graph,
00258 const std::vector<const robot_model::LinkModel*> &tips);
00264 bool publishPath( const ob::PlannerDataPtr& planner_data, const rviz_visual_tools::colors color,
00265 const double thickness = 0.4, const std::string& ns = "result_path" );
00266
00271 bool publishPath( const og::PathGeometric& path, const rviz_visual_tools::colors color, const double thickness = 0.4, const std::string& ns = "result_path" );
00272
00279 geometry_msgs::Point stateToPointMsg( int vertex_id, ob::PlannerDataPtr planner_data );
00280
00281 geometry_msgs::Point stateToPointMsg( const ob::State *state );
00282
00283 geometry_msgs::Point stateToPointMsg( const ob::ScopedState<> state );
00284
00290 static int natRound(double x);
00291
00297 bool publishState(const ob::ScopedState<> state, const rviz_visual_tools::colors &color,
00298 const rviz_visual_tools::scales scale = rviz_visual_tools::REGULAR,
00299 const std::string& ns = "state_sphere");
00300 bool publishState(const ob::ScopedState<> state, const rviz_visual_tools::colors &color,
00301 double scale = 0.1, const std::string& ns = "state_sphere");
00302 bool publishState(const ob::ScopedState<> state, const rviz_visual_tools::colors &color,
00303 const geometry_msgs::Vector3 &scale, const std::string& ns = "state_sphere");
00304
00310 bool publishSampleRegion(const ob::ScopedState<>& state_area, const double& distance);
00311
00315 bool publishText(const geometry_msgs::Point &point, const std::string &text,
00316 const rviz_visual_tools::colors &color = rviz_visual_tools::BLACK,
00317 bool static_id = true);
00318
00319 bool publishText(const geometry_msgs::Pose &pose, const std::string &text,
00320 const rviz_visual_tools::colors &color = rviz_visual_tools::BLACK,
00321 bool static_id = true);
00322
00329 bool convertRobotStatesToTipPoints(const ompl::base::PlannerDataPtr &graph,
00330 const std::vector<const robot_model::LinkModel*> &tips,
00331 std::vector< std::vector<geometry_msgs::Point> > & vertex_tip_points);
00332
00350 };
00351
00352 typedef boost::shared_ptr<OmplVisualTools> OmplVisualToolsPtr;
00353 typedef boost::shared_ptr<const OmplVisualTools> OmplVisualToolsConstPtr;
00354
00355 }
00356
00357 #endif