moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
multi_state_validation_service_capability.cpp
Go to the documentation of this file.
7
8namespace move_group
9{
10
12{
13 validity_service_ = context_->moveit_cpp_->getNode()->create_service<moveit_msgs::srv::GetMultiStateValidity>(
14 MULTI_STATE_VALIDITY_SERVICE_NAME,
15 [this](const std::shared_ptr<rmw_request_id_t>& request_header,
16 const std::shared_ptr<moveit_msgs::srv::GetMultiStateValidity::Request>& req,
17 const std::shared_ptr<moveit_msgs::srv::GetMultiStateValidity::Response>& res) {
18 return computeService(request_header, req, res);
19 });
20}
21
22bool MoveGroupMultiStateValidationService::computeService(
23 const std::shared_ptr<rmw_request_id_t>& /* unused */,
24 const std::shared_ptr<moveit_msgs::srv::GetMultiStateValidity::Request>& req,
25 const std::shared_ptr<moveit_msgs::srv::GetMultiStateValidity::Response>& res)
26{
28 moveit::core::RobotState rs = ls->getCurrentState();
29 moveit::core::robotStateMsgToRobotState(req->robot_state, rs);
30 for (size_t i = 0; i < req->joint_states.size(); ++i)
31 {
32 // Update robot state with next set of joint states
33 rs.setVariableValues(req->joint_states[i]);
34
35 // Check validity of given joint state
36 res->valid = isStateValid(ls, rs, req->group_name, req->constraints, res->contacts, res->cost_sources,
37 res->constraint_result);
38
39 // This service only checks up to the first invalid joint state,
40 // with the result then holding the information about the first invalid
41 // state
42 if (!res->valid)
43 {
44 break;
45 }
46 }
47 return true;
48}
49} // namespace move_group
50
51#include <pluginlib/class_list_macros.hpp>
52
PLUGINLIB_EXPORT_CLASS(cached_ik_kinematics_plugin::CachedIKKinematicsPlugin< kdl_kinematics_plugin::KDLKinematicsPlugin >, kinematics::KinematicsBase)
bool isStateValid(const planning_scene_monitor::LockedPlanningSceneRO &ls, const moveit::core::RobotState &rs, const std::string &group_name, const moveit_msgs::msg::Constraints &constraints, std::vector< moveit_msgs::msg::ContactInformation > &contacts, std::vector< moveit_msgs::msg::CostSource > &cost_sources, std::vector< moveit_msgs::msg::ConstraintEvalResult > &constraint_result)
Representation of a robot's state. This includes position, velocity, acceleration and effort.
void setVariableValues(const sensor_msgs::msg::JointState &msg)
This is a convenience class for obtaining access to an instance of a locked PlanningScene.
bool robotStateMsgToRobotState(const Transforms &tf, const moveit_msgs::msg::RobotState &robot_state, RobotState &state, bool copy_attached_bodies=true)
Convert a robot state msg (with accompanying extra transforms) to a MoveIt robot state.