38 #include <gtest/gtest.h>
40 #include <urdf_parser/urdf_parser.h>
44 #include <boost/math/constants/constants.hpp>
52 geometry_msgs::Pose origin;
53 origin.orientation.w = 1;
54 builder.
addChain(
"base_link->roll",
"revolute", { origin }, urdf::Vector3(1, 0, 0));
55 builder.
addChain(
"roll->pitch",
"revolute", { origin }, urdf::Vector3(0, 1, 0));
56 builder.
addChain(
"pitch->yaw",
"revolute", { origin }, urdf::Vector3(0, 0, 1));
61 std::map<std::string, double>
getJointValues(
const double roll,
const double pitch,
const double yaw)
63 std::map<std::string, double> jvals;
64 jvals[
"base_link-roll-joint"] = roll;
65 jvals[
"roll-pitch-joint"] = pitch;
66 jvals[
"pitch-yaw-joint"] = yaw;
100 robot.
addChain(
"base_link->ee",
"floating");
107 valid_euler_data_ << -0.1712092272140422, -0.2853625129991958, -0.1712092272140422, 0.9273311367620117,
108 -0.28536251299919585, -0.17120922721404216, 0.28536251299919585, 0.8987902273981057, 0.28536251299919585,
109 -0.17120922721404216, -0.28536251299919585, 0.8987902273981057, 0.1712092272140422, -0.2853625129991958,
110 0.1712092272140422, 0.9273311367620117, -0.28536251299919585, 0.17120922721404216, -0.28536251299919585,
111 0.8987902273981057, -0.1712092272140422, 0.2853625129991958, 0.1712092272140422, 0.9273311367620117,
112 0.1712092272140422, 0.2853625129991958, -0.1712092272140422, 0.9273311367620117, 0.28536251299919585,
113 0.17120922721404216, 0.28536251299919585, 0.8987902273981057;
114 valid_rotvec_data_ << -0.23771285949073287, -0.23771285949073287, -0.23771285949073287, 0.911305541132181,
115 -0.2401272988734743, -0.2401272988734743, 0.0, 0.9405731022474852, -0.23771285949073287, -0.23771285949073287,
116 0.23771285949073287, 0.911305541132181, 0.0, -0.24012729887347428, -0.24012729887347428, 0.9405731022474851,
117 0.0, -0.24012729887347428, 0.24012729887347428, 0.9405731022474851, 0.23771285949073287, -0.23771285949073287,
118 -0.23771285949073287, 0.911305541132181, 0.2401272988734743, -0.2401272988734743, 0.0, 0.9405731022474852,
119 0.23771285949073287, -0.23771285949073287, 0.23771285949073287, 0.911305541132181;
130 return Eigen::AngleAxisd(rx, Eigen::Vector3d::UnitX()) * Eigen::AngleAxisd(ry, Eigen::Vector3d::UnitY()) *
131 Eigen::AngleAxisd(rz, Eigen::Vector3d::UnitZ());
138 Eigen::Matrix3d m{ Eigen::AngleAxisd(v.norm(), v.normalized()) };
139 return Eigen::Quaterniond{ m };
145 Eigen::VectorXd joint_values(7);
146 joint_values << 0.0, 0.0, 0.0, quat.x(), quat.y(), quat.z(), quat.w();
147 robot_state.setJointGroupPositions(
"group1", joint_values);
156 moveit_msgs::OrientationConstraint ocm;
158 ocm.link_name =
"yaw";
159 ocm.header.frame_id = robot_model_->getModelFrame();
160 ocm.orientation.x = 0.0;
161 ocm.orientation.y = 0.0;
162 ocm.orientation.z = 0.0;
163 ocm.orientation.w = 1.0;
164 ocm.absolute_x_axis_tolerance = 0.8;
165 ocm.absolute_y_axis_tolerance = 0.8;
166 ocm.absolute_z_axis_tolerance = 3.15;
171 robot_state.setVariablePositions(getJointValues(3.140208, 3.141588, 1.570821));
183 moveit_msgs::OrientationConstraint ocm;
185 ocm.link_name =
"yaw";
186 ocm.header.frame_id = robot_model_->getModelFrame();
187 ocm.orientation.x = 0.0;
188 ocm.orientation.y = 0.0;
189 ocm.orientation.z = 0.0;
190 ocm.orientation.w = 1.0;
191 ocm.absolute_x_axis_tolerance = 0.2;
192 ocm.absolute_y_axis_tolerance = 2.0;
193 ocm.absolute_z_axis_tolerance = 0.2;
199 robot_state.setVariablePositions(getJointValues(0.15, boost::math::constants::half_pi<double>(), 0.15));
204 robot_state.setVariablePositions(getJointValues(0.21, boost::math::constants::half_pi<double>(), 0.0));
209 robot_state.setVariablePositions(getJointValues(0.0, boost::math::constants::half_pi<double>(), 0.21));
216 robot_state.setVariablePositions(getJointValues(0.15, -boost::math::constants::half_pi<double>(), 0.15));
228 moveit_msgs::OrientationConstraint ocm;
230 ocm.link_name =
"yaw";
231 ocm.header.frame_id = robot_model_->getModelFrame();
232 ocm.orientation.x = 0.0;
233 ocm.orientation.y = 0.0;
234 ocm.orientation.z = 0.0;
235 ocm.orientation.w = 1.0;
236 ocm.absolute_x_axis_tolerance = 0.2;
237 ocm.absolute_y_axis_tolerance = 2.0;
238 ocm.absolute_z_axis_tolerance = 0.3;
245 robot_state.setVariablePositions(getJointValues(0.21, boost::math::constants::half_pi<double>(), 0.0));
250 robot_state.setVariablePositions(getJointValues(0.0, boost::math::constants::half_pi<double>(), 0.21));
255 ocm.absolute_x_axis_tolerance = 0.3;
256 ocm.absolute_y_axis_tolerance = 2.0;
257 ocm.absolute_z_axis_tolerance = 0.2;
260 robot_state.setVariablePositions(getJointValues(0.21, boost::math::constants::half_pi<double>(), 0.0));
265 robot_state.setVariablePositions(getJointValues(0.0, boost::math::constants::half_pi<double>(), 0.21));
276 moveit_msgs::OrientationConstraint ocm;
278 ocm.link_name =
"yaw";
279 ocm.header.frame_id = robot_model_->getModelFrame();
280 ocm.orientation.x = 0.0;
281 ocm.orientation.y = 0.0;
282 ocm.orientation.z = 0.0;
283 ocm.orientation.w = 1.0;
284 ocm.absolute_x_axis_tolerance = 0.2;
285 ocm.absolute_y_axis_tolerance = 2.0;
286 ocm.absolute_z_axis_tolerance = 0.3;
293 robot_state.setVariablePositions(getJointValues(0.21, -boost::math::constants::half_pi<double>(), 0.0));
298 robot_state.setVariablePositions(getJointValues(0.0, -boost::math::constants::half_pi<double>(), 0.21));
303 ocm.absolute_x_axis_tolerance = 0.3;
304 ocm.absolute_y_axis_tolerance = 2.0;
305 ocm.absolute_z_axis_tolerance = 0.2;
308 robot_state.setVariablePositions(getJointValues(0.21, -boost::math::constants::half_pi<double>(), 0.0));
313 robot_state.setVariablePositions(getJointValues(0.0, -boost::math::constants::half_pi<double>(), 0.21));
318 robot_state.setVariablePositions(getJointValues(0.5, -boost::math::constants::half_pi<double>(), 0.21));
330 moveit_msgs::OrientationConstraint ocm;
333 robot_state.setVariablePositions(getJointValues(0.0, boost::math::constants::half_pi<double>(), 0.0));
336 ocm.link_name =
"yaw";
337 ocm.header.frame_id = robot_model_->getModelFrame();
338 ocm.orientation =
tf2::toMsg(Eigen::Quaterniond(
robot_state.getGlobalLinkTransform(ocm.link_name).linear()));
339 ocm.absolute_x_axis_tolerance = 0.0;
340 ocm.absolute_y_axis_tolerance = 0.0;
341 ocm.absolute_z_axis_tolerance = 1.0;
344 robot_state.setVariablePositions(getJointValues(0.2, boost::math::constants::half_pi<double>(), 0.3));
357 moveit_msgs::OrientationConstraint ocm;
358 ocm.link_name =
"ee";
359 ocm.header.frame_id = robot_model_->getModelFrame();
360 ocm.orientation.y = 0.0;
361 ocm.orientation.z = 0.0;
362 ocm.orientation.w = 1.0;
363 ocm.absolute_x_axis_tolerance = 0.5;
364 ocm.absolute_y_axis_tolerance = 0.5;
365 ocm.absolute_z_axis_tolerance = 0.5;
369 ocm.parameterization = 99;
393 moveit_msgs::OrientationConstraint ocm;
394 ocm.link_name =
"ee";
395 ocm.header.frame_id = robot_model_->getModelFrame();
396 ocm.orientation = p.orientation;
397 ocm.absolute_x_axis_tolerance = 0.5;
398 ocm.absolute_y_axis_tolerance = 0.5;
399 ocm.absolute_z_axis_tolerance = 0.5;
404 ocm.parameterization = moveit_msgs::OrientationConstraint::XYZ_EULER_ANGLES;
409 ocm.parameterization = moveit_msgs::OrientationConstraint::ROTATION_VECTOR;
430 Eigen::VectorXd joint_values(7);
431 joint_values << 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0;
432 for (Eigen::Index i_row{ 0 }; i_row < valid_euler_data_.rows(); ++i_row)
434 joint_values[3] = valid_euler_data_(i_row, 0);
435 joint_values[4] = valid_euler_data_(i_row, 1);
436 joint_values[5] = valid_euler_data_(i_row, 2);
437 joint_values[6] = valid_euler_data_(i_row, 3);
438 robot_state.setJointGroupPositions(
"group1", joint_values);
443 joint_values[3] = valid_rotvec_data_(i_row, 0);
444 joint_values[4] = valid_rotvec_data_(i_row, 1);
445 joint_values[5] = valid_rotvec_data_(i_row, 2);
446 joint_values[6] = valid_rotvec_data_(i_row, 3);
447 robot_state.setJointGroupPositions(
"group1", joint_values);
458 ocm.parameterization = moveit_msgs::OrientationConstraint::XYZ_EULER_ANGLES;
467 ocm.parameterization = moveit_msgs::OrientationConstraint::ROTATION_VECTOR;
488 moveit_msgs::OrientationConstraint ocm;
489 ocm.link_name =
"ee";
490 ocm.header.frame_id = robot_model_->getModelFrame();
491 ocm.parameterization = moveit_msgs::OrientationConstraint::ROTATION_VECTOR;
493 ocm.absolute_x_axis_tolerance = 0.2;
494 ocm.absolute_y_axis_tolerance = 0.2;
495 ocm.absolute_z_axis_tolerance = 1.0;
513 int main(
int argc,
char** argv)
515 testing::InitGoogleTest(&argc, argv);
516 return RUN_ALL_TESTS();