20 #define BOOST_TEST_STATIC_LINK 22 #include <boost/test/included/unit_test.hpp> 24 #include "asr_next_best_view/GetAttributedPointCloud.h" 35 int test(SetAttributedPointCloud apc, std::vector<std::string> object_type_name_list) {
37 geometry_msgs::Pose initialPose;
38 initialPose.position.x = -0.383223;
39 initialPose.position.y = 0.157997;
40 initialPose.position.z = 1.32;
41 initialPose.orientation.x = -0.17266;
42 initialPose.orientation.y = 0.2115588;
43 initialPose.orientation.z = 0.60825979;
44 initialPose.orientation.w = 0.74528563;
45 this->setInitialPose(initialPose);
48 if (!mSetPointCloudClient.call(apc.request, apc.response)) {
49 ROS_ERROR(
"Could not set initial point cloud.");
52 asr_next_best_view::GetAttributedPointCloud gpc;
53 if (!mGetPointCloudClient.call(gpc)) {
54 ROS_ERROR(
"Could not get initial point cloud.");
57 asr_next_best_view::GetNextBestView nbv;
58 nbv.request.current_pose = initialPose;
61 int deactivatedNormals = 0;
64 if (!mGetNextBestViewClient.call(nbv.request, nbv.response)) {
65 ROS_ERROR(
"Something went wrong in next best view");
69 asr_next_best_view::UpdatePointCloud upc_req;
70 upc_req.request.object_type_name_list = object_type_name_list;
71 upc_req.request.pose_for_update = nbv.response.viewport.pose;
72 if(!mUpdatePointCloudClient.call(upc_req)) {
76 deactivatedNormals += upc_req.response.deactivated_object_normals;
80 return deactivatedNormals;
84 SetAttributedPointCloud apc;
94 orientation[0] = euler2Quaternion(-90, 0.0, 0.0);
95 orientation[1] = euler2Quaternion(-90, 0.0, 0.0);
97 std::string* types =
new std::string[nHp];
99 types[1] =
"PlateDeep";
101 int elementsPerHp[2] = { 3, 1 };
103 for (std::size_t idx = 0; idx < (std::size_t)nHp; idx++) {
104 for (std::size_t cnt = 0; cnt < (std::size_t)elementsPerHp[idx]; cnt++) {
107 asr_msgs::AsrAttributedPoint element;
109 geometry_msgs::Pose pose;
110 pose.orientation.w = orientation[idx].w();
111 pose.orientation.x = orientation[idx].x();
112 pose.orientation.y = orientation[idx].y();
113 pose.orientation.z = orientation[idx].z();
114 pose.position.x = curLocation[0] - 0.1 * cnt;
115 pose.position.y = curLocation[1];
116 pose.position.z = curLocation[2];
118 element.type = types[idx];
119 element.identifier = std::to_string(idx);
121 apc.request.point_cloud.elements.push_back(element);
125 int deactivatedSmacksNormals =
test(apc, {
"Smacks"});
126 int deactivatedSmacksPlateDeepNormals =
test(apc, {
"Smacks",
"PlateDeep"});
127 BOOST_CHECK_MESSAGE(deactivatedSmacksNormals < deactivatedSmacksPlateDeepNormals,
"Update deactivated the same or more normals without PlateDeep");
128 ROS_INFO(
"deactivated normals [Smacks, PlateDeep]: %d", deactivatedSmacksPlateDeepNormals);
129 ROS_INFO(
"deactivated normals [Smacks]: %d", deactivatedSmacksNormals);
137 test_suite* evaluation = BOOST_TEST_SUITE(
"Evaluation NBV");
142 if (boost::iequals(argv[1],
"silent") || boost::iequals(argv[1],
"s")) {
150 framework::master_test_suite().add(evaluation);
virtual ~UpdatePointCloudTest()
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
test_suite * init_unit_test_suite(int argc, char *argv[])
UpdatePointCloudTest(bool silent)
int test(SetAttributedPointCloud apc, std::vector< std::string > object_type_name_list)
#define ROS_INFO_STREAM(args)
Eigen::Quaternion< Precision > SimpleQuaternion