2 #include <gtest/gtest.h> 7 typedef std::vector<double>
Vec1D;
8 typedef std::vector<Vec1D>
Vec2D;
25 static constexpr
double L1 {0.3500};
26 static constexpr
double L2 {0.3070};
36 auto it = vec.begin();
38 for (++it; it < vec.end(); ++it)
50 std::ostream&
operator<< (std::ostream &os,
const geometry_msgs::Pose &pose)
52 os <<
"position: x=" << double(pose.position.x)
53 <<
", y=" << double(pose.position.y)
54 <<
", z=" << double(pose.position.z)
55 <<
", orientation: x=" << double(pose.orientation.x)
56 <<
", y=" << double(pose.orientation.y)
57 <<
", z=" << double(pose.orientation.z)
58 <<
", w=" << double(pose.orientation.w);
98 std::string plugin_name;
108 FAIL() <<
"Failed to load plugin: " << e.what();
113 <<
"The parameter " <<
GROUP_PARAM <<
" was not found.";
121 std::vector<std::string> tip_links {
tip_link_};
153 std::vector<std::string> link_names { {
solver_->getTipFrame()} };
157 Vec2D joints_test_set;
158 joints_test_set.push_back(
Vec1D { {0.0, 0.0, 0.0, 0.0, 0.0, 0.0} });
159 joints_test_set.push_back(
Vec1D { {0.0, 0.0, 0.0, 1.0, 0.0, 0.0} });
160 joints_test_set.push_back(
Vec1D { {0.0, 0.0, 0.0, 0.0, -1.0, 0.0} });
161 joints_test_set.push_back(
Vec1D { {0.0, 0.0, 0.0, 0.0, 1.0, 1.0} });
165 joints_test_set.push_back(
Vec1D { {0.0, j1, j2, 0.0, 0.0, 0.0} });
166 joints_test_set.push_back(
Vec1D { {0.0, j1, j2, -1.0, 0.0, 0.0} });
167 joints_test_set.push_back(
Vec1D { {0.0, j1, j2, 0.0, 1.0, 0.0} });
168 joints_test_set.push_back(
Vec1D { {0.0, j1, j2, 0.0, 1.0, -1.0} });
171 for (
Vec1D joints : joints_test_set)
179 std::vector<geometry_msgs::Pose> poses;
180 ASSERT_TRUE(
solver_->getPositionFK(link_names, joints, poses) )
181 <<
"Failed to compute forward kinematics.";
195 <<
"Failed to solve inverse kinematics.";
196 double duration_ms = (
ros::Time::now() - generation_begin).toSec() * 1000;
200 ROS_INFO_STREAM(
"Received " << solutions.size() <<
" solutions to IK problem.");
201 EXPECT_GT(solutions.size(), 0u);
207 bool found_expected_solution {
false};
208 for (
Vec1D sol : solutions)
215 diff +=
pow(sol[j] - joints[j], 2);
219 if (found_expected_solution)
225 if (!found_expected_solution)
227 ADD_FAILURE() <<
"No solution is near the expected values.";
229 for (
Vec1D sol : solutions)
237 int main(
int argc,
char** argv)
239 ros::init(argc, argv,
"unittest_prbt_ikfast_manipulator_plugin");
242 testing::InitGoogleTest(&argc, argv);
243 return RUN_ALL_TESTS();
static const std::string MOVEIT_CORE_PACKAGE
static const std::string GROUP_PARAM
std::ostream & operator<<(std::ostream &os, const Vec1D &vec)
Overload ostream operator for double vectors.
static constexpr double IKFAST_TOLERANCE
static constexpr double L1
static const std::string ROOT_LINK_PARAM
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
IMETHOD Vector diff(const Vector &p_w_a, const Vector &p_w_b, double dt=1)
int main(int argc, char **argv)
void TearDown()
Ensures that the solver is destroyed before the ClassLoader.
static const std::string JOINT_NAMES_PARAM
std::vector< Vec1D > Vec2D
static constexpr unsigned int NUM_JOINTS
INLINE Rall1d< T, V, S > asin(const Rall1d< T, V, S > &x)
TEST_F(PrbtIKFastPluginTest, testSingularities)
Tests if the IKFast plugin can solve the IK problem for specific singular poses.
void SetUp()
Loads and initializes the IKFast plugin.
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
#define ROS_DEBUG_STREAM(args)
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
std::vector< std::string > joint_names_
#define ROS_INFO_STREAM(args)
static const std::string ROBOT_DESCRIPTION_PARAM
bool getParam(const std::string &key, std::string &s) const
double singularPoseJointFormula(double joint1)
Computes joint2 from joint1 such that singular position with px,py=0 is reached.
static const std::string TIP_LINK_PARAM
static const std::string PLUGIN_NAME_PARAM
static constexpr double L2
static constexpr double DEFAULT_SEARCH_DISCRETIZATION
pluginlib::ClassLoader< kinematics::KinematicsBase > KinematicsLoader
#define EXPECT_TRUE(args)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
std::vector< double > Vec1D
Initializes the test of the IKFast plugin.
static const std::string KINEMATICS_BASE_CLASS
boost::shared_ptr< kinematics::KinematicsBase > solver_