26 std::string pPbdObjectTopic;
29 std::string pPbdSceneGraphTopic;
32 std::string sceneModelFileName;
39 std::string baseFrameId;
45 double sigmaMultiplicator;
49 throw std::runtime_error(
"Please specify parameter " + std::string(
"plot") +
" when starting this node.");
53 throw std::runtime_error(
"Please specify parameter " + std::string(
"object_topic") +
" when starting this node.");
57 throw std::runtime_error(
"Please specify parameter " + std::string(
"scene_graph_topic") +
" when starting this node.");
61 throw std::runtime_error(
"Please specify parameter " + std::string(
"scene_model_filename") +
" when starting this node.");
65 throw std::runtime_error(
"Please specify parameter " + std::string(
"base_frame_id") +
" when starting this node.");
69 throw std::runtime_error(
"Please specify parameter " + std::string(
"scale_factor") +
" when starting this node.");
73 throw std::runtime_error(
"Please specify parameter " + std::string(
"sigma_multiplicator") +
" when starting this node.");
77 throw std::runtime_error(
"Please specify parameter " + std::string(
"targeting_help") +
" when starting this node.");
81 throw std::runtime_error(
"Please specify parameter " + std::string(
"inference_algorithm") +
" when starting this node.");
127 catch(std::exception& exception){
129 ROS_ERROR(
"Unable to resolve transformation in target coordinate frame. Dropping object.");
144 std::vector<SceneIdentifier> pSceneList;
147 printf(
"===========================================");
148 printf(
"This are the scene probabilities:\n");
150 printf(
" -> %s (%s): %f (%f)\n", i.mDescription.c_str(), i.mType.c_str(), i.mLikelihood, i.mPriori);
156 std::vector<std::string> barLabels;
157 std::map<std::string, float> currentData;
160 barLabels.push_back(i.mDescription);
161 currentData.insert(std::pair<std::string, float>(i.mDescription, i.mLikelihood));
185 throw std::runtime_error(
"Please specify parameter " + std::string(
"bag_path") +
" when starting this node.");
187 ROS_INFO_STREAM(
"Extracting AsrObject messages from rosbag file: " << bagPath);
191 throw std::logic_error(
"Cannot parse bag file with AsrObjects without knowing on which topic they were sent.");
204 std::cerr <<
"Trying to extract AsrObject messages aborted because of: " << exception.what() << std::endl;
210 rosbag::View pbdSceneGraphView(pbdObjectsBag, pbdSceneGraphIdentifier);
213 if(!pbdSceneGraphView.
size())
224 if(currentObject != NULL)
230 catch(std::exception& exception){
232 ROS_INFO(
"Unable to resolve transformation in target coordinate frame. Dropping object.");
245 pbdObjectsBag.close();
260 ROS_INFO(
"Initializing visualization mechanism.");
263 mVisualizer.reset(
new Visualization::ProbabilisticSceneModelVisualization());
269 mVisualizer->setDrawingParameters(pScale, pSigmaMultiplicator, pFrameId);
272 std::vector<SceneIdentifier> pSceneList;
279 std::vector<std::string> barLabels;
280 std::map<std::string, float> currentData;
283 barLabels.push_back(i.mDescription);
284 currentData.insert(std::pair<std::string, float>(i.mDescription, i.mLikelihood));
288 mVisGnuplot.initAnimatedBarChart(barLabels,
"Scene Probability",
"Probability", std::pair<float, float>(0.0, 1.0));
304 geometry_msgs::Pose *asrPose =
new geometry_msgs::Pose();
305 asrPose->position.x = pObject->pose->point->getEigen().x();
306 asrPose->position.y = pObject->pose->point->getEigen().y();
307 asrPose->position.z = pObject->pose->point->getEigen().z();
308 asrPose->orientation.w = pObject->pose->quat->getEigen().w();
309 asrPose->orientation.x = pObject->pose->quat->getEigen().x();
310 asrPose->orientation.y = pObject->pose->quat->getEigen().y();
311 asrPose->orientation.z = pObject->pose->quat->getEigen().z();
313 geometry_msgs::PoseWithCovariance *poseWithCovariance =
new geometry_msgs::PoseWithCovariance();
314 poseWithCovariance->pose = *asrPose;
316 outputObject->sampledPoses.push_back(*poseWithCovariance);
318 outputObject->identifier = pObject->observedId;
319 outputObject->type = pObject->type;
320 outputObject->providedBy = pObject->providedBy;
321 outputObject->meshResourcePath = pObject->ressourcePath.string();
322 outputObject->typeConfidence = pObject->weight;
323 outputObject->sizeConfidence = pObject->confidence;
332 geometry_msgs::Pose asrPose = pObject->sampledPoses.front().pose;
334 ISM::Point *point =
new ISM::Point(asrPose.position.x, asrPose.position.y, asrPose.position.z);
336 ISM::Quaternion *quat =
new ISM::Quaternion(asrPose.orientation.w, asrPose.orientation.x, asrPose.orientation.y, asrPose.orientation.z);
341 outputObject->observedId = pObject->identifier;
342 outputObject->type = pObject->type;
343 outputObject->providedBy = pObject->providedBy;
344 outputObject->ressourcePath = pObject->meshResourcePath;
345 outputObject->weight = pObject->typeConfidence;
346 outputObject->confidence = pObject->sizeConfidence;
void loadSceneModel(const std::string pSceneModelFileName, const std::string pInferenceAlgorithm)
ros::Subscriber mObjectListener
void open(std::string const &filename, uint32_t mode=bagmode::Read)
void initializeVisualizer(boost::shared_ptr< Visualization::ProbabilisticSceneModelVisualization > mSuperior)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
Visualization::GnuplotVisualization mVisGnuplot
void integrateEvidence(const boost::shared_ptr< const ISM::Object > &pObject)
boost::shared_ptr< Visualization::ProbabilisticSceneModelVisualization > mVisualizer
void initializeVisualizationChain(const double pScale, const float pSigmaMultiplicator, const std::string pFrameId)
void newObservationCallback(const boost::shared_ptr< asr_msgs::AsrObject > &pObject)
void executeInStackMode()
void getSceneListWithProbabilities(std::vector< SceneIdentifier > &pSceneList)
std::string getTopic() const
boost::shared_ptr< asr_msgs::AsrObject > ISMObjectToAsrObject(boost::shared_ptr< ISM::Object > pObject)
ObjectTransformation mObjectTransform
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
#define ROS_INFO_STREAM(args)
void loadModelFromFile(std::string pPathToFile, std::string pAlgorithm)
bool getParam(const std::string &key, std::string &s) const
ros::NodeHandle mNodeHandle
std::queue< boost::shared_ptr< asr_msgs::AsrObject > > mEvidenceBuffer
boost::shared_ptr< ISM::Object > AsrObjectToISMObject(boost::shared_ptr< asr_msgs::AsrObject > pObject)
SceneModelDescription mModel