30 #include <Eigen/Geometry> 45 namespace update_filters
49 name_(
"ConstrainedCartesianGoal")
76 const moveit_msgs::MotionPlanRequest &req,
78 moveit_msgs::MoveItErrorCodes& error_code)
80 using namespace Eigen;
82 using namespace utils::kinematics;
93 const std::vector<moveit_msgs::Constraints>& goals = req.goal_constraints;
96 ROS_ERROR(
"A goal constraint was not provided");
97 error_code.val = error_code.INVALID_GOAL_CONSTRAINTS;
102 bool found_goal =
false;
103 for(
const auto& g: goals)
108 state_->updateLinkTransforms();
109 Eigen::Affine3d start_tool_pose =
state_->getGlobalLinkTransform(
tool_link_);
111 if(cartesian_constraints.is_initialized())
128 ROS_DEBUG(
"%s a cartesian goal pose in MotionPlanRequest was not provided,calculating it from FK",
getName().c_str());
130 for(
const auto& g: goals)
133 if(g.joint_constraints.empty())
140 const std::vector<moveit_msgs::JointConstraint>& joint_constraints = g.joint_constraints;
143 for(
auto& jc: joint_constraints)
145 state_->setVariablePosition(jc.joint_name,jc.position);
163 error_code.val = error_code.INVALID_GOAL_CONSTRAINTS;
167 error_code.val = error_code.SUCCESS;
172 std::size_t num_timesteps,
173 int iteration_number,
174 const Eigen::MatrixXd& parameters,
175 Eigen::MatrixXd& updates,
178 using namespace Eigen;
184 VectorXd goal_joint_pose;
185 VectorXd seed = parameters.rightCols(1) + updates.rightCols(1);
191 updates.rightCols(1) = goal_joint_pose - parameters.rightCols(1);
195 ROS_DEBUG(
"%s failed failed to solve ik using noisy goal pose as seed, zeroing updates",
getName().c_str());
197 updates.rightCols(1) = Eigen::VectorXd::Zero(updates.rows());
bool decodeCartesianConstraint(moveit::core::RobotModelConstPtr model, const moveit_msgs::Constraints &constraints, Eigen::Affine3d &tool_pose, std::vector< double > &tolerance, std::string target_frame="")
virtual bool filter(std::size_t start_timestep, std::size_t num_timesteps, int iteration_number, const Eigen::MatrixXd ¶meters, Eigen::MatrixXd &updates, bool &filtered) override
Forces the goal to be within the tool's task manifold.
virtual ~ConstrainedCartesianGoal()
virtual bool setMotionPlanRequest(const planning_scene::PlanningSceneConstPtr &planning_scene, const moveit_msgs::MotionPlanRequest &req, const stomp_core::StompConfiguration &config, moveit_msgs::MoveItErrorCodes &error_code) override
Stores the planning details.
const std::vector< std::string > & getLinkModelNames() const
moveit::core::RobotModelConstPtr robot_model_
Eigen::VectorXd tool_goal_tolerance_
Eigen::Affine3d tool_goal_pose_
The desired goal pose for the active plan request.
boost::optional< moveit_msgs::Constraints > curateCartesianConstraints(const moveit_msgs::Constraints &c, const Eigen::Affine3d &ref_pose, double default_pos_tol=0.0005, double default_rot_tol=M_PI)
static int CARTESIAN_DOF_SIZE
This defines a underconstrained goal update filter. It forces the goal cartesian tool pose into the t...
static const double DEFAULT_ROT_TOLERANCE
virtual bool configure(const XmlRpc::XmlRpcValue &config) override
Sets internal members of the plugin from the configuration data.
bool robotStateMsgToRobotState(const Transforms &tf, const moveit_msgs::RobotState &robot_state, RobotState &state, bool copy_attached_bodies=true)
virtual std::string getName() const
#define ROS_WARN_STREAM(args)
bool isCartesianConstraints(const moveit_msgs::Constraints &c)
PLUGINLIB_EXPORT_CLASS(stomp_moveit::update_filters::ConstrainedCartesianGoal, stomp_moveit::update_filters::StompUpdateFilter)
Forces the goal cartesian tool pose into the task space.
stomp_moveit::utils::kinematics::IKSolverPtr ik_solver_
virtual bool initialize(moveit::core::RobotModelConstPtr robot_model_ptr, const std::string &group_name, const XmlRpc::XmlRpcValue &config) override
Initializes and configures.
static const double DEFAULT_POS_TOLERANCE
const std::vector< const JointModel * > & getActiveJointModels() const
ConstrainedCartesianGoal()
moveit::core::RobotStatePtr state_