35 namespace noisy_filters
38 JointLimits::JointLimits():
41 has_goal_constraints_(false)
46 JointLimits::~JointLimits()
51 bool JointLimits::initialize(moveit::core::RobotModelConstPtr robot_model_ptr,
56 robot_model_ = robot_model_ptr;
57 group_name_ = group_name;
60 start_state_.reset(
new RobotState(robot_model_));
61 goal_state_.reset(
new RobotState(robot_model_));
70 auto members = {
"lock_start",
"lock_goal"};
71 for(
auto& m : members)
75 ROS_ERROR(
"%s failed to find one or more required parameters",
getName().c_str());
83 lock_start_ =
static_cast<bool>(c[
"lock_start"]);
84 lock_goal_ =
static_cast<bool>(c[
"lock_goal"]);
95 bool JointLimits::setMotionPlanRequest(
const planning_scene::PlanningSceneConstPtr&
planning_scene,
96 const moveit_msgs::MotionPlanRequest &req,
98 moveit_msgs::MoveItErrorCodes& error_code)
102 error_code.val = error_code.val | moveit_msgs::MoveItErrorCodes::SUCCESS;
111 if(!start_state_->satisfiesBounds(robot_model_->getJointModelGroup(group_name_)))
113 ROS_WARN(
"%s Requested Start State is out of bounds",
getName().c_str());
119 bool goal_state_saved =
false;
120 has_goal_constraints_ =
false;
121 for(
auto& gc: req.goal_constraints)
123 has_goal_constraints_ = !gc.joint_constraints.empty();
124 for(
auto& jc : gc.joint_constraints)
126 goal_state_->setVariablePosition(jc.joint_name,jc.position);
129 if(!goal_state_->satisfiesBounds(robot_model_->getJointModelGroup(group_name_)))
131 ROS_WARN(
"%s Requested Goal State is out of bounds",
getName().c_str());
135 if(has_goal_constraints_)
137 goal_state_saved =
true;
142 if(has_goal_constraints_ && !goal_state_saved)
152 bool JointLimits::filter(std::size_t start_timestep,std::size_t num_timesteps,
153 int iteration_number,
int rollout_number,Eigen::MatrixXd& parameters,
bool& filtered)
158 const JointModelGroup* joint_group = robot_model_->getJointModelGroup(group_name_);
161 if(parameters.rows() != num_joints)
163 ROS_ERROR(
"Incorrect number of joints in the 'parameters' matrix");
169 for(
auto j = 0u; j < num_joints; j++)
171 parameters(j,0) = *start_state_->getJointPositions(joint_models[j]);
177 if(has_goal_constraints_ && lock_goal_)
179 auto last_index = parameters.cols()-1;
180 for(
auto j = 0u; j < num_joints; j++)
182 parameters(j,last_index) = *goal_state_->getJointPositions(joint_models[j]);
189 for (
auto j = 0u; j < num_joints; ++j)
191 for (
auto t=0u; t< parameters.cols(); ++t)
193 val = parameters(j,t);
194 if(joint_models[j]->enforcePositionBounds(&val))
196 parameters(j,t) = val;
const std::string & getMessage() const
Interface class for filtering noisy trajectories.
std::string getName(void *handle)
PLUGINLIB_EXPORT_CLASS(test_moveit_controller_manager::TestMoveItControllerManager, moveit_controller_manager::MoveItControllerManager)
const std::vector< std::string > & getActiveJointModelNames() const
bool robotStateMsgToRobotState(const Transforms &tf, const moveit_msgs::RobotState &robot_state, RobotState &state, bool copy_attached_bodies=true)
virtual bool configure(const XmlRpc::XmlRpcValue &config) override
see base class for documentation
This defines a joint limit filter.
bool hasMember(const std::string &name) const
Checks that the joint values are within the limits as defined in the urdf file. It modifies the value...
const std::vector< const JointModel * > & getActiveJointModels() const
#define ROS_ERROR_STREAM(args)