44#include <moveit_msgs/msg/robot_trajectory.hpp>
45#include <moveit_msgs/msg/robot_state.hpp>
46#include <moveit_msgs/msg/planner_interface_description.hpp>
47#include <moveit_msgs/msg/constraints.hpp>
48#include <moveit_msgs/msg/grasp.hpp>
49#include <moveit_msgs/action/move_group.hpp>
50#include <moveit_msgs/action/execute_trajectory.hpp>
51#include <rclcpp/logger.hpp>
52#include <rclcpp/version.h>
54#include <moveit_msgs/msg/motion_plan_request.hpp>
55#include <geometry_msgs/msg/pose_stamped.hpp>
57#include <rclcpp_action/rclcpp_action.hpp>
62#if RCLCPP_VERSION_GTE(29, 6, 0)
63#include <tf2_ros/buffer.hpp>
66#include <tf2_ros/buffer.h>
69#include <moveit_move_group_interface_export.h>
138 const std::shared_ptr<tf2_ros::Buffer>& tf_buffer = std::shared_ptr<tf2_ros::Buffer>(),
139 const rclcpp::Duration& wait_for_servers = rclcpp::Duration::from_seconds(-1));
149 const std::shared_ptr<tf2_ros::Buffer>& tf_buffer = std::shared_ptr<tf2_ros::Buffer>(),
150 const rclcpp::Duration& wait_for_servers = rclcpp::Duration::from_seconds(-1));
165 const std::string&
getName()
const;
172 const std::shared_ptr<tf2_ros::Buffer>&
getTF()
const;
178 const rclcpp::Node::SharedPtr&
getNode()
const;
199 const std::vector<std::string>&
getJoints()
const;
212 std::map<std::string, std::string>
getPlannerParams(
const std::string& planner_id,
213 const std::string& group =
"")
const;
216 void setPlannerParams(
const std::string& planner_id,
const std::string& group,
217 const std::map<std::string, std::string>& params,
bool bReplace =
false);
300 void setWorkspace(
double minx,
double miny,
double minz,
double maxx,
double maxy,
double maxz);
304 void setStartState(
const moveit_msgs::msg::RobotState& start_state);
376 bool setJointValueTarget(
const std::vector<std::string>& variable_names,
const std::vector<double>& variable_values);
400 bool setJointValueTarget(
const std::string& joint_name,
const std::vector<double>& values);
438 bool setJointValueTarget(
const geometry_msgs::msg::Pose& eef_pose,
const std::string& end_effector_link =
"");
451 bool setJointValueTarget(
const geometry_msgs::msg::PoseStamped& eef_pose,
const std::string& end_effector_link =
"");
464 bool setJointValueTarget(
const Eigen::Isometry3d& eef_pose,
const std::string& end_effector_link =
"");
477 const std::string& end_effector_link =
"");
490 const std::string& end_effector_link =
"");
538 bool setPositionTarget(
double x,
double y,
double z,
const std::string& end_effector_link =
"");
547 bool setRPYTarget(
double roll,
double pitch,
double yaw,
const std::string& end_effector_link =
"");
557 bool setOrientationTarget(
double x,
double y,
double z,
double w,
const std::string& end_effector_link =
"");
566 bool setPoseTarget(
const Eigen::Isometry3d& end_effector_pose,
const std::string& end_effector_link =
"");
575 bool setPoseTarget(
const geometry_msgs::msg::Pose& target,
const std::string& end_effector_link =
"");
584 bool setPoseTarget(
const geometry_msgs::msg::PoseStamped& target,
const std::string& end_effector_link =
"");
604 bool setPoseTargets(
const EigenSTL::vector_Isometry3d& end_effector_pose,
const std::string& end_effector_link =
"");
624 bool setPoseTargets(
const std::vector<geometry_msgs::msg::Pose>& target,
const std::string& end_effector_link =
"");
644 bool setPoseTargets(
const std::vector<geometry_msgs::msg::PoseStamped>& target,
645 const std::string& end_effector_link =
"");
671 const geometry_msgs::msg::PoseStamped&
getPoseTarget(
const std::string& end_effector_link =
"")
const;
678 const std::vector<geometry_msgs::msg::PoseStamped>&
getPoseTargets(
const std::string& end_effector_link =
"")
const;
734 const std::vector<std::string>& controllers = std::vector<std::string>());
743 const std::vector<std::string>& controllers = std::vector<std::string>());
752 const std::vector<std::string>& controllers = std::vector<std::string>());
761 const std::vector<std::string>& controllers = std::vector<std::string>());
772 [[deprecated(
"Drop jump_threshold")]]
double
774 double , moveit_msgs::msg::RobotTrajectory& trajectory,
775 bool avoid_collisions =
true, moveit_msgs::msg::MoveItErrorCodes* error_code =
nullptr)
779 double computeCartesianPath(
const std::vector<geometry_msgs::msg::Pose>& waypoints,
double eef_step,
780 moveit_msgs::msg::RobotTrajectory& trajectory,
bool avoid_collisions =
true,
781 moveit_msgs::msg::MoveItErrorCodes* error_code =
nullptr);
795 [[deprecated(
"Drop jump_threshold")]]
double
797 double , moveit_msgs::msg::RobotTrajectory& trajectory,
798 const moveit_msgs::msg::Constraints& path_constraints,
bool avoid_collisions =
true,
799 moveit_msgs::msg::MoveItErrorCodes* error_code =
nullptr)
801 return computeCartesianPath(waypoints, eef_step, trajectory, path_constraints, avoid_collisions, error_code);
803 double computeCartesianPath(
const std::vector<geometry_msgs::msg::Pose>& waypoints,
double eef_step,
804 moveit_msgs::msg::RobotTrajectory& trajectory,
805 const moveit_msgs::msg::Constraints& path_constraints,
bool avoid_collisions =
true,
806 moveit_msgs::msg::MoveItErrorCodes* error_code =
nullptr);
812 void allowReplanning(
bool flag);
815 void setReplanAttempts(int32_t attempts);
818 void setReplanDelay(
double delay);
822 void allowLooking(
bool flag);
825 void setLookAroundAttempts(int32_t attempts);
833 void constructRobotState(moveit_msgs::msg::RobotState& state);
837 void constructMotionPlanRequest(moveit_msgs::msg::MotionPlanRequest& request);
852 bool attachObject(
const std::string&
object,
const std::string& link =
"");
862 bool attachObject(
const std::string&
object,
const std::string& link,
const std::vector<std::string>& touch_links);
869 bool detachObject(
const std::string& name =
"");
883 bool startStateMonitor(
double wait = 1.0);
886 std::vector<double> getCurrentJointValues()
const;
889 moveit::core::RobotStatePtr getCurrentState(
double wait = 1)
const;
894 geometry_msgs::msg::PoseStamped getCurrentPose(
const std::string& end_effector_link =
"")
const;
899 std::vector<double> getCurrentRPY(
const std::string& end_effector_link =
"")
const;
902 std::vector<double> getRandomJointValues()
const;
907 geometry_msgs::msg::PoseStamped getRandomPose(
const std::string& end_effector_link =
"")
const;
920 void rememberJointValues(
const std::string& name);
926 void rememberJointValues(
const std::string& name,
const std::vector<double>& values);
931 return remembered_joint_values_;
935 void forgetJointValues(
const std::string& name);
945 void setConstraintsDatabase(
const std::string& host,
unsigned int port);
948 std::vector<std::string> getKnownConstraints()
const;
953 moveit_msgs::msg::Constraints getPathConstraints()
const;
958 bool setPathConstraints(
const std::string& constraint);
963 void setPathConstraints(
const moveit_msgs::msg::Constraints& constraint);
967 void clearPathConstraints();
969 moveit_msgs::msg::TrajectoryConstraints getTrajectoryConstraints()
const;
970 void setTrajectoryConstraints(
const moveit_msgs::msg::TrajectoryConstraints& constraint);
971 void clearTrajectoryConstraints();
980 std::map<std::string, std::vector<double> > remembered_joint_values_;
981 class MoveGroupInterfaceImpl;
982 MoveGroupInterfaceImpl* impl_;
983 rclcpp::Logger logger_;
MoveGroupInterface(const rclcpp::Node::SharedPtr &node, const Options &opt, const std::shared_ptr< tf2_ros::Buffer > &tf_buffer=std::shared_ptr< tf2_ros::Buffer >(), const rclcpp::Duration &wait_for_servers=rclcpp::Duration::from_seconds(-1))
Construct a MoveGroupInterface instance call using a specified set of options opt.
#define MOVEIT_CLASS_FORWARD(C)
a wrapper around moveit_msgs::MoveItErrorCodes to make it easier to return an error code message from...
Representation of a robot's state. This includes position, velocity, acceleration and effort.
Client class to conveniently use the ROS interfaces provided by the move_group node.
double computeCartesianPath(const std::vector< geometry_msgs::msg::Pose > &waypoints, double eef_step, double, moveit_msgs::msg::RobotTrajectory &trajectory, bool avoid_collisions=true, moveit_msgs::msg::MoveItErrorCodes *error_code=nullptr)
Compute a Cartesian path that follows specified waypoints with a step size of at most eef_step meters...
void setMaxVelocityScalingFactor(double max_velocity_scaling_factor)
Set a scaling factor for optionally reducing the maximum joint velocity. Allowed values are in (0,...
const std::string & getEndEffectorLink() const
Get the current end-effector link. This returns the value set by setEndEffectorLink() (or indirectly ...
static const std::string ROBOT_DESCRIPTION
Default ROS parameter name from where to read the robot's URDF. Set to 'robot_description'.
const std::vector< std::string > & getNamedTargets() const
Get the names of the named robot states available as targets, both either remembered states or defaul...
std::map< std::string, std::string > getPlannerParams(const std::string &planner_id, const std::string &group="") const
Get the planner parameters for given group and planner_id.
MoveGroupInterface(const rclcpp::Node::SharedPtr &node, const Options &opt, const std::shared_ptr< tf2_ros::Buffer > &tf_buffer=std::shared_ptr< tf2_ros::Buffer >(), const rclcpp::Duration &wait_for_servers=rclcpp::Duration::from_seconds(-1))
Construct a MoveGroupInterface instance call using a specified set of options opt.
const std::string & getPlannerId() const
Get the current planner_id.
MoveGroupInterface & operator=(const MoveGroupInterface &)=delete
moveit::core::MoveItErrorCode plan(Plan &plan)
Compute a motion plan that takes the group declared in the constructor from the current state to the ...
void setGoalTolerance(double tolerance)
Set the tolerance that is used for reaching the goal. For joint state goals, this will be distance fo...
void setGoalPositionTolerance(double tolerance)
Set the position tolerance that is used for reaching the goal when moving to a pose.
const std::string & getPlanningFrame() const
Get the name of the frame in which the robot is planning.
bool setPoseTargets(const EigenSTL::vector_Isometry3d &end_effector_pose, const std::string &end_effector_link="")
Set goal poses for end_effector_link.
bool setPoseTarget(const Eigen::Isometry3d &end_effector_pose, const std::string &end_effector_link="")
Set the goal pose of the end-effector end_effector_link.
moveit::core::MoveItErrorCode asyncMove()
Plan and execute a trajectory that takes the group of joints declared in the constructor to the speci...
void setPlanningPipelineId(const std::string &pipeline_id)
Specify a planning pipeline to be used for further planning.
double getGoalJointTolerance() const
Get the tolerance that is used for reaching a joint goal. This is distance for each joint in configur...
MOVEIT_STRUCT_FORWARD(Plan)
MoveGroupInterface(const MoveGroupInterface &)=delete
This class owns unique resources (e.g. action clients, threads) and its not very meaningful to copy....
bool setEndEffectorLink(const std::string &end_effector_link)
Specify the parent link of the end-effector. This end_effector_link will be used in calls to pose tar...
void setStartStateToCurrentState()
Set the starting state for planning to be that reported by the robot's joint state publication.
bool getInterfaceDescriptions(std::vector< moveit_msgs::msg::PlannerInterfaceDescription > &desc) const
Get the descriptions of all planning plugins loaded by the action server.
void setMaxAccelerationScalingFactor(double max_acceleration_scaling_factor)
Set a scaling factor for optionally reducing the maximum joint acceleration. Allowed values are in (0...
bool setPositionTarget(double x, double y, double z, const std::string &end_effector_link="")
Set the goal position of the end-effector end_effector_link to be (x, y, z).
const std::string & getEndEffector() const
Get the current end-effector name. This returns the value set by setEndEffector() (or indirectly by s...
std::string getDefaultPlanningPipelineId() const
void setNumPlanningAttempts(unsigned int num_planning_attempts)
Set the number of times the motion plan is to be computed from scratch before the shortest solution i...
rclcpp_action::Client< moveit_msgs::action::MoveGroup > & getMoveGroupClient() const
Get the move_group action client used by the MoveGroupInterface. The client can be used for querying ...
bool setNamedTarget(const std::string &name)
Set the current joint values to be ones previously remembered by rememberJointValues() or,...
const std::vector< std::string > & getJointNames() const
Get vector of names of joints available in move group.
moveit::core::MoveItErrorCode move()
Plan and execute a trajectory that takes the group of joints declared in the constructor to the speci...
double computeCartesianPath(const std::vector< geometry_msgs::msg::Pose > &waypoints, double eef_step, double, moveit_msgs::msg::RobotTrajectory &trajectory, const moveit_msgs::msg::Constraints &path_constraints, bool avoid_collisions=true, moveit_msgs::msg::MoveItErrorCodes *error_code=nullptr)
Compute a Cartesian path that follows specified waypoints with a step size of at most eef_step meters...
moveit::core::RobotModelConstPtr getRobotModel() const
Get the RobotModel object.
moveit::core::MoveItErrorCode execute(const Plan &plan, const std::vector< std::string > &controllers=std::vector< std::string >())
Given a plan, execute it while waiting for completion.
bool setOrientationTarget(double x, double y, double z, double w, const std::string &end_effector_link="")
Set the goal orientation of the end-effector end_effector_link to be the quaternion (x,...
bool setJointValueTarget(const std::vector< double > &group_variable_values)
Set the JointValueTarget and use it for future planning requests.
const rclcpp::Node::SharedPtr & getNode() const
Get the ROS node handle of this instance operates on.
bool setRPYTarget(double roll, double pitch, double yaw, const std::string &end_effector_link="")
Set the goal orientation of the end-effector end_effector_link to be (roll,pitch,yaw) radians.
void setGoalOrientationTolerance(double tolerance)
Set the orientation tolerance that is used for reaching the goal when moving to a pose.
void clearPoseTarget(const std::string &end_effector_link="")
Forget pose(s) specified for end_effector_link.
const geometry_msgs::msg::PoseStamped & getPoseTarget(const std::string &end_effector_link="") const
void setGoalJointTolerance(double tolerance)
Set the joint tolerance (for each joint) that is used for reaching the goal when moving to a joint va...
std::string getDefaultPlannerId(const std::string &group="") const
Get the default planner of the current planning pipeline for the given group (or the pipeline's defau...
void setRandomTarget()
Set the joint state goal to a random joint configuration.
void getJointValueTarget(std::vector< double > &group_variable_values) const
Get the current joint state goal in a form compatible to setJointValueTarget().
const std::vector< std::string > & getActiveJoints() const
Get only the active (actuated) joints this instance operates on.
bool getInterfaceDescription(moveit_msgs::msg::PlannerInterfaceDescription &desc) const
Get the description of the default planning plugin loaded by the action server.
const std::string & getName() const
Get the name of the group this instance operates on.
moveit::core::MoveItErrorCode asyncExecute(const Plan &plan, const std::vector< std::string > &controllers=std::vector< std::string >())
Given a plan, execute it without waiting for completion.
const std::vector< std::string > & getJoints() const
Get all the joints this instance operates on (including fixed joints).
void setPoseReferenceFrame(const std::string &pose_reference_frame)
Specify which reference frame to assume for poses specified without a reference frame.
const std::shared_ptr< tf2_ros::Buffer > & getTF() const
Get the tf2_ros::Buffer.
const std::vector< geometry_msgs::msg::PoseStamped > & getPoseTargets(const std::string &end_effector_link="") const
double getMaxVelocityScalingFactor() const
Get the max velocity scaling factor set by setMaxVelocityScalingFactor().
const std::vector< std::string > & getLinkNames() const
Get vector of names of links available in move group.
double getMaxAccelerationScalingFactor() const
Get the max acceleration scaling factor set by setMaxAccelerationScalingFactor().
void setStartState(const moveit_msgs::msg::RobotState &start_state)
If a different start state should be considered instead of the current state of the robot,...
void clearPoseTargets()
Forget any poses specified for all end-effectors.
void setPlannerId(const std::string &planner_id)
Specify a planner to be used for further planning.
bool setEndEffector(const std::string &eef_name)
Specify the name of the end-effector to use. This is equivalent to setting the EndEffectorLink to the...
const std::string & getPoseReferenceFrame() const
Get the reference frame set by setPoseReferenceFrame(). By default this is the reference frame of the...
const std::string & getPlanningPipelineId() const
Get the current planning_pipeline_id.
const std::map< std::string, std::vector< double > > & getRememberedJointValues() const
Get the currently remembered map of names to joint values.
double getGoalOrientationTolerance() const
Get the tolerance that is used for reaching an orientation goal. This is the tolerance for roll,...
std::map< std::string, double > getNamedTargetValues(const std::string &name) const
Get the joint angles for targets specified by name.
unsigned int getVariableCount() const
Get the number of variables used to describe the state of this group. This is larger or equal to the ...
double getGoalPositionTolerance() const
Get the tolerance that is used for reaching a position goal. This is be the radius of a sphere where ...
double getPlanningTime() const
Get the number of seconds set by setPlanningTime().
void setPlanningTime(double seconds)
Specify the maximum amount of time to use when planning.
bool setApproximateJointValueTarget(const geometry_msgs::msg::Pose &eef_pose, const std::string &end_effector_link="")
Set the joint state goal for a particular joint by computing IK.
void setPlannerParams(const std::string &planner_id, const std::string &group, const std::map< std::string, std::string > ¶ms, bool bReplace=false)
Set the planner parameters for given group and planner_id.
void setWorkspace(double minx, double miny, double minz, double maxx, double maxy, double maxz)
Specify the workspace bounding box. The box is specified in the planning frame (i....
const std::vector< std::string > & getJointModelGroupNames() const
Get the available planning group names.
Simple interface to MoveIt components.
Main namespace for MoveIt.
Options(std::string group_name, std::string desc=ROBOT_DESCRIPTION, std::string move_group_namespace="")
The representation of a motion plan (as ROS messages).
Specification of options to use when constructing the MoveGroupInterface class.
std::string move_group_namespace
The namespace for the move group node.
Options(std::string group_name, std::string desc=ROBOT_DESCRIPTION, std::string move_group_namespace="")
std::string robot_description
The robot description parameter name (if different from default).
moveit::core::RobotModelConstPtr robot_model
Optionally, an instance of the RobotModel to use can be also specified.
std::string group_name
The group to construct the class instance for.
The representation of a motion plan (as ROS messages).
moveit_msgs::msg::RobotTrajectory trajectory
The trajectory of the robot (may not contain joints that are the same as for the start_state_).
double planning_time
The amount of time it took to generate the plan.
moveit_msgs::msg::RobotState start_state
The full starting state used for planning.