47 #include <gtest/gtest.h>
53 static const std::string
LOGNAME =
"servo_cpp_interface_test";
66 ros::topic::waitForMessage<sensor_msgs::JointState>(
"/joint_states");
105 trajectory_msgs::JointTrajectory last_received_msg;
106 boost::function<void(
const trajectory_msgs::JointTrajectoryConstPtr&)> traj_callback =
107 [&](
const trajectory_msgs::JointTrajectoryConstPtr& msg) {
108 EXPECT_EQ(msg->header.frame_id,
"panda_link0");
111 double angle_tolerance = 0.08;
112 EXPECT_NEAR(msg->points[0].positions[0], 0, angle_tolerance);
113 EXPECT_NEAR(msg->points[0].positions[1], -0.785, angle_tolerance);
114 EXPECT_NEAR(msg->points[0].positions[2], 0, angle_tolerance);
115 EXPECT_NEAR(msg->points[0].positions[3], -2.360, angle_tolerance);
116 EXPECT_NEAR(msg->points[0].positions[4], 0, angle_tolerance);
117 EXPECT_NEAR(msg->points[0].positions[5], 1.571, angle_tolerance);
118 EXPECT_NEAR(msg->points[0].positions[6], 0.785, angle_tolerance);
120 this->tracker_->stopMotion();
123 auto traj_sub = nh_.subscribe(
"servo_server/command", 1, traj_callback);
125 geometry_msgs::PoseStamped target_pose;
126 target_pose.header.frame_id =
"panda_link4";
128 target_pose.pose.position.x = 0.2;
129 target_pose.pose.position.y = 0.2;
130 target_pose.pose.position.z = 0.2;
131 target_pose.pose.orientation.w = 1;
134 std::thread target_pub_thread([&] {
135 size_t msg_count = 0;
136 while (++msg_count < 100)
138 target_pose_pub_.publish(target_pose);
147 tracker_->resetTargetPose();
151 target_pub_thread.join();
156 int main(
int argc,
char** argv)
159 testing::InitGoogleTest(&argc, argv);
164 int result = RUN_ALL_TESTS();