378 bool computeRelativeTransform(
const std::string& from,
const std::string& to, Eigen::Isometry3d& transform,
379 bool& differs_from_identity);
386 void transformToChainFrame(
const geometry_msgs::msg::Pose& ik_pose, KDL::Frame& ik_pose_chain)
const;
389bool IKFastKinematicsPlugin::computeRelativeTransform(
const std::string& from,
const std::string& to,
390 Eigen::Isometry3d& transform,
bool& differs_from_identity)
392 RobotStatePtr robot_state = std::make_shared<RobotState>(
robot_model_);
393 robot_state->setToDefaultValues();
397 if (!from_link || !to_link)
400 if (
robot_model_->getRigidlyConnectedParentLinkModel(from_link) !=
401 robot_model_->getRigidlyConnectedParentLinkModel(to_link))
403 RCLCPP_ERROR_STREAM(LOGGER,
"Link frames " << from <<
" and " << to <<
" are not rigidly connected.");
407 transform = robot_state->getGlobalLinkTransform(from_link).inverse() * robot_state->getGlobalLinkTransform(to_link);
408 differs_from_identity = !transform.matrix().isIdentity();
412bool IKFastKinematicsPlugin::initialize(
const rclcpp::Node::SharedPtr& node,
const moveit::core::RobotModel& robot_model,
const std::string& group_name,
413 const std::string& base_frame,
const std::vector<std::string>& tip_frames,
414 double search_discretization)
416 if (tip_frames.size() != 1)
418 RCLCPP_ERROR(LOGGER,
"Expecting exactly one tip frame.");
422 std::string kinematics_param_prefix =
"robot_description_kinematics." + group_name;
423 param_listener_ = std::make_shared<prbt_ikfast_kinematics::ParamListener>(node, kinematics_param_prefix);
424 params_ = param_listener_->get_params();
426 storeValues(robot_model, group_name, base_frame, tip_frames, search_discretization);
428 RCLCPP_INFO_STREAM(LOGGER,
"Using link_prefix: '" << params_.link_prefix <<
'\'');
432 RCLCPP_ERROR_STREAM(LOGGER,
"tip frame '" <<
tip_frames_[0] <<
"' does not exist.");
434 RCLCPP_ERROR_STREAM(LOGGER,
"base_frame '" <<
base_frame_ <<
"' does not exist.");
436 if (!robot_model.
hasLinkModel(params_.link_prefix + IKFAST_TIP_FRAME_)) {
437 RCLCPP_ERROR_STREAM(LOGGER,
"prefixed tip frame '" << params_.link_prefix + IKFAST_TIP_FRAME_
438 <<
"' does not exist. "
439 "Please check your link_prefix parameter.");
441 if (!robot_model.
hasLinkModel(params_.link_prefix + IKFAST_BASE_FRAME_)) {
442 RCLCPP_ERROR_STREAM(LOGGER,
"prefixed base frame '" << params_.link_prefix + IKFAST_BASE_FRAME_
443 <<
"' does not exist. "
444 "Please check your link_prefix parameter.");
451 if (!computeRelativeTransform(
tip_frames_[0], params_.link_prefix + IKFAST_TIP_FRAME_, group_tip_to_chain_tip_,
452 tip_transform_required_) ||
453 !computeRelativeTransform(params_.link_prefix + IKFAST_BASE_FRAME_,
base_frame_, chain_base_to_group_base_,
454 base_transform_required_))
462 if (free_params_.size() > 1)
464 RCLCPP_ERROR(LOGGER,
"Only one free joint parameter supported!");
467 else if (free_params_.size() == 1)
471 KinematicsBase::setSearchDiscretization(search_discretization);
474 const moveit::core::JointModelGroup* jmg =
robot_model_->getJointModelGroup(group_name);
477 RCLCPP_ERROR_STREAM(LOGGER,
"Unknown planning group: " << group_name);
481 RCLCPP_DEBUG_STREAM(LOGGER,
"Registering joints and links");
484 while (link && link != base_link)
486 RCLCPP_DEBUG_STREAM(LOGGER,
"Link " << link->
getName());
487 link_names_.push_back(link->
getName());
491 RCLCPP_DEBUG_STREAM(LOGGER,
"Adding joint " << joint->
getName());
493 joint_names_.push_back(joint->
getName());
502 if (joint_names_.size() != num_joints_)
504 RCLCPP_FATAL(LOGGER,
"Joint numbers of RobotModel (%zd) and IKFast solver (%zd) do not match", joint_names_.size(),
509 std::reverse(link_names_.begin(), link_names_.end());
510 std::reverse(joint_names_.begin(), joint_names_.end());
511 std::reverse(joint_min_vector_.begin(), joint_min_vector_.end());
512 std::reverse(joint_max_vector_.begin(), joint_max_vector_.end());
513 std::reverse(joint_has_limits_vector_.begin(), joint_has_limits_vector_.end());
515 for (
size_t joint_id = 0; joint_id < num_joints_; ++joint_id) {
516 RCLCPP_DEBUG_STREAM(LOGGER, joint_names_[joint_id] <<
' ' << joint_min_vector_[joint_id] <<
' '
517 << joint_max_vector_[joint_id] <<
' '
518 << joint_has_limits_vector_[joint_id]);
527 if (discretization.empty())
529 RCLCPP_ERROR(LOGGER,
"The 'discretization' map is empty");
535 RCLCPP_ERROR_STREAM(LOGGER,
"This group's solver doesn't support redundant joints");
541 std::string redundant_joint = joint_names_[free_params_[0]];
542 RCLCPP_ERROR_STREAM(LOGGER,
"Attempted to discretize a non-redundant joint "
543 << discretization.begin()->first <<
", only joint '" << redundant_joint
548 if (discretization.begin()->second <= 0.0)
550 RCLCPP_ERROR_STREAM(LOGGER,
"Discretization can not takes values that are <= 0");
560 RCLCPP_ERROR_STREAM(LOGGER,
"Changing the redundant joints isn't permitted by this group's solver ");
564size_t IKFastKinematicsPlugin::solve(KDL::Frame& pose_frame,
const std::vector<double>& vfree,
571 trans[0] = pose_frame.p[0];
572 trans[1] = pose_frame.p[1];
573 trans[2] = pose_frame.p[2];
576 KDL::Vector direction;
587 vals[0] = mult(0, 0);
588 vals[1] = mult(0, 1);
589 vals[2] = mult(0, 2);
590 vals[3] = mult(1, 0);
591 vals[4] = mult(1, 1);
592 vals[5] = mult(1, 2);
593 vals[6] = mult(2, 0);
594 vals[7] = mult(2, 1);
595 vals[8] = mult(2, 2);
598 ComputeIk(trans, vals, vfree.size() > 0 ? &vfree[0] :
nullptr, solutions);
607 direction = pose_frame.M * KDL::Vector(0, 0, 1);
608 ComputeIk(trans, direction.data, vfree.size() > 0 ? &vfree[0] :
nullptr, solutions);
617 RCLCPP_ERROR(LOGGER,
"IK for this IkParameterizationType not implemented yet.");
623 RCLCPP_ERROR(LOGGER,
"IK for this IkParameterizationType not implemented yet.");
630 RCLCPP_ERROR(LOGGER,
"IK for this IkParameterizationType not implemented yet.");
634 double roll, pitch, yaw;
638 pose_frame.M.GetRPY(roll, pitch, yaw);
639 ComputeIk(trans, &yaw, vfree.size() > 0 ? &vfree[0] :
nullptr, solutions);
646 pose_frame.M.GetRPY(roll, pitch, yaw);
647 ComputeIk(trans, &roll, vfree.size() > 0 ? &vfree[0] :
nullptr, solutions);
654 pose_frame.M.GetRPY(roll, pitch, yaw);
655 ComputeIk(trans, &pitch, vfree.size() > 0 ? &vfree[0] :
nullptr, solutions);
659 RCLCPP_ERROR(LOGGER,
"Unknown IkParameterizationType! "
660 "Was the solver generated with an incompatible version of Openrave?");
666 std::vector<double>& solution)
const
669 solution.resize(num_joints_);
672 const IkSolutionBase<IkReal>& sol = solutions.
GetSolution(i);
673 std::vector<IkReal> vsolfree(sol.
GetFree().size());
674 sol.
GetSolution(&solution[0], vsolfree.size() > 0 ? &vsolfree[0] :
nullptr);
676 for (std::size_t joint_id = 0; joint_id < num_joints_; ++joint_id)
678 if (joint_has_limits_vector_[joint_id])
680 solution[joint_id] = enforceLimits(solution[joint_id], joint_min_vector_[joint_id], joint_max_vector_[joint_id]);
686 const std::vector<double>& ik_seed_state,
int i,
687 std::vector<double>& solution)
const
690 solution.resize(num_joints_);
693 const IkSolutionBase<IkReal>& sol = solutions.
GetSolution(i);
694 std::vector<IkReal> vsolfree(sol.
GetFree().size());
695 sol.
GetSolution(&solution[0], vsolfree.size() > 0 ? &vsolfree[0] :
nullptr);
698 for (std::size_t i = 0; i < num_joints_; ++i)
700 if (joint_has_limits_vector_[i])
702 solution[i] = enforceLimits(solution[i], joint_min_vector_[i], joint_max_vector_[i]);
703 double signed_distance = solution[i] - ik_seed_state[i];
704 while (signed_distance > M_PI && solution[i] - 2 * M_PI > (joint_min_vector_[i] -
LIMIT_TOLERANCE))
706 signed_distance -= 2 * M_PI;
707 solution[i] -= 2 * M_PI;
709 while (signed_distance < -M_PI && solution[i] + 2 * M_PI < (joint_max_vector_[i] +
LIMIT_TOLERANCE))
711 signed_distance += 2 * M_PI;
712 solution[i] += 2 * M_PI;
718double IKFastKinematicsPlugin::enforceLimits(
double joint_value,
double min,
double max)
const
721 while (joint_value > max)
723 joint_value -= 2 * M_PI;
727 while (joint_value < min)
729 joint_value += 2 * M_PI;
734void IKFastKinematicsPlugin::fillFreeParams(
int count,
int* array)
736 free_params_.clear();
737 for (
int i = 0; i < count; ++i)
738 free_params_.push_back(array[i]);
741bool IKFastKinematicsPlugin::getCount(
int& count,
int max_count,
int min_count)
const
745 if (-count >= min_count)
750 else if (count + 1 <= max_count)
762 if (1 - count <= max_count)
767 else if (count - 1 >= min_count)
778 const std::vector<double>& joint_angles,
779 std::vector<geometry_msgs::msg::Pose>& poses)
const
787 RCLCPP_ERROR(LOGGER,
"Can only compute FK for Transform6D IK type!");
792 if (link_names.size() == 0)
794 RCLCPP_WARN_STREAM(LOGGER,
"Link names with nothing");
798 if (link_names.size() != 1 || link_names[0] !=
getTipFrame())
800 RCLCPP_ERROR(LOGGER,
"Can compute FK for %s only",
getTipFrame().c_str());
806 IkReal eerot[9], eetrans[3];
808 if (joint_angles.size() != num_joints_)
810 RCLCPP_ERROR(LOGGER,
"Unexpected number of joint angles");
814 std::vector<IkReal> angles(num_joints_, 0);
815 for (
unsigned char i = 0; i < num_joints_; i++)
816 angles[i] = joint_angles[i];
819 ComputeFk(angles.data(), eetrans, eerot);
821 for (
int i = 0; i < 3; ++i)
822 p_out.p.data[i] = eetrans[i];
824 for (
int i = 0; i < 9; ++i)
825 p_out.M.data[i] = eerot[i];
828 poses[0] = tf2::toMsg(p_out);
834 const std::vector<double>& ik_seed_state,
double timeout,
835 std::vector<double>& solution, moveit_msgs::msg::MoveItErrorCodes& error_code,
838 std::vector<double> consistency_limits;
844 const std::vector<double>& ik_seed_state,
double timeout,
845 const std::vector<double>& consistency_limits,
846 std::vector<double>& solution, moveit_msgs::msg::MoveItErrorCodes& error_code,
854 const std::vector<double>& ik_seed_state,
double timeout,
855 std::vector<double>& solution,
const IKCallbackFn& solution_callback,
856 moveit_msgs::msg::MoveItErrorCodes& error_code,
859 std::vector<double> consistency_limits;
860 return searchPositionIK(ik_pose, ik_seed_state, timeout, consistency_limits, solution, solution_callback, error_code,
865 const std::vector<double>& ik_seed_state,
double ,
866 const std::vector<double>& consistency_limits,
867 std::vector<double>& solution,
const IKCallbackFn& solution_callback,
868 moveit_msgs::msg::MoveItErrorCodes& error_code,
875 if (free_params_.size() == 0)
877 RCLCPP_DEBUG_STREAM(LOGGER,
"No need to search since no free params/redundant joints");
879 std::vector<geometry_msgs::msg::Pose> ik_poses(1, ik_pose);
880 std::vector<std::vector<double>> solutions;
883 if (!
getPositionIK(ik_poses, ik_seed_state, solutions, kinematic_result, options))
885 RCLCPP_DEBUG_STREAM(LOGGER,
"No solution whatsoever");
886 error_code.val = moveit_msgs::msg::MoveItErrorCodes::NO_IK_SOLUTION;
891 std::vector<LimitObeyingSol> solutions_obey_limits;
892 for (std::size_t i = 0; i < solutions.size(); ++i)
894 double dist_from_seed = 0.0;
895 for (std::size_t j = 0; j < ik_seed_state.size(); ++j)
897 dist_from_seed += fabs(ik_seed_state[j] - solutions[i][j]);
900 solutions_obey_limits.push_back({ solutions[i], dist_from_seed });
902 std::sort(solutions_obey_limits.begin(), solutions_obey_limits.end());
905 if (solution_callback)
907 for (std::size_t i = 0; i < solutions_obey_limits.size(); ++i)
909 solution_callback(ik_pose, solutions_obey_limits[i].value, error_code);
910 if (error_code.val == moveit_msgs::msg::MoveItErrorCodes::SUCCESS)
912 solution = solutions_obey_limits[i].value;
913 RCLCPP_DEBUG_STREAM(LOGGER,
"Solution passes callback");
918 RCLCPP_DEBUG_STREAM(LOGGER,
"Solution has error code " << error_code.val);
923 solution = solutions_obey_limits[0].value;
924 error_code.val = moveit_msgs::msg::MoveItErrorCodes::SUCCESS;
933 RCLCPP_ERROR_STREAM(LOGGER,
"Kinematics not active");
934 error_code.val = error_code.NO_IK_SOLUTION;
938 if (ik_seed_state.size() != num_joints_)
940 RCLCPP_ERROR_STREAM(LOGGER,
941 "Seed state must have size " << num_joints_ <<
" instead of size " << ik_seed_state.size());
942 error_code.val = error_code.NO_IK_SOLUTION;
946 if (!consistency_limits.empty() && consistency_limits.size() != num_joints_)
948 RCLCPP_ERROR_STREAM(LOGGER,
"Consistency limits be empty or must have size " << num_joints_ <<
" instead of size "
949 << consistency_limits.size());
950 error_code.val = error_code.NO_IK_SOLUTION;
958 transformToChainFrame(ik_pose, frame);
960 std::vector<double> vfree(free_params_.size());
964 double initial_guess = ik_seed_state[free_params_[0]];
965 vfree[0] = initial_guess;
969 int num_positive_increments;
970 int num_negative_increments;
973 if (!consistency_limits.empty())
977 double max_limit = fmin(joint_max_vector_[free_params_[0]], initial_guess + consistency_limits[free_params_[0]]);
978 double min_limit = fmax(joint_min_vector_[free_params_[0]], initial_guess - consistency_limits[free_params_[0]]);
980 num_positive_increments =
static_cast<int>((max_limit - initial_guess) / search_discretization);
981 num_negative_increments =
static_cast<int>((initial_guess - min_limit) / search_discretization);
985 num_positive_increments = (joint_max_vector_[free_params_[0]] - initial_guess) / search_discretization;
986 num_negative_increments = (initial_guess - joint_min_vector_[free_params_[0]]) / search_discretization;
992 RCLCPP_DEBUG_STREAM(LOGGER,
"Free param is " << free_params_[0] <<
" initial guess is " << initial_guess
993 <<
", # positive increments: " << num_positive_increments
994 <<
", # negative increments: " << num_negative_increments);
995 if ((search_mode &
OPTIMIZE_MAX_JOINT) && (num_positive_increments + num_negative_increments) > 1000)
996 RCLCPP_WARN_STREAM_ONCE(LOGGER,
"Large search space, consider increasing the search discretization");
998 double best_costs = -1.0;
999 std::vector<double> best_solution;
1000 int nattempts = 0, nvalid = 0;
1005 size_t numsol = solve(frame, vfree, solutions);
1007 RCLCPP_DEBUG_STREAM(LOGGER,
"Found " << numsol <<
" solutions from IKFast");
1011 for (
size_t s = 0; s < numsol; ++s)
1014 std::vector<double> sol;
1015 getSolution(solutions, ik_seed_state, s, sol);
1017 bool obeys_limits =
true;
1018 for (
size_t i = 0; i < sol.size(); i++)
1020 if (joint_has_limits_vector_[i] && (sol[i] < joint_min_vector_[i] || sol[i] > joint_max_vector_[i]))
1022 obeys_limits =
false;
1030 getSolution(solutions, ik_seed_state, s, solution);
1033 if (solution_callback)
1035 solution_callback(ik_pose, solution, error_code);
1039 error_code.val = error_code.SUCCESS;
1042 if (error_code.val == error_code.SUCCESS)
1049 for (
unsigned int i = 0; i < solution.size(); i++)
1051 double d = fabs(ik_seed_state[i] - solution[i]);
1055 if (costs < best_costs || best_costs == -1.0)
1058 best_solution = solution;
1070 if (!getCount(counter, num_positive_increments, -num_negative_increments))
1073 error_code.val = moveit_msgs::msg::MoveItErrorCodes::NO_IK_SOLUTION;
1077 vfree[0] = initial_guess + search_discretization * counter;
1081 RCLCPP_DEBUG_STREAM(LOGGER,
"Valid solutions: " << nvalid <<
'/' << nattempts);
1085 solution = best_solution;
1086 error_code.val = error_code.SUCCESS;
1091 error_code.val = moveit_msgs::msg::MoveItErrorCodes::NO_IK_SOLUTION;
1097 std::vector<double>& solution, moveit_msgs::msg::MoveItErrorCodes& error_code,
1100 RCLCPP_DEBUG_STREAM(LOGGER,
"getPositionIK");
1104 RCLCPP_ERROR(LOGGER,
"kinematics not active");
1108 if (ik_seed_state.size() < num_joints_)
1110 RCLCPP_ERROR_STREAM(LOGGER,
"ik_seed_state only has " << ik_seed_state.size()
1111 <<
" entries, this ikfast solver requires " << num_joints_);
1116 for (std::size_t i = 0; i < ik_seed_state.size(); i++)
1119 if (joint_has_limits_vector_[i] && ((ik_seed_state[i] < (joint_min_vector_[i] -
LIMIT_TOLERANCE)) ||
1122 RCLCPP_DEBUG_STREAM(LOGGER,
"IK seed not in limits! " <<
static_cast<int>(i) <<
" value " << ik_seed_state[i]
1123 <<
" has limit: " << joint_has_limits_vector_[i] <<
" being "
1124 << joint_min_vector_[i] <<
" to " << joint_max_vector_[i]);
1129 std::vector<double> vfree(free_params_.size());
1130 for (std::size_t i = 0; i < free_params_.size(); ++i)
1132 int p = free_params_[i];
1133 RCLCPP_ERROR(LOGGER,
"%u is %f", p, ik_seed_state[p]);
1134 vfree[i] = ik_seed_state[p];
1138 transformToChainFrame(ik_pose, frame);
1141 size_t numsol = solve(frame, vfree, solutions);
1142 RCLCPP_DEBUG_STREAM(LOGGER,
"Found " << numsol <<
" solutions from IKFast");
1144 std::vector<LimitObeyingSol> solutions_obey_limits;
1148 std::vector<double> solution_obey_limits;
1149 for (std::size_t s = 0; s < numsol; ++s)
1151 std::vector<double> sol;
1152 getSolution(solutions, ik_seed_state, s, sol);
1153 RCLCPP_DEBUG(LOGGER,
"Sol %d: %e %e %e %e %e %e",
static_cast<int>(s), sol[0], sol[1], sol[2], sol[3],
1156 bool obeys_limits =
true;
1157 for (std::size_t i = 0; i < sol.size(); i++)
1160 if (joint_has_limits_vector_[i] && ((sol[i] < (joint_min_vector_[i] -
LIMIT_TOLERANCE)) ||
1164 obeys_limits =
false;
1165 RCLCPP_DEBUG_STREAM(LOGGER,
"Not in limits! " <<
static_cast<int>(i) <<
" value " << sol[i]
1166 <<
" has limit: " << joint_has_limits_vector_[i] <<
" being "
1167 << joint_min_vector_[i] <<
" to " << joint_max_vector_[i]);
1174 getSolution(solutions, ik_seed_state, s, solution_obey_limits);
1175 double dist_from_seed = 0.0;
1176 for (std::size_t i = 0; i < ik_seed_state.size(); ++i)
1178 dist_from_seed += fabs(ik_seed_state[i] - solution_obey_limits[i]);
1181 solutions_obey_limits.push_back({ solution_obey_limits, dist_from_seed });
1187 RCLCPP_DEBUG_STREAM(LOGGER,
"No IK solution");
1191 if (!solutions_obey_limits.empty())
1193 std::sort(solutions_obey_limits.begin(), solutions_obey_limits.end());
1194 solution = solutions_obey_limits[0].value;
1195 error_code.val = moveit_msgs::msg::MoveItErrorCodes::SUCCESS;
1199 error_code.val = moveit_msgs::msg::MoveItErrorCodes::NO_IK_SOLUTION;
1204 const std::vector<double>& ik_seed_state,
1205 std::vector<std::vector<double>>& solutions,
1209 RCLCPP_DEBUG_STREAM(LOGGER,
"getPositionIK with multiple solutions");
1213 RCLCPP_ERROR(LOGGER,
"kinematics not active");
1218 if (ik_poses.empty())
1220 RCLCPP_ERROR(LOGGER,
"ik_poses is empty");
1225 if (ik_poses.size() > 1)
1227 RCLCPP_ERROR(LOGGER,
"ik_poses contains multiple entries, only one is allowed");
1232 if (ik_seed_state.size() < num_joints_)
1234 RCLCPP_ERROR_STREAM(LOGGER,
"ik_seed_state only has " << ik_seed_state.size()
1235 <<
" entries, this ikfast solver requires " << num_joints_);
1240 transformToChainFrame(ik_poses[0], frame);
1243 std::vector<IkSolutionList<IkReal>> solution_set;
1245 std::vector<double> vfree;
1247 std::vector<double> sampled_joint_vals;
1260 double jv = sampled_joint_vals[0];
1264 RCLCPP_ERROR_STREAM(LOGGER,
"ik seed is out of bounds");
1270 if (!sampleRedundantJoint(options.discretization_method, sampled_joint_vals))
1276 for (
unsigned int i = 0; i < sampled_joint_vals.size(); i++)
1279 vfree.push_back(sampled_joint_vals[i]);
1280 numsol += solve(frame, vfree, ik_solutions);
1281 solution_set.push_back(ik_solutions);
1287 numsol = solve(frame, vfree, ik_solutions);
1288 solution_set.push_back(ik_solutions);
1291 RCLCPP_DEBUG_STREAM(LOGGER,
"Found " << numsol <<
" solutions from IKFast");
1292 bool solutions_found =
false;
1298 for (
unsigned int r = 0; r < solution_set.size(); r++)
1300 ik_solutions = solution_set[r];
1302 for (
int s = 0; s < numsol; ++s)
1304 std::vector<double> sol;
1305 getSolution(ik_solutions, ik_seed_state, s, sol);
1307 bool obeys_limits =
true;
1308 for (
unsigned int i = 0; i < sol.size(); i++)
1311 if (joint_has_limits_vector_[i] && ((sol[i] < (joint_min_vector_[i] -
LIMIT_TOLERANCE)) ||
1315 obeys_limits =
false;
1316 RCLCPP_DEBUG_STREAM(LOGGER,
"Not in limits! " << i <<
" value " << sol[i]
1317 <<
" has limit: " << joint_has_limits_vector_[i] <<
" being "
1318 << joint_min_vector_[i] <<
" to " << joint_max_vector_[i]);
1325 solutions_found =
true;
1326 solutions.push_back(sol);
1331 if (solutions_found)
1339 RCLCPP_DEBUG_STREAM(LOGGER,
"No IK solution");
1347 std::vector<double>& sampled_joint_vals)
const
1351 double joint_min = joint_min_vector_[index];
1352 double joint_max = joint_max_vector_[index];
1358 size_t steps = std::ceil((joint_max - joint_min) / joint_dscrt);
1359 for (
size_t i = 0; i < steps; i++)
1361 sampled_joint_vals.push_back(joint_min + joint_dscrt * i);
1363 sampled_joint_vals.push_back(joint_max);
1368 int steps = std::ceil((joint_max - joint_min) / joint_dscrt);
1369 steps = steps > 0 ? steps : 1;
1370 double diff = joint_max - joint_min;
1371 for (
int i = 0; i < steps; i++)
1373 sampled_joint_vals.push_back(((diff * std::rand()) / (
static_cast<double>(RAND_MAX))) + joint_min);
1382 RCLCPP_ERROR_STREAM(LOGGER,
"Discretization method " << method <<
" is not supported");
1389void IKFastKinematicsPlugin::transformToChainFrame(
const geometry_msgs::msg::Pose& ik_pose, KDL::Frame& ik_pose_chain)
const
1391 if (tip_transform_required_ || base_transform_required_)
1393 Eigen::Isometry3d ik_eigen_pose;
1394 tf2::fromMsg(ik_pose, ik_eigen_pose);
1395 if (tip_transform_required_)
1396 ik_eigen_pose = ik_eigen_pose * group_tip_to_chain_tip_;
1398 if (base_transform_required_)
1399 ik_eigen_pose = chain_base_to_group_base_ * ik_eigen_pose;
1401 tf2::transformEigenToKDL(ik_eigen_pose, ik_pose_chain);
1405 tf2::fromMsg(ik_pose, ik_pose_chain);
1412#include <pluginlib/class_list_macros.hpp>