Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef ACTION_HPP
00018 #define ACTION_HPP
00019
00020
00021 #include <ros/ros.h>
00022
00023
00024 #include <moveit/move_group_interface/move_group.h>
00025
00026
00027 #include <moveit_simple_grasps/simple_grasps.h>
00028 #include <moveit_simple_grasps/grasp_data.h>
00029
00030
00031 #include <moveit_visual_tools/moveit_visual_tools.h>
00032
00033
00034 #include <moveit/robot_state/robot_state.h>
00035 #include <moveit/robot_state/conversions.h>
00036
00037 #include "romeo_moveit_actions/metablock.hpp"
00038 #include "romeo_moveit_actions/postures.hpp"
00039
00040 #define FLAG_NO_MOVE 1
00041 #define FLAG_MOVE 2
00042
00043 namespace moveit_simple_actions
00044 {
00045
00047 class Action
00048 {
00049 public:
00051 Action(ros::NodeHandle *nh,
00052 const std::string &arm,
00053 const std::string &robot_name,
00054 const std::string &base_frame);
00055
00057 void initVisualTools(moveit_visual_tools::MoveItVisualToolsPtr &visual_tools);
00058
00060 bool pickAction(MetaBlock *block,
00061 const std::string surface_name,
00062 const int attempts_nbr=0,
00063 const double planning_time=0.0);
00064
00066 bool placeAction(MetaBlock *block,
00067 const std::string surface_name);
00068
00070 bool pickDefault(MetaBlock *block,
00071 const std::string surface_name);
00072
00074 bool graspPlan(MetaBlock *block,
00075 const std::string surface_name);
00076
00078 bool graspPlanAllPossible(MetaBlock *block,
00079 const std::string surface_name);
00080
00082 bool executeAction();
00083
00085 bool reachGrasp(MetaBlock *block,
00086 const std::string surface_name,
00087 int attempts_nbr=0,
00088 float tolerance_min=0.0f,
00089 double planning_time=0.0);
00090
00092 bool reachAction(geometry_msgs::PoseStamped pose_target,
00093 const std::string surface_name="",
00094 const int attempts_nbr=1);
00095
00097 bool poseHand(const int pose_id);
00098
00100 geometry_msgs::Pose getPose();
00101
00103 void poseHandOpen();
00104
00106 void poseHandClose();
00107
00109 bool poseHeadDown();
00110
00112 bool poseHeadZero();
00113
00115 void setTolerance(const double value);
00116
00118 void detachObject(const std::string &block_name);
00119
00121 std::string getBaseLink();
00122
00124 float computeDistance(MetaBlock *block);
00125
00127 float computeDistance(geometry_msgs::Pose goal);
00128
00130 geometry_msgs::PoseStamped getGraspPose(MetaBlock *block);
00131
00133 void releaseObject(MetaBlock *block);
00134
00136 const std::string plan_group_;
00137
00138 private:
00140 void attachObject(const std::string &block_name);
00141
00143 void publishPlanInfo(moveit::planning_interface::MoveGroup::Plan plan,
00144 geometry_msgs::Pose pose_target);
00145
00147 void setPlanningTime(const double value);
00148
00150 void setToleranceStep(const double value);
00151
00153 void setToleranceMin(const double value);
00154
00156 void setMaxVelocityScalingFactor(const double value);
00157
00159 void setVerbose(bool verbose);
00160
00162 void setAttemptsMax(int value);
00163
00165 void setFlag(int flag);
00166
00168 std::vector<moveit_msgs::Grasp> generateGrasps(MetaBlock *block);
00169
00171 std::vector<geometry_msgs::Pose> configureForPlanning(
00172 const std::vector<moveit_msgs::Grasp> &grasps);
00173
00175 bool setAllowedMoveItCollisionMatrix(moveit_msgs::AllowedCollisionMatrix& m);
00176
00178 bool getCurrentMoveItAllowedCollisionMatrix(moveit_msgs::AllowedCollisionMatrix& matrix);
00179
00181 std::vector<std::string>::iterator ensureExistsInACM(const std::string& name,
00182 moveit_msgs::AllowedCollisionMatrix& m,
00183 bool initFlag);
00184
00186 void expandMoveItCollisionMatrix(const std::string& name,
00187 moveit_msgs::AllowedCollisionMatrix& m,
00188 bool default_val);
00189
00191 void updateCollisionMatrix(const std::string& name);
00192
00193
00195 const std::string end_eff_;
00196
00198 Posture posture_;
00199
00201 moveit_simple_grasps::GraspData grasp_data_;
00202
00204 boost::scoped_ptr<move_group_interface::MoveGroup> move_group_;
00205
00207 moveit_simple_grasps::SimpleGraspsPtr simple_grasps_;
00208
00210 boost::shared_ptr<moveit::planning_interface::MoveGroup::Plan> current_plan_;
00211
00213 moveit_visual_tools::MoveItVisualToolsPtr visual_tools_;
00214
00216 moveit::planning_interface::PlanningSceneInterface current_scene_;
00217
00219 ros::Publisher pub_obj_pose_;
00220
00222 ros::Publisher pub_plan_pose_;
00223
00225 ros::Publisher pub_plan_traj_;
00226
00228 ros::ServiceClient client_fk_;
00229
00231 bool verbose_;
00232
00234 int attempts_max_;
00235
00237 double planning_time_;
00238
00240 std::string planner_id_;
00241
00243 double tolerance_min_;
00244
00246 double tolerance_step_;
00247
00249 double max_velocity_scaling_factor_;
00250
00252 float dist_th_;
00253
00255 int flag_;
00256
00258 std::string object_attached_;
00259
00261 tf::TransformListener listener_;
00262
00264 ros::Publisher planning_scene_publisher_;
00265
00267 ros::ServiceClient planning_scene_client_;
00268
00270 std::vector<std::string> allowedCollisionLinks_;
00271
00273 std::string base_frame_;
00274 };
00275 }
00276 #endif // ACTION_HPP