ProbabilisticSecondarySceneObjectVisualization.cpp
Go to the documentation of this file.
1 
19 
20 namespace Visualization {
21 
23  : mHandle()
24  , mCertainty(0.0)
25  , mBestScore(0.0)
26  {
27  mPublisher.reset(new ros::Publisher(mHandle.advertise<visualization_msgs::MarkerArray>("psm", 1)));
28  }
29 
31  : mSceneObject(pName)
32  , mHandle()
33  , mCertainty(0.0)
34  , mBestScore(0.0)
35  {
36  mPublisher.reset(new ros::Publisher(mHandle.advertise<visualization_msgs::MarkerArray>("psm", 1)));
37  }
38 
40  {
41  }
42 
43  void ProbabilisticSecondarySceneObjectVisualization::setDrawingParameters(const double pScale, const float pSigmaMultiplicator, const std::string pFrameId)
44  {
45  visualizerFrame.setFrameId(pFrameId);
46 
47  visualizerKernel.setFrameId(pFrameId);
49  visualizerKernel.setSigmaMultiplicator(pSigmaMultiplicator);
50 
53 
54  visualizerSamples.setFrameId(pFrameId);
56  }
57 
59  {
60  std::string ns;
61  if(mSceneObject.size() > 0)
62  ns = pNamespace + "/" + mSceneObject;
63  else
64  ns = pNamespace;
65 
69  visualizerSamples.setNamespace(ns + "/samples");
70  }
71 
72  void ProbabilisticSecondarySceneObjectVisualization::setColors(const std_msgs::ColorRGBA& pFirstColor,
73  const std_msgs::ColorRGBA& pSecondColor)
74  {
75  // Create a gray color for the unused ring.
76  std_msgs::ColorRGBA color;
77  color.r = color.g = color.b = 0.3;
78  color.a = 1.0;
79 
80  // Forward the colors to the visualizers.
81  visualizerKernel.setColors(pFirstColor, pSecondColor, color);
82  visualizerKinematics.setColors(pFirstColor, pSecondColor, color);
83  visualizerSamples.setColors(pFirstColor, pSecondColor, color);
84  }
85 
87  {
88  // Certainty must be in [0,1].
89  if(pCertainty < 0.0 && pCertainty > 1.0)
90  throw std::out_of_range("Certainty is out of range ('" + boost::lexical_cast<std::string>(pCertainty) + "').");
91 
92  // Take the bigger value.
93  if(pCertainty > mCertainty)
94  mCertainty = pCertainty;
95  }
96 
98  {
99  mCertainty = 0.0;
100  }
101 
103  {
104  // Check, if pointer is valid.
105  if(!pPose)
106  throw std::out_of_range("Invalid pointer: last observation of associated scene object pose.");
107 
108  mLastObjectPose = pPose;
109  }
110 
112  {
113  // Check, if pointer is valid.
114  if(!pPose)
115  throw std::out_of_range("Invalid pointer: absolute pose of primary scene object.");
116 
117  // Set position and orientation.
118  mBestCandidatePose = pPose;
119  }
120 
122  {
123  mBestScoreCandidate = std::min(pScore, 1.0);
124  }
125 
127  {
128  // Check, if pointer is valid.
129  if(!pPose)
130  throw std::out_of_range("Invalid pointer: absolute pose of primary scene object.");
131 
132  // Set absolute position of the primary scene object.
133  mParentPose = pPose;
134  }
135 
136  void ProbabilisticSecondarySceneObjectVisualization::setAbsoluteLearningSamples(const std::vector<Eigen::Vector3d>& pRelativeSamples,
137  const std::vector<Eigen::Vector3d>& pAbsoluteSamples,
138  const std::vector<Eigen::Vector3d>& pAbsoluteParentSamples)
139  {
140  mRelativeSamples = pRelativeSamples;
141  mAbsoluteSamples = pAbsoluteSamples;
142  mAbsoluteParentSamples = pAbsoluteParentSamples;
143  }
144 
146  {
149  }
150 
152  const boost::shared_ptr<Eigen::Matrix3d>& pCovariance)
153  {
154  // Check, if pointer is valid.
155  if(!pMean)
156  throw std::out_of_range("Invalid pointer: mean vector.");
157 
158  // Check, if pointer is valid.
159  if(!pCovariance)
160  throw std::out_of_range("Invalid pointer: covariance matrix.");
161 
162  // Store the kernel in an intern data structure.
163  mKernels.push_back(std::pair<Eigen::Vector3d, Eigen::Matrix3d>(*pMean, *pCovariance));
164  }
165 
167  {
168  // Call to advertise() should not have returned an empty publisher.
169  if(!mPublisher)
170  throw std::invalid_argument("Empty ros::publisher cannot be used to publish marker messages.");
171 
172  // Check, it parent pose is already known.
173  if(mParentPose)
174  {
175  // Forward the parent pose to the visualizer.
177 
178  // Draw all kernels stored in this class. Also draw an arrow from the parent position to the kernel mean.
179  for(std::pair<Eigen::Vector3d, Eigen::Matrix3d> kernel : mKernels)
180  visualizerKernel.publishKernel(mPublisher, pMarkerId, kernel.first, kernel.second);
181  }
182  }
183 
185  {
186  // Call to advertise() should not have returned an empty publisher.
187  if(!mPublisher)
188  throw std::invalid_argument("Empty ros::publisher cannot be used to publish marker messages.");
189 
190  // If last position is known, generate marker for it and publish it on given topic.
191  if(mLastObjectPose)
192  {
193  // Draw the object position as an arrow.
195  }
196  }
197 
198 
200  {
201  // Call to advertise() should not have returned an empty publisher.
202  if(!mPublisher)
203  throw std::invalid_argument("Empty ros::publisher cannot be used to publish marker messages.");
204 
205  // Check, it parent pose is already known.
206  if(mParentPose && mBestPose)
207  {
208  // Draw the link between parent object and this object.
209  // Apply some normalization term for the color of the kinematic chain.
210  visualizerKinematics.publishLink(mPublisher, pMarkerId, mParentPose->point->getEigen(), mBestPose->point->getEigen(), std::min(mBestScore / 0.02, 1.0)); // NOTE The normalization constant here is responsible for coloring the arrow between objects.
211  }
212  }
213 
215  {
216  // Call to advertise() should not have returned an empty publisher.
217  if(!mPublisher)
218  throw std::invalid_argument("Empty ros::publisher cannot be used to publish marker messages.");
219 
220  // Check, it parent pose is already known.
221  if(mParentPose)
222  {
223  // Forward the parent pose to the visualizer.
225 
226  // Draws a small sphere in the color of the scene object it belongs to for every learning sample.
228  }
229  }
230 
232  {
233  // Call to advertise() should not have returned an empty publisher.
234  if(!mPublisher)
235  throw std::invalid_argument("Empty ros::publisher cannot be used to publish marker messages.");
236 
237  // Draw all samples.
239  }
240 
241 }
void setSigmaMultiplicator(const float pSigmaMultiplicator)
void setNamespace(std::string pNamespace)
void publishLink(boost::shared_ptr< ros::Publisher > pPublisher, unsigned int &pMarkerId, const Eigen::Vector3d pFrom, const Eigen::Vector3d pTo, double pQualityOfMatch)
void setParentPose(boost::shared_ptr< ISM::Pose > pPose)
void setFrameId(std::string pFrameId)
void setColors(const std_msgs::ColorRGBA &pFirstRingColor, const std_msgs::ColorRGBA &pSecondRingColor)
void setDrawingParameters(const double pScale, const float pSigmaMultiplicator, const std::string pFrameId)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void setAbsoluteLearningSamples(const std::vector< Eigen::Vector3d > &pRelativeSamples, const std::vector< Eigen::Vector3d > &pAbsoluteSamples, const std::vector< Eigen::Vector3d > &pAbsoluteParentSamples)
void publishTrajectory(boost::shared_ptr< ros::Publisher > pPublisher, unsigned int &pMarkerId, const std::vector< Eigen::Vector3d > &pSamples)
void appendKernel(const boost::shared_ptr< Eigen::Vector3d > &pMean, const boost::shared_ptr< Eigen::Matrix3d > &pCovariance)
void setParentPose(boost::shared_ptr< ISM::Pose > pPose)
void publishKernel(boost::shared_ptr< ros::Publisher > pPublisher, unsigned int &pMarkerId, const Eigen::Vector3d &pMean, const Eigen::Matrix3d &pCovariance)
void setColors(const std_msgs::ColorRGBA &pFirstColor, const std_msgs::ColorRGBA &pSecondColor, const std_msgs::ColorRGBA &pThirdColor)
void publishObjectPositionAsArrow(boost::shared_ptr< ros::Publisher > pPublisher, unsigned int &pMarkerId, const boost::shared_ptr< ISM::Pose > pPose, double pQualityOfMatch)


asr_psm_visualizations
Author(s): Gehrung Joachim, Meißner Pascal
autogenerated on Sat Nov 9 2019 03:49:13