move_group_interface.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2014, SRI International
5  * Copyright (c) 2012, Willow Garage, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Willow Garage nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 /* Author: Ioan Sucan, Sachin Chitta */
37 
38 #ifndef MOVEIT_MOVE_GROUP_INTERFACE_MOVE_GROUP_INTERFACE_
39 #define MOVEIT_MOVE_GROUP_INTERFACE_MOVE_GROUP_INTERFACE_
40 
43 #include <moveit_msgs/RobotTrajectory.h>
44 #include <moveit_msgs/RobotState.h>
45 #include <moveit_msgs/PlannerInterfaceDescription.h>
46 #include <moveit_msgs/Constraints.h>
47 #include <moveit_msgs/Grasp.h>
48 #include <moveit_msgs/PlaceLocation.h>
49 #include <moveit_msgs/PickupGoal.h>
50 #include <moveit_msgs/PlaceGoal.h>
51 #include <moveit_msgs/MotionPlanRequest.h>
52 #include <moveit_msgs/MoveGroupAction.h>
53 #include <geometry_msgs/PoseStamped.h>
55 #include <memory>
56 #include <tf2_ros/buffer.h>
57 
58 namespace moveit
59 {
61 namespace planning_interface
62 {
63 class MoveItErrorCode : public moveit_msgs::MoveItErrorCodes
64 {
65 public:
67  {
68  val = 0;
69  }
70  MoveItErrorCode(int code)
71  {
72  val = code;
73  }
74  MoveItErrorCode(const moveit_msgs::MoveItErrorCodes& code)
75  {
76  val = code.val;
77  }
78  explicit operator bool() const
79  {
80  return val == moveit_msgs::MoveItErrorCodes::SUCCESS;
81  }
82  bool operator==(const int c) const
83  {
84  return val == c;
85  }
86  bool operator!=(const int c) const
87  {
88  return val != c;
89  }
90 };
91 
93 
100 {
101 public:
103  static const std::string ROBOT_DESCRIPTION;
104 
106  struct Options
107  {
108  Options(const std::string& group_name, const std::string& desc = ROBOT_DESCRIPTION,
109  const ros::NodeHandle& node_handle = ros::NodeHandle())
110  : group_name_(group_name), robot_description_(desc), node_handle_(node_handle)
111  {
112  }
113 
115  std::string group_name_;
116 
118  std::string robot_description_;
119 
121  robot_model::RobotModelConstPtr robot_model_;
122 
124  };
125 
127 
129  struct Plan
130  {
132  moveit_msgs::RobotState start_state_;
133 
135  moveit_msgs::RobotTrajectory trajectory_;
136 
139  };
140 
151  MoveGroupInterface(const Options& opt,
152  const std::shared_ptr<tf2_ros::Buffer>& tf_buffer = std::shared_ptr<tf2_ros::Buffer>(),
153  const ros::WallDuration& wait_for_servers = ros::WallDuration());
154  [[deprecated]] MoveGroupInterface(const Options& opt, const std::shared_ptr<tf2_ros::Buffer>& tf_buffer,
155  const ros::Duration& wait_for_servers);
156 
164  MoveGroupInterface(const std::string& group,
165  const std::shared_ptr<tf2_ros::Buffer>& tf_buffer = std::shared_ptr<tf2_ros::Buffer>(),
166  const ros::WallDuration& wait_for_servers = ros::WallDuration());
167  [[deprecated]] MoveGroupInterface(const std::string& group, const std::shared_ptr<tf2_ros::Buffer>& tf_buffer,
168  const ros::Duration& wait_for_servers);
169 
171 
177  MoveGroupInterface(const MoveGroupInterface&) = delete;
178  MoveGroupInterface& operator=(const MoveGroupInterface&) = delete;
179 
181  MoveGroupInterface& operator=(MoveGroupInterface&& other);
182 
184  const std::string& getName() const;
185 
188  const std::vector<std::string> getNamedTargets();
189 
191  robot_model::RobotModelConstPtr getRobotModel() const;
192 
194  const ros::NodeHandle& getNodeHandle() const;
195 
197  const std::string& getPlanningFrame() const;
198 
200  const std::vector<std::string>& getJointModelGroupNames() const;
201 
203  const std::vector<std::string>& getJointNames();
204 
206  const std::vector<std::string>& getLinkNames();
207 
209  std::map<std::string, double> getNamedTargetValues(const std::string& name);
210 
212  const std::vector<std::string>& getActiveJoints() const;
213 
215  const std::vector<std::string>& getJoints() const;
216 
219  unsigned int getVariableCount() const;
220 
222  bool getInterfaceDescription(moveit_msgs::PlannerInterfaceDescription& desc);
223 
225  std::map<std::string, std::string> getPlannerParams(const std::string& planner_id, const std::string& group = "");
226 
228  void setPlannerParams(const std::string& planner_id, const std::string& group,
229  const std::map<std::string, std::string>& params, bool bReplace = false);
230 
232  std::string getDefaultPlannerId(const std::string& group = "") const;
233 
235  void setPlannerId(const std::string& planner_id);
236 
238  const std::string& getPlannerId() const;
239 
241  void setPlanningTime(double seconds);
242 
245  void setNumPlanningAttempts(unsigned int num_planning_attempts);
246 
252  void setMaxVelocityScalingFactor(double max_velocity_scaling_factor);
253 
259  void setMaxAccelerationScalingFactor(double max_acceleration_scaling_factor);
260 
262  double getPlanningTime() const;
263 
266  double getGoalJointTolerance() const;
267 
270  double getGoalPositionTolerance() const;
271 
274  double getGoalOrientationTolerance() const;
275 
282  void setGoalTolerance(double tolerance);
283 
286  void setGoalJointTolerance(double tolerance);
287 
289  void setGoalPositionTolerance(double tolerance);
290 
292  void setGoalOrientationTolerance(double tolerance);
293 
298  void setWorkspace(double minx, double miny, double minz, double maxx, double maxy, double maxz);
299 
302  void setStartState(const moveit_msgs::RobotState& start_state);
303 
306  void setStartState(const robot_state::RobotState& start_state);
307 
309  void setStartStateToCurrentState();
310 
313  void setSupportSurfaceName(const std::string& name);
314 
345  bool setJointValueTarget(const std::vector<double>& group_variable_values);
346 
362  bool setJointValueTarget(const std::map<std::string, double>& variable_values);
363 
373  bool setJointValueTarget(const robot_state::RobotState& robot_state);
374 
386  bool setJointValueTarget(const std::string& joint_name, const std::vector<double>& values);
387 
399  bool setJointValueTarget(const std::string& joint_name, double value);
400 
411  bool setJointValueTarget(const sensor_msgs::JointState& state);
412 
424  bool setJointValueTarget(const geometry_msgs::Pose& eef_pose, const std::string& end_effector_link = "");
425 
437  bool setJointValueTarget(const geometry_msgs::PoseStamped& eef_pose, const std::string& end_effector_link = "");
438 
450  bool setJointValueTarget(const Eigen::Isometry3d& eef_pose, const std::string& end_effector_link = "");
451 
462  bool setApproximateJointValueTarget(const geometry_msgs::Pose& eef_pose, const std::string& end_effector_link = "");
463 
474  bool setApproximateJointValueTarget(const geometry_msgs::PoseStamped& eef_pose,
475  const std::string& end_effector_link = "");
476 
487  bool setApproximateJointValueTarget(const Eigen::Isometry3d& eef_pose, const std::string& end_effector_link = "");
488 
493  void setRandomTarget();
494 
497  bool setNamedTarget(const std::string& name);
498 
500  const robot_state::RobotState& getJointValueTarget() const;
501 
523  bool setPositionTarget(double x, double y, double z, const std::string& end_effector_link = "");
524 
532  bool setRPYTarget(double roll, double pitch, double yaw, const std::string& end_effector_link = "");
533 
542  bool setOrientationTarget(double x, double y, double z, double w, const std::string& end_effector_link = "");
543 
551  bool setPoseTarget(const Eigen::Isometry3d& end_effector_pose, const std::string& end_effector_link = "");
552 
560  bool setPoseTarget(const geometry_msgs::Pose& target, const std::string& end_effector_link = "");
561 
569  bool setPoseTarget(const geometry_msgs::PoseStamped& target, const std::string& end_effector_link = "");
570 
589  bool setPoseTargets(const EigenSTL::vector_Isometry3d& end_effector_pose, const std::string& end_effector_link = "");
590 
609  bool setPoseTargets(const std::vector<geometry_msgs::Pose>& target, const std::string& end_effector_link = "");
610 
629  bool setPoseTargets(const std::vector<geometry_msgs::PoseStamped>& target, const std::string& end_effector_link = "");
630 
632  void setPoseReferenceFrame(const std::string& pose_reference_frame);
633 
637  bool setEndEffectorLink(const std::string& end_effector_link);
638 
641  bool setEndEffector(const std::string& eef_name);
642 
644  void clearPoseTarget(const std::string& end_effector_link = "");
645 
647  void clearPoseTargets();
648 
655  const geometry_msgs::PoseStamped& getPoseTarget(const std::string& end_effector_link = "") const;
656 
662  const std::vector<geometry_msgs::PoseStamped>& getPoseTargets(const std::string& end_effector_link = "") const;
663 
669  const std::string& getEndEffectorLink() const;
670 
676  const std::string& getEndEffector() const;
677 
680  const std::string& getPoseReferenceFrame() const;
681 
692  MoveItErrorCode asyncMove();
693 
698 
703  MoveItErrorCode move();
704 
708  MoveItErrorCode plan(Plan& plan);
709 
711  MoveItErrorCode asyncExecute(const Plan& plan);
712 
714  MoveItErrorCode asyncExecute(const moveit_msgs::RobotTrajectory& trajectory);
715 
717  MoveItErrorCode execute(const Plan& plan);
718 
720  MoveItErrorCode execute(const moveit_msgs::RobotTrajectory& trajectory);
721 
731  double computeCartesianPath(const std::vector<geometry_msgs::Pose>& waypoints, double eef_step, double jump_threshold,
732  moveit_msgs::RobotTrajectory& trajectory, bool avoid_collisions = true,
733  moveit_msgs::MoveItErrorCodes* error_code = NULL);
734 
747  double computeCartesianPath(const std::vector<geometry_msgs::Pose>& waypoints, double eef_step, double jump_threshold,
748  moveit_msgs::RobotTrajectory& trajectory,
749  const moveit_msgs::Constraints& path_constraints, bool avoid_collisions = true,
750  moveit_msgs::MoveItErrorCodes* error_code = NULL);
751 
753  void stop();
754 
757  void allowLooking(bool flag);
758 
760  void allowReplanning(bool flag);
761 
764  void constructMotionPlanRequest(moveit_msgs::MotionPlanRequest& request);
765 
767  moveit_msgs::PickupGoal constructPickupGoal(const std::string& object, std::vector<moveit_msgs::Grasp> grasps,
768  bool plan_only);
769 
771  moveit_msgs::PlaceGoal constructPlaceGoal(const std::string& object,
772  std::vector<moveit_msgs::PlaceLocation> locations, bool plan_only);
773 
775  std::vector<moveit_msgs::PlaceLocation> posesToPlaceLocations(const std::vector<geometry_msgs::PoseStamped>& poses);
776 
787  MoveItErrorCode pick(const std::string& object, bool plan_only = false)
788  {
789  return pick(constructPickupGoal(object, std::vector<moveit_msgs::Grasp>(), plan_only));
790  }
791 
793  MoveItErrorCode pick(const std::string& object, const moveit_msgs::Grasp& grasp, bool plan_only = false)
794  {
795  return pick(constructPickupGoal(object, { grasp }, plan_only));
796  }
797 
799  MoveItErrorCode pick(const std::string& object, std::vector<moveit_msgs::Grasp> grasps, bool plan_only = false)
800  {
801  return pick(constructPickupGoal(object, std::move(grasps), plan_only));
802  }
803 
808  MoveItErrorCode pick(const moveit_msgs::PickupGoal& goal);
809 
813  MoveItErrorCode planGraspsAndPick(const std::string& object = "", bool plan_only = false);
814 
818  MoveItErrorCode planGraspsAndPick(const moveit_msgs::CollisionObject& object, bool plan_only = false);
819 
821  MoveItErrorCode place(const std::string& object, bool plan_only = false)
822  {
823  return place(constructPlaceGoal(object, std::vector<moveit_msgs::PlaceLocation>(), plan_only));
824  }
825 
827  MoveItErrorCode place(const std::string& object, std::vector<moveit_msgs::PlaceLocation> locations,
828  bool plan_only = false)
829  {
830  return place(constructPlaceGoal(object, std::move(locations), plan_only));
831  }
832 
834  MoveItErrorCode place(const std::string& object, const std::vector<geometry_msgs::PoseStamped>& poses,
835  bool plan_only = false)
836  {
837  return place(constructPlaceGoal(object, posesToPlaceLocations(poses), plan_only));
838  }
839 
841  MoveItErrorCode place(const std::string& object, const geometry_msgs::PoseStamped& pose, bool plan_only = false)
842  {
843  return place(constructPlaceGoal(object, posesToPlaceLocations({ pose }), plan_only));
844  }
845 
850  MoveItErrorCode place(const moveit_msgs::PlaceGoal& goal);
851 
858  bool attachObject(const std::string& object, const std::string& link = "");
859 
868  bool attachObject(const std::string& object, const std::string& link, const std::vector<std::string>& touch_links);
869 
875  bool detachObject(const std::string& name = "");
876 
889  bool startStateMonitor(double wait = 1.0);
890 
892  std::vector<double> getCurrentJointValues();
893 
895  robot_state::RobotStatePtr getCurrentState(double wait = 1);
896 
900  geometry_msgs::PoseStamped getCurrentPose(const std::string& end_effector_link = "");
901 
905  std::vector<double> getCurrentRPY(const std::string& end_effector_link = "");
906 
908  std::vector<double> getRandomJointValues();
909 
913  geometry_msgs::PoseStamped getRandomPose(const std::string& end_effector_link = "");
914 
926  void rememberJointValues(const std::string& name);
927 
932  void rememberJointValues(const std::string& name, const std::vector<double>& values);
933 
935  const std::map<std::string, std::vector<double> >& getRememberedJointValues() const
936  {
937  return remembered_joint_values_;
938  }
939 
941  void forgetJointValues(const std::string& name);
942 
951  void setConstraintsDatabase(const std::string& host, unsigned int port);
952 
954  std::vector<std::string> getKnownConstraints() const;
955 
959  moveit_msgs::Constraints getPathConstraints() const;
960 
964  bool setPathConstraints(const std::string& constraint);
965 
969  void setPathConstraints(const moveit_msgs::Constraints& constraint);
970 
973  void clearPathConstraints();
974 
975  moveit_msgs::TrajectoryConstraints getTrajectoryConstraints() const;
976  void setTrajectoryConstraints(const moveit_msgs::TrajectoryConstraints& constraint);
977  void clearTrajectoryConstraints();
978 
981 private:
982  std::map<std::string, std::vector<double> > remembered_joint_values_;
985 };
986 } // namespace planning_interface
987 } // namespace moveit
988 
989 #endif
MoveItErrorCode(const moveit_msgs::MoveItErrorCodes &code)
MoveItErrorCode place(const std::string &object, std::vector< moveit_msgs::PlaceLocation > locations, bool plan_only=false)
Place an object at one of the specified possible locations.
moveit_msgs::RobotTrajectory trajectory_
The trajectory of the robot (may not contain joints that are the same as for the start_state_) ...
static const std::string ROBOT_DESCRIPTION
Default ROS parameter name from where to read the robot&#39;s URDF. Set to &#39;robot_description&#39;.
MoveItErrorCode place(const std::string &object, bool plan_only=false)
Place an object somewhere safe in the world (a safe location will be detected)
std::vector< double > values
std::map< std::string, std::vector< double > > remembered_joint_values_
void wait(int seconds)
ROSCONSOLE_CONSOLE_IMPL_DECL std::string getName(void *handle)
name
MoveItErrorCode place(const std::string &object, const geometry_msgs::PoseStamped &pose, bool plan_only=false)
Place an object at one of the specified possible location.
Eigen::Isometry3d getRandomPose(random_numbers::RandomNumberGenerator &g)
MoveItErrorCode place(const std::string &object, const std::vector< geometry_msgs::PoseStamped > &poses, bool plan_only=false)
Place an object at one of the specified possible locations.
Specification of options to use when constructing the MoveGroupInterface class.
std::string robot_description_
The robot description parameter name (if different from default)
MOVEIT_STRUCT_FORWARD(CollisionGeometryData)
ROSCPP_DECL bool execute(const std::string &method, const XmlRpc::XmlRpcValue &request, XmlRpc::XmlRpcValue &response, XmlRpc::XmlRpcValue &payload, bool wait_for_master)
void attachObject()
Definition: demo.cpp:104
Options(const std::string &group_name, const std::string &desc=ROBOT_DESCRIPTION, const ros::NodeHandle &node_handle=ros::NodeHandle())
Client class to conveniently use the ROS interfaces provided by the move_group node.
robot_model::RobotModelConstPtr robot_model_
Optionally, an instance of the RobotModel to use can be also specified.
moveit_msgs::RobotState start_state_
The full starting state used for planning.
const std::map< std::string, std::vector< double > > & getRememberedJointValues() const
Get the currently remembered map of names to joint values.
std::vector< Eigen::Isometry3d, Eigen::aligned_allocator< Eigen::Isometry3d > > vector_Isometry3d
MoveItErrorCode pick(const std::string &object, const moveit_msgs::Grasp &grasp, bool plan_only=false)
Pick up an object given a grasp pose.
std::string group_name_
The group to construct the class instance for.
MoveItErrorCode pick(const std::string &object, std::vector< moveit_msgs::Grasp > grasps, bool plan_only=false)
Pick up an object given possible grasp poses.
double planning_time_
The amount of time it took to generate the plan.
The representation of a motion plan (as ROS messasges)
MoveItErrorCode pick(const std::string &object, bool plan_only=false)
Pick up an object.
MOVEIT_CLASS_FORWARD(MoveGroupInterface)


planning_interface
Author(s): Ioan Sucan
autogenerated on Fri Aug 14 2020 03:59:32