OcmSceneObjectLearner.cpp
Go to the documentation of this file.
1 
19 
21 
22  OcmSceneObjectLearner::OcmSceneObjectLearner(std::string pSceneObjectType, std::string pSceneName)
23  : SceneObjectLearner(pSceneObjectType)
24  {
25  // Term learners should be specified here.
29  }
30 
32  {
33  }
34 
36  {
37  // Debug message.
38  ROS_INFO_STREAM("Initializing visualizer for primary scene object '" << mSceneObjectType << "'.");
39 
40  // Create a new coordinator for seondary scene object visualization.
41  mVisualizer.reset(new Visualization::ProbabilisticPrimarySceneObjectVisualization(mSceneObjectType));
42 
43  // Append it to supperior visualizer.
44  mSuperior->appendVisualizer(mVisualizer);
45 
46  // Forward visualizer to the OCM model.
47  mOcmModel->initializeVisualizer(mVisualizer);
48  }
49 
50  void OcmSceneObjectLearner::save(boost::property_tree::ptree& pPt)
51  {
52  // Create a seperate tree.
53  boost::property_tree::ptree subtree;
54 
55  // Add scene object parameters.
56  subtree.add("<xmlattr>.name", mSceneObjectType);
57  subtree.add("<xmlattr>.type", "ocm");
58  subtree.add("<xmlattr>.priori", mPriori);
59 
60  // Write the OCM tree to XML.
61  mOcmModel->save(mWorkspaceVolume, subtree);
62 
63  // Add subtree to main tree.
64  pPt.add_child("object", subtree);
65  }
66 
67 
68  void OcmSceneObjectLearner::learn(std::vector<ISM::ObjectSetPtr> pExamplesList, boost::shared_ptr<SceneModel::TreeNode> pTree)
69  {
70  if(!pTree)
71  throw std::runtime_error("FATAL ERROR: Relation graph generator wasn't able to provide a tree.");
72 
73  ROS_INFO_STREAM("Rearranging tree for object of type " << mSceneObjectType << ".");
74 
75  // The tree needs to be rearranged. The node with the given type has to be root node.
76  pTree = pTree->setNewRootNodeByType(mSceneObjectType);
77 
78  // Print tree.
79  ROS_INFO_STREAM("Tree rearranged for object of type " << mSceneObjectType << ".");
80  std::cout << "------------- TREE:" << std::endl;
81  pTree->printTreeToConsole(0);
82  std::cout << "---------------------" << std::endl;
83 
84  // Build the OCM tree.
86 
87  // Iterate over all learners and let them calculate the model parameters.
88  BOOST_FOREACH(boost::shared_ptr<TermLearner> learner, mTermLearners)
89  learner->learn(mOcmModel);
90  }
91 
92 }
std::vector< boost::shared_ptr< TermLearner > > mTermLearners
OcmSceneObjectLearner(std::string pSceneObjectType, std::string pSceneName="")
boost::shared_ptr< Visualization::ProbabilisticPrimarySceneObjectVisualization > mVisualizer
#define ROS_INFO_STREAM(args)
void learn(std::vector< ISM::ObjectSetPtr > pExamplesList, boost::shared_ptr< SceneModel::TreeNode > pTree)
void initializeVisualizer(boost::shared_ptr< Visualization::ProbabilisticSceneVisualization > mSuperior)


asr_psm
Author(s): Braun Kai, Gehrung Joachim, Heizmann Heinrich, Meißner Pascal
autogenerated on Fri Nov 15 2019 03:57:54