20 #include "asr_recognizer_prediction_ism/pose_prediction/PosePredictionNode.h" 21 #include "asr_recognizer_prediction_ism/SceneRecognizerService.h" 24 #include <gtest/gtest.h> 40 node_handle->
setParam(
"dbfilename",
"/home/patrick/catkin_ws/src/ilcasRosFull/perception/scene_understanding/recognizer_prediction_ism/test/rsc/smacks_throne.sqlite");
41 node_handle->
setParam(
"foundObjectClientName",
"/env/asr_world_model/get_found_object_list");
44 node_handle->
setParam(
"toggleVisualizationServerName",
"recognizer_prediction_toggle_visualization");
77 using namespace boost::interprocess;
78 shared_memory_object::remove(
"SharedMemory");
80 managed_shared_memory segment
86 const RecognitionResultAllocator alloc_inst (segment.get_segment_manager());
89 segment.construct<SharedrecognitionresultVector>(
"SharedrecognitionresultVector")
91 named_mutex::remove(
"resultsMutex");
92 named_mutex mutex(open_or_create,
"resultsMutex");
104 sceneRecognizer = SceneRecognizerServicePtr(
new SceneRecognizerService());
109 using namespace boost::interprocess;
110 shared_memory_object::remove(
"SharedMemory");
111 named_mutex::remove(
"resultsMutex");
125 asr_recognizer_prediction_ism::GetPointCloud::Request
req;
126 asr_recognizer_prediction_ism::GetPointCloud::Response
res;
137 PointPtr plateDeepPointPtr(
new Point(-0.888345658850255, 0.632926776060424,
139 QuaternionPtr plateDeepQuatPtr(
new Quaternion(0.651570493634819, -0.643417330721776,
140 -0.27727505130885, 0.2908411529908));
141 PosePtr plateDeepPosePtr(
new Pose(plateDeepPointPtr, plateDeepQuatPtr));
142 ObjectPtr objectPtr(
new Object(
"PlateDeep", plateDeepPosePtr));
154 PointPtr cupPdVPointPtr(
new Point(-0.89555632189646,
157 QuaternionPtr cupPdVQuatPtr(
new Quaternion(0.0437368287079934,
158 -0.00284608589628875,
162 for (asr_msgs::AsrAttributedPoint attributedPoint :
res.point_cloud.elements)
164 double x = attributedPoint.pose.position.x;
165 double y = attributedPoint.pose.position.y;
166 double z = attributedPoint.pose.position.z;
167 double qw = attributedPoint.pose.orientation.w;
168 double qx = attributedPoint.pose.orientation.x;
169 double qy = attributedPoint.pose.orientation.y;
170 double qz = attributedPoint.pose.orientation.z;
172 PointPtr currentPointPtr(
new Point(x,y,z));
173 QuaternionPtr currentQuaternionPtr(
new Quaternion(qw, qx, qy, qz));
174 double distance = GeometryHelper::getDistanceBetweenPoints(currentPointPtr,cupPdVPointPtr);
175 double angle = GeometryHelper::getAngleBetweenQuats(currentQuaternionPtr, cupPdVQuatPtr);
177 if (distance < 0.03 && angle < 5)
192 EXPECT_LT(0,
res.point_cloud.elements.size());
194 asr_msgs::AsrAttributedPointCloud pointCloud1 =
res.point_cloud;
197 asr_msgs::AsrAttributedPointCloud pointCloud2 =
res.point_cloud;
198 EXPECT_GE(pointCloud1.elements.size(), pointCloud2.elements.size());
223 unsigned int size = 100;
226 double lower_bound = 0;
227 double upper_bound = 1;
228 std::uniform_real_distribution<double> unif(lower_bound,upper_bound);
229 std::default_random_engine re;
230 double random_confidence = unif(re);
247 std::vector<ISM::RecognitionResult> sortedResults =
posePredictionNodePtr->getSharedMemoryManagerPtr()->getResults();
250 for (
unsigned int i = 0; i < sortedResults.size(); i++)
252 EXPECT_LE(confidence, sortedResults.at(i).getConfidence());
253 confidence = sortedResults.at(i).getConfidence();
258 ISM::RecognitionResult best =
posePredictionNodePtr->getSharedMemoryManagerPtr()->sortListAndgetBest();
259 EXPECT_EQ(1.0, best.getConfidence());
264 int main(
int argc,
char **argv)
266 ros::init(argc, argv,
"test_recognizer_prediction");
267 testing::InitGoogleTest(&argc, argv);
268 return RUN_ALL_TESTS();
std::vector< ISM::VotedPointsTypePtr > votedPoints
TEST_F(PaperPredictionNormalizedTest, databaseTest)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL const std::string & getName()
int main(int argc, char **argv)
ISM::RecognitionResultPtr resultPtr
PosePredictionNodePtr posePredictionNodePtr
static void TearDownTestCase()
static ros::NodeHandle * node_handle
asr_recognizer_prediction_ism::GetPointCloud::Response res
ISM::PosePtr referencePose
static void SetUpTestCase()
std::vector< ISM::RecognitionResultPtr > recognitionResults
SceneRecognizerServicePtr sceneRecognizer
ISM::ObjectSetPtr recognizedSet
ROSCONSOLE_DECL bool set_logger_level(const std::string &name, levels::Level level)
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
#define ROSCONSOLE_DEFAULT_NAME
asr_recognizer_prediction_ism::GetPointCloud::Request req
std::vector< ISM::PointPtr > idealPoints