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 #ifndef MOVEIT_VISUAL_TOOLS_MOVEIT_VISUAL_TOOLS_H
00041 #define MOVEIT_VISUAL_TOOLS_MOVEIT_VISUAL_TOOLS_H
00042
00043
00044 #include <rviz_visual_tools/rviz_visual_tools.h>
00045
00046
00047 #include <moveit/planning_scene_monitor/planning_scene_monitor.h>
00048
00049 #include <rviz_visual_tools/deprecation.h>
00050
00051
00052 #include <moveit_msgs/Grasp.h>
00053 #include <moveit_msgs/DisplayRobotState.h>
00054 #include <moveit_msgs/WorkspaceParameters.h>
00055
00056
00057 #include <trajectory_msgs/JointTrajectory.h>
00058
00059
00060 #include <map>
00061 #include <string>
00062 #include <vector>
00063
00064 namespace moveit_visual_tools
00065 {
00066
00067 static const std::string ROBOT_DESCRIPTION = "robot_description";
00068 static const std::string DISPLAY_PLANNED_PATH_TOPIC =
00069 "/move_group/display_planned_path";
00070 static const std::string DISPLAY_ROBOT_STATE_TOPIC =
00071 "display_robot_state";
00072 static const std::string PLANNING_SCENE_TOPIC = "planning_scene";
00073
00074 class MoveItVisualTools : public rviz_visual_tools::RvizVisualTools
00075 {
00076 public:
00084 MoveItVisualTools(const std::string &base_frame, const std::string &marker_topic,
00085 planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor);
00086
00093 MoveItVisualTools(const std::string &base_frame,
00094 const std::string &marker_topic = rviz_visual_tools::RVIZ_MARKER_TOPIC,
00095 robot_model::RobotModelConstPtr robot_model = robot_model::RobotModelConstPtr());
00096
00101 void setRobotStateTopic(const std::string &robot_state_topic)
00102 {
00103 robot_state_topic_ = robot_state_topic;
00104 }
00105
00110 void setPlanningSceneTopic(const std::string &planning_scene_topic)
00111 {
00112 planning_scene_topic_ = planning_scene_topic;
00113 }
00114
00119 bool loadPlanningSceneMonitor();
00120
00127 bool processCollisionObjectMsg(const moveit_msgs::CollisionObject &msg,
00128 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00129
00135 bool processAttachedCollisionObjectMsg(const moveit_msgs::AttachedCollisionObject &msg);
00136
00141 bool triggerPlanningSceneUpdate();
00142
00147 bool loadSharedRobotState();
00148
00153 moveit::core::RobotStatePtr &getSharedRobotState();
00154
00159 moveit::core::RobotStatePtr &getRootRobotState()
00160 {
00161 return root_robot_state_;
00162 }
00163
00168 moveit::core::RobotModelConstPtr getRobotModel();
00169
00175 RVIZ_VISUAL_TOOLS_DEPRECATED
00176 bool loadEEMarker(const std::string &ee_group_name)
00177 {
00178 return loadEEMarker(robot_model_->getJointModelGroup(ee_group_name));
00179 }
00185 bool loadEEMarker(const robot_model::JointModelGroup *ee_jmg);
00186
00190 void loadTrajectoryPub(const std::string &display_planned_path_topic = DISPLAY_PLANNED_PATH_TOPIC, bool blocking = true);
00191 void loadRobotStatePub(const std::string &robot_state_topic = "", bool blocking = true);
00192
00197 void setPlanningSceneMonitor(planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor)
00198 {
00199 planning_scene_monitor_ = planning_scene_monitor;
00200 }
00201
00206 void setManualSceneUpdating(bool enable_manual = true)
00207 {
00208 mannual_trigger_update_ = enable_manual;
00209 }
00210
00218 bool publishEEMarkers(const Eigen::Affine3d &pose, const robot_model::JointModelGroup *ee_jmg,
00219 const rviz_visual_tools::colors &color = rviz_visual_tools::CLEAR,
00220 const std::string &ns = "end_effector")
00221 {
00222 return publishEEMarkers(convertPose(pose), ee_jmg, color, ns);
00223 }
00224 bool publishEEMarkers(const geometry_msgs::Pose &pose, const robot_model::JointModelGroup *ee_jmg,
00225 const rviz_visual_tools::colors &color = rviz_visual_tools::CLEAR,
00226 const std::string &ns = "end_effector");
00227
00234 bool publishGrasps(const std::vector<moveit_msgs::Grasp> &possible_grasps, const robot_model::JointModelGroup *ee_jmg,
00235 double animate_speed = 0.1);
00236
00243 bool publishAnimatedGrasps(const std::vector<moveit_msgs::Grasp> &possible_grasps,
00244 const robot_model::JointModelGroup *ee_jmg, double animate_speed = 0.01);
00245
00253 bool publishAnimatedGrasp(const moveit_msgs::Grasp &grasp, const robot_model::JointModelGroup *ee_jmg,
00254 double animate_speed);
00255
00263 bool publishIKSolutions(const std::vector<trajectory_msgs::JointTrajectoryPoint> &ik_solutions,
00264 const robot_model::JointModelGroup *arm_jmg, double display_time = 0.4);
00265
00272 bool removeAllCollisionObjects();
00273
00279 bool cleanupCO(const std::string &name);
00280
00286 bool cleanupACO(const std::string &name);
00287
00294 bool attachCO(const std::string &name, const std::string &ee_parent_link);
00295
00303 bool publishCollisionFloor(double z = 0.0, const std::string &plane_name = "Floor",
00304 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00305
00314 bool publishCollisionBlock(const geometry_msgs::Pose &block_pose, const std::string &block_name, double block_size,
00315 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00316
00325 RVIZ_VISUAL_TOOLS_DEPRECATED
00326 bool publishCollisionRectangle(const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const std::string &name,
00327 const rviz_visual_tools::colors &color)
00328 {
00329 return publishCollisionCuboid(convertPoint(point1), convertPoint(point2), name, color);
00330 }
00331 RVIZ_VISUAL_TOOLS_DEPRECATED
00332 bool publishCollisionRectangle(const geometry_msgs::Point &point1, const geometry_msgs::Point &point2,
00333 const std::string &name, const rviz_visual_tools::colors &color)
00334 {
00335 return publishCollisionCuboid(convertPoint(point1), convertPoint(point2), name, color);
00336 }
00337 bool publishCollisionCuboid(const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const std::string &name,
00338 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00339 bool publishCollisionCuboid(const geometry_msgs::Point &point1, const geometry_msgs::Point &point2,
00340 const std::string &name,
00341 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00342
00352 bool publishCollisionCylinder(const geometry_msgs::Point &a, const geometry_msgs::Point &b,
00353 const std::string &object_name, double radius,
00354 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00355 bool publishCollisionCylinder(const Eigen::Vector3d &a, const Eigen::Vector3d &b, const std::string &object_name,
00356 double radius, const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00357
00367 bool publishCollisionCylinder(const Eigen::Affine3d &object_pose, const std::string &object_name, double radius,
00368 double height, const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00369 bool publishCollisionCylinder(const geometry_msgs::Pose &object_pose, const std::string &object_name, double radius,
00370 double height, const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00371
00380 bool publishCollisionMesh(const geometry_msgs::Pose &object_pose, const std::string &object_name,
00381 const std::string &mesh_path,
00382 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00383 bool publishCollisionMesh(const Eigen::Affine3d &object_pose, const std::string &object_name,
00384 const std::string &mesh_path,
00385 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00386 bool publishCollisionMesh(const Eigen::Affine3d &object_pose, const std::string &object_name,
00387 const shape_msgs::Mesh &mesh_msg,
00388 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00389 bool publishCollisionMesh(const geometry_msgs::Pose &object_pose, const std::string &object_name,
00390 const shape_msgs::Mesh &mesh_msg,
00391 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00392
00400 bool publishCollisionGraph(const graph_msgs::GeometryGraph &graph, const std::string &object_name, double radius,
00401 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00402
00406 void getCollisionWallMsg(double x, double y, double angle, double width, double height, const std::string name,
00407 moveit_msgs::CollisionObject &collision_obj);
00408
00420 RVIZ_VISUAL_TOOLS_DEPRECATED
00421 bool publishCollisionWall(double x, double y, double angle, double width, const std::string name,
00422 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00423
00424 bool publishCollisionWall(double x, double y, double angle = 0.0, double width = 2.0, double height = 1.5,
00425 const std::string name = "wall",
00426 const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00427
00440 bool publishCollisionTable(double x, double y, double angle, double width, double height, double depth,
00441 const std::string name, const rviz_visual_tools::colors &color = rviz_visual_tools::GREEN);
00442
00449 bool loadCollisionSceneFromFile(const std::string &path);
00450 bool loadCollisionSceneFromFile(const std::string &path, const Eigen::Affine3d &offset);
00451
00456 RVIZ_VISUAL_TOOLS_DEPRECATED
00457 bool publishCollisionTests();
00458
00464 bool publishWorkspaceParameters(const moveit_msgs::WorkspaceParameters ¶ms);
00465
00473 bool publishContactPoints(const moveit::core::RobotState &robot_state,
00474 const planning_scene::PlanningScene *planning_scene,
00475 const rviz_visual_tools::colors &color = rviz_visual_tools::RED);
00476
00488 bool publishTrajectoryPoint(const trajectory_msgs::JointTrajectoryPoint &trajectory_pt,
00489 const std::string &planning_group, double display_time = 0.1);
00490
00499 bool publishTrajectoryPath(const std::vector<moveit::core::RobotStatePtr> &trajectory,
00500 const moveit::core::JointModelGroup *jmg, double speed = 0.01, bool blocking = false);
00501 bool publishTrajectoryPath(const robot_trajectory::RobotTrajectoryPtr &trajectory, bool blocking = false);
00502 bool publishTrajectoryPath(const robot_trajectory::RobotTrajectory &trajectory, bool blocking = false);
00503 bool publishTrajectoryPath(const moveit_msgs::RobotTrajectory &trajectory_msg,
00504 const moveit::core::RobotStateConstPtr robot_state, bool blocking = false);
00505
00517 RVIZ_VISUAL_TOOLS_DEPRECATED
00518 bool publishTrajectoryLine(const moveit_msgs::RobotTrajectory &trajectory_msg,
00519 const moveit::core::LinkModel *ee_parent_link, const robot_model::JointModelGroup *arm_jmg,
00520 const rviz_visual_tools::colors &color, bool clear_all_markers)
00521 {
00522
00523 enableInternalBatchPublishing(true);
00524
00525 if (clear_all_markers)
00526 publishMarker(reset_marker_);
00527
00528 return publishTrajectoryLine(trajectory_msg, ee_parent_link, arm_jmg, color);
00529 }
00530
00531 RVIZ_VISUAL_TOOLS_DEPRECATED
00532 bool publishTrajectoryLine(const robot_trajectory::RobotTrajectoryPtr robot_trajectory,
00533 const moveit::core::LinkModel *ee_parent_link, const rviz_visual_tools::colors &color,
00534 bool clear_all_markers)
00535 {
00536
00537 enableInternalBatchPublishing(true);
00538
00539 if (clear_all_markers)
00540 publishMarker(reset_marker_);
00541
00542 return publishTrajectoryLine(robot_trajectory, ee_parent_link, color);
00543 }
00544
00545 RVIZ_VISUAL_TOOLS_DEPRECATED
00546 bool publishTrajectoryLine(const robot_trajectory::RobotTrajectory &robot_trajectory,
00547 const moveit::core::LinkModel *ee_parent_link, const rviz_visual_tools::colors &color,
00548 bool clear_all_markers)
00549 {
00550
00551 enableInternalBatchPublishing(true);
00552
00553 if (clear_all_markers)
00554 publishMarker(reset_marker_);
00555
00556 return publishTrajectoryLine(robot_trajectory, ee_parent_link, color);
00557 }
00558
00567 bool publishTrajectoryLine(const moveit_msgs::RobotTrajectory &trajectory_msg,
00568 const moveit::core::LinkModel *ee_parent_link, const robot_model::JointModelGroup *arm_jmg,
00569 const rviz_visual_tools::colors &color);
00570 bool publishTrajectoryLine(const robot_trajectory::RobotTrajectoryPtr robot_trajectory,
00571 const moveit::core::LinkModel *ee_parent_link, const rviz_visual_tools::colors &color);
00572 bool publishTrajectoryLine(const robot_trajectory::RobotTrajectory &robot_trajectory,
00573 const moveit::core::LinkModel *ee_parent_link, const rviz_visual_tools::colors &color);
00574
00581 bool publishTrajectoryPoints(const std::vector<moveit::core::RobotStatePtr> &robot_state_trajectory,
00582 const moveit::core::LinkModel *ee_parent_link,
00583 const rviz_visual_tools::colors &color = rviz_visual_tools::YELLOW);
00584
00586 void enableRobotStateRootOffet(const Eigen::Affine3d &offset);
00587
00589 void disableRobotStateRootOffet();
00590
00598 bool publishRobotState(const trajectory_msgs::JointTrajectoryPoint &trajectory_pt,
00599 const robot_model::JointModelGroup *jmg,
00600 const rviz_visual_tools::colors &color = rviz_visual_tools::DEFAULT);
00601
00608 bool publishRobotState(const moveit::core::RobotState &robot_state,
00609 const rviz_visual_tools::colors &color = rviz_visual_tools::DEFAULT);
00610 bool publishRobotState(const moveit::core::RobotStatePtr &robot_state,
00611 const rviz_visual_tools::colors &color = rviz_visual_tools::DEFAULT);
00612
00617 bool hideRobot();
00618
00620 bool applyVirtualJointTransform(moveit::core::RobotState &robot_state, const Eigen::Affine3d &offset);
00621
00626 void showJointLimits(moveit::core::RobotStatePtr robot_state);
00627
00628 private:
00633 planning_scene_monitor::PlanningSceneMonitorPtr getPlanningSceneMonitor();
00634
00639 bool checkForVirtualJoint(const moveit::core::RobotState &robot_state);
00640
00641 protected:
00642
00643 ros::Publisher pub_display_path_;
00644 ros::Publisher pub_robot_state_;
00645
00646
00647 planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_;
00648 robot_model_loader::RobotModelLoaderPtr rm_loader_;
00649
00650
00651 std::map<const robot_model::JointModelGroup *, visualization_msgs::MarkerArray> ee_markers_map_;
00652 std::map<const robot_model::JointModelGroup *, EigenSTL::vector_Affine3d> ee_poses_map_;
00653
00654
00655
00656
00657 std::map<rviz_visual_tools::colors, moveit_msgs::DisplayRobotState> display_robot_msgs_;
00658
00659
00660 moveit::core::RobotModelConstPtr robot_model_;
00661
00662
00663 moveit::core::RobotStatePtr shared_robot_state_;
00664
00665
00666 moveit::core::RobotStatePtr hidden_robot_state_;
00667
00668
00669
00670 moveit::core::RobotStatePtr root_robot_state_;
00671
00672
00673 bool robot_state_root_offset_enabled_;
00674 Eigen::Affine3d robot_state_root_offset_;
00675
00676
00677 bool mannual_trigger_update_;
00678
00679
00680 std::string robot_state_topic_;
00681 std::string planning_scene_topic_;
00682 };
00683
00684 typedef boost::shared_ptr<MoveItVisualTools> MoveItVisualToolsPtr;
00685 typedef boost::shared_ptr<const MoveItVisualTools> MoveItVisualToolsConstPtr;
00686
00687 }
00688
00689 #endif // MOVEIT_VISUAL_TOOLS_MOVEIT_VISUAL_TOOLS_H