Go to the documentation of this file.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
00040
00041 #include <ros/ros.h>
00042
00043
00044 #include <moveit_visual_tools/moveit_visual_tools.h>
00045
00046
00047 #include <moveit/planning_scene_monitor/planning_scene_monitor.h>
00048
00049 namespace moveit_visual_tools
00050 {
00051
00052
00053 static const std::string EE_PARENT_LINK = "right_wrist";
00054 static const std::string PLANNING_GROUP_NAME = "right_arm_torso_grasping";
00055 static const std::string EE_GROUP = "right_hand";
00056
00057 class VisualToolsDemo
00058 {
00059 private:
00060
00061
00062 ros::NodeHandle nh_;
00063
00064
00065 moveit_visual_tools::MoveItVisualToolsPtr visual_tools_;
00066
00067
00068 planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_;
00069
00070 public:
00071
00075 VisualToolsDemo()
00076 {
00077 visual_tools_.reset(new moveit_visual_tools::MoveItVisualTools("base","/moveit_visual_tools"));
00078 visual_tools_->loadPlanningSceneMonitor();
00079
00080
00081 ros::spinOnce();
00082 ros::Duration(5.0).sleep();
00083
00084
00085 geometry_msgs::Pose pose1;
00086 geometry_msgs::Pose pose2;
00087
00088
00089 for (std::size_t i = 0; i < 10; ++i)
00090 {
00091 if (!ros::ok())
00092 break;
00093
00094 ROS_INFO_STREAM_NAMED("visual_tools","Publishing Collision Mesh");
00095 visual_tools_->generateRandomPose(pose1);
00096 static const std::string package = "moveit_visual_tools";
00097 std::string path = "file://" + ros::package::getPath(package);
00098 if( path == "file://" )
00099 ROS_FATAL_STREAM_NAMED("visual_tools", "Unable to get " << package << " package path " );
00100 path.append("/resources/demo_mesh.stl");
00101 visual_tools_->publishCollisionMesh(pose1, "Mesh", path, rviz_visual_tools::RAND);
00102 ros::Duration(1.0).sleep();
00103
00104 ROS_INFO_STREAM_NAMED("visual_tools","Publishing Collision Block");
00105 visual_tools_->generateRandomPose(pose1);
00106 visual_tools_->publishCollisionBlock(pose1, "Block", 0.1, rviz_visual_tools::RAND);
00107 ros::Duration(1.0).sleep();
00108
00109 ROS_INFO_STREAM_NAMED("visual_tools","Publishing Collision Rectanglular Cuboid");
00110 visual_tools_->generateRandomPose(pose1);
00111 visual_tools_->generateRandomPose(pose2);
00112 visual_tools_->publishCollisionCuboid(pose1.position, pose2.position, "Rectangle", rviz_visual_tools::RAND);
00113 ros::Duration(1.0).sleep();
00114
00115 ROS_INFO_STREAM_NAMED("visual_tools","Publishing Collision Floor");
00116 visual_tools_->publishCollisionFloor(0, "Floor", rviz_visual_tools::RAND);
00117 ros::Duration(1.0).sleep();
00118
00119 ROS_INFO_STREAM_NAMED("visual_tools","Publishing Collision Cylinder");
00120 visual_tools_->generateRandomPose(pose1);
00121 visual_tools_->generateRandomPose(pose2);
00122 visual_tools_->publishCollisionCylinder(pose1.position, pose2.position, "Cylinder", 0.1, rviz_visual_tools::RAND);
00123 ros::Duration(1.0).sleep();
00124
00125
00126
00127 ROS_INFO_STREAM_NAMED("visual_tools","Publishing Collision Wall");
00128 visual_tools_->generateRandomPose(pose1);
00129 visual_tools_->publishCollisionWall(pose1.position.x, pose1.position.y, 0, 1, "Wall", rviz_visual_tools::RAND);
00130 ros::Duration(1.0).sleep();
00131
00132 ROS_INFO_STREAM_NAMED("visual_tools","Publishing Collision Table");
00133 visual_tools_->generateRandomPose(pose1);
00134 visual_tools_->publishCollisionTable(pose1.position.x, pose1.position.y, 0, 0.5, 0.5, 0.5, "Table", rviz_visual_tools::RAND);
00135 ros::Duration(1.0).sleep();
00136 }
00137 }
00138
00142 ~VisualToolsDemo()
00143 {
00144 }
00145
00146 };
00147
00148 }
00149
00150 int main(int argc, char** argv)
00151 {
00152 ros::init(argc, argv, "visual_tools_demo");
00153 ROS_INFO_STREAM("Visual Tools Demo");
00154
00155
00156 ros::AsyncSpinner spinner(1);
00157 spinner.start();
00158
00159 moveit_visual_tools::VisualToolsDemo demoer;
00160
00161 ROS_INFO_STREAM("Shutting down.");
00162
00163 return 0;
00164 }