5 #include <ram_msgs/AdditiveManufacturingPose.h> 6 #include <ram_msgs/AdditiveManufacturingTrajectory.h> 7 #include <ram_display/DisplayTrajectory.h> 8 #include <ram_display/DeleteTrajectory.h> 10 #include <gtest/gtest.h> 12 std::unique_ptr<ros::NodeHandle>
nh;
18 TEST(TestSuite, testDisplayServiceExistence)
20 display_traj_client =
nh->serviceClient<ram_display::DisplayTrajectory>(
21 "ram/display/add_trajectory");
27 TEST(TestSuite, testSendFirstTrajectoryFirstParameters)
29 ros::Publisher pub =
nh->advertise<ram_msgs::AdditiveManufacturingTrajectory>(
"ram/trajectory", 1,
true);
30 ram_msgs::AdditiveManufacturingTrajectory msg;
31 Eigen::Isometry3d pose_isometry = Eigen::Isometry3d::Identity();
32 for (
unsigned j(1); j <= 2; j++)
34 for (
unsigned i(0); i < 14; ++i)
36 pose_isometry.translation()[0] =
cos(i * M_PI / 8);
37 pose_isometry.translation()[1] =
sin(i * M_PI / 8);
38 pose_isometry.translation()[2] = j;
40 geometry_msgs::Pose pose_srv;
43 ram_msgs::AdditiveManufacturingPose ram_pose;
44 ram_pose.pose = pose_srv;
45 ram_pose.layer_level = j;
46 ram_pose.params.speed = i;
47 msg.poses.push_back(ram_pose);
57 ram_display::DisplayTrajectory srv;
58 srv.request.cylinder_size = 0.01;
59 srv.request.wire_size = 5;
60 srv.request.axis_size = 0.2;
61 srv.request.display_mode = 2;
62 srv.request.color_mode = 1;
63 srv.request.display_labels =
false;
64 bool success(display_traj_client.
call(srv));
66 EXPECT_TRUE(srv.response.error.empty());
68 if (!srv.response.error.empty())
73 ROS_WARN_STREAM(
"Press enter in the terminal to skip to the next test");
74 while (std::cin.
get() !=
'\n')
80 TEST(TestSuite, testSendSecondParameters)
83 ram_display::DisplayTrajectory srv;
84 srv.request.cylinder_size = 0.01;
85 srv.request.wire_size = 5;
86 srv.request.axis_size = 0.2;
87 srv.request.display_mode = 3;
88 srv.request.color_mode = 0;
89 srv.request.display_labels =
true;
90 srv.request.label_type = 0;
91 srv.request.labels_size = 9;
92 bool success(display_traj_client.
call(srv));
94 EXPECT_TRUE(srv.response.error.empty());
96 if (!srv.response.error.empty())
101 ROS_WARN_STREAM(
"Press enter in the terminal to skip to the next test");
102 while (std::cin.
get() !=
'\n')
108 TEST(TestSuite, testSendSecondWrongParameters)
113 ram_display::DisplayTrajectory srv;
114 srv.request.display_mode = 5;
115 bool success(display_traj_client.
call(srv));
116 EXPECT_TRUE(success);
117 EXPECT_FALSE(srv.response.error.empty());
121 TEST(TestSuite, testDeleteMarkersServiceExistence)
123 delete_markers_client =
nh->serviceClient<ram_display::DeleteTrajectory>(
"ram/display/delete_trajectory");
129 TEST(TestSuite, testDeleteMarkers)
131 ram_display::DeleteTrajectory srv;
132 bool success(delete_markers_client.
call(srv));
133 EXPECT_TRUE(success);
137 ROS_WARN_STREAM(
"Press enter in the terminal to skip to the next test");
138 while (std::cin.
get() !=
'\n')
149 ros::init(argc, argv,
"services_clients");
153 nh->param<
bool>(
"use_gui",
use_gui,
false);
170 ROS_WARN_STREAM(
"Could not fetch transformation from " << trajectory_frame <<
" to base");
174 testing::InitGoogleTest(&argc, argv);
175 return RUN_ALL_TESTS();
std::string trajectory_frame
ros::ServiceClient display_traj_client
void publish(const boost::shared_ptr< M > &message) const
void poseEigenToMsg(const Eigen::Affine3d &e, geometry_msgs::Pose &m)
TEST(TestSuite, testDisplayServiceExistence)
std::unique_ptr< ros::NodeHandle > nh
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
int main(int argc, char **argv)
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
#define ROS_WARN_STREAM(args)
uint32_t getNumSubscribers() const
ros::ServiceClient delete_markers_client
ROSCPP_DECL bool exists(const std::string &service_name, bool print_failure_reason)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
#define ROS_ERROR_STREAM(args)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)