57 if(pSigmaMultiplicator <= 0.0
f)
58 throw std::out_of_range(
"Dimensions of a geometric primitive must be non-negative.");
68 throw std::invalid_argument(
"Empty ros::publisher cannot be used to publish marker messages.");
76 if(pMarkerShape != visualization_msgs::Marker::SPHERE && pMarkerShape != visualization_msgs::Marker::LINE_LIST)
77 throw std::invalid_argument(
"Chosen marker shape is not supported to visualize.");
80 if((pEllipsoidColor.r < 0.0f || pEllipsoidColor.r > 1.0f) || (pEllipsoidColor.g < 0.0f || pEllipsoidColor.g > 1.0f) || (pEllipsoidColor.b < 0.0f || pEllipsoidColor.b > 1.0f) || (pEllipsoidColor.a < 0.0f || pEllipsoidColor.a > 1.0f))
81 throw std::out_of_range(
"ColorRGBA message is no valid color information.");
93 ellipsoidMarker->ns =
"distribution";
96 ellipsoidMarker->id = pMarkerID;
99 ellipsoidMarker->type = pMarkerShape;
102 ellipsoidMarker->action = visualization_msgs::Marker::ADD;
105 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> es(*
mCovariance);
106 Eigen::Matrix3d rotationMatrixOrientation = es.eigenvectors();
118 tf::Matrix3x3 tfRotationMatrixOrientation(rotationMatrixOrientation(0,0), rotationMatrixOrientation(0,1), rotationMatrixOrientation(0,2),
119 rotationMatrixOrientation(1,0), rotationMatrixOrientation(1,1), rotationMatrixOrientation(1,2),
120 rotationMatrixOrientation(2,0), rotationMatrixOrientation(2,1), rotationMatrixOrientation(2,2));
123 tf::Transform tfEllipsoidPose(tfRotationMatrixOrientation, tfEllipsoidPosition);
129 ellipsoidMarker->pose.position.x *=
mScale;
130 ellipsoidMarker->pose.position.y *=
mScale;
131 ellipsoidMarker->pose.position.z *=
mScale;
134 Eigen::Vector3d squaredEllipsoidLengths = es.eigenvalues();
137 if(pMarkerShape == visualization_msgs::Marker::SPHERE)
148 std::vector<std::vector<std::vector<float> > >::const_iterator ellipseIterator;
151 for(ellipseIterator = pWireFramePolygons.begin(); ellipseIterator != pWireFramePolygons.end(); ellipseIterator++) {
154 std::vector<std::vector<float> >::const_iterator polygonPointIterator = ellipseIterator->begin();
157 geometry_msgs::Point rosPolygonPoint;
163 ellipsoidMarker->points.push_back(rosPolygonPoint);
166 for(polygonPointIterator++; polygonPointIterator != ellipseIterator->end(); polygonPointIterator++) {
170 ellipsoidMarker->points.push_back(rosPolygonPoint);
173 ellipsoidMarker->points.push_back(rosPolygonPoint);
178 ellipsoidMarker->points.push_back(rosPolygonPoint);
182 ellipsoidMarker->scale.x = pWireFrameWidth;
187 ellipsoidMarker->color = pEllipsoidColor;
196 return ellipsoidMarker;
202 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> es(*
mCovariance);
205 for(
int i = 0; i < 3; i++)
207 visualization_msgs::Marker msg;
210 Eigen::Vector3d eigenvector = es.eigenvectors().col(i) * es.eigenvalues()[i];
222 msg.type = visualization_msgs::Marker::ARROW;
225 msg.action = visualization_msgs::Marker::ADD;
228 geometry_msgs::Point start;
229 start.x = (*mMean)[0] *
mScale;
230 start.y = (*mMean)[1] *
mScale;
231 start.z = (*mMean)[2] *
mScale;
232 msg.points.push_back(start);
235 geometry_msgs::Point stop;
236 stop.x = ((*mMean)[0] + eigenvector[0]) * mScale;
237 stop.y = ((*mMean)[1] + eigenvector[1]) * mScale;
238 stop.z = ((*mMean)[2] + eigenvector[2]) * mScale;
239 msg.points.push_back(stop);
243 msg.ns =
"distribution_frame/" + boost::lexical_cast<std::string>(pMarkerID);
246 msg.color.r = (i == 0) ? 1.0 : 0.0;
247 msg.color.g = (i - 1 == 0) ? 1.0 : 0.0;
248 msg.color.b = (i - 2 == 0) ? 1.0 : 0.0;
260 throw std::invalid_argument(
"Empty ros::publisher cannot be used to publish marker messages.");
269 if((pColor.r < 0.0f || pColor.r > 1.0f) || (pColor.g < 0.0f || pColor.g > 1.0f) || (pColor.b < 0.0f || pColor.b > 1.0f) || (pColor.a < 0.0f || pColor.a > 1.0f))
270 throw std::out_of_range(
"ColorRGBA message is no valid color information.");
272 visualization_msgs::Marker msg;
284 msg.type = visualization_msgs::Marker::ARROW;
295 msg.action = visualization_msgs::Marker::ADD;
298 geometry_msgs::Point start;
299 start.x = pPoint->x() *
mScale;
300 start.y = pPoint->y() *
mScale;
301 start.z = pPoint->z() *
mScale + 0.5;
302 msg.points.push_back(start);
305 geometry_msgs::Point stop;
306 stop.x = pPoint->x() *
mScale;
307 stop.y = pPoint->y() *
mScale;
308 stop.z = pPoint->z() *
mScale;
309 msg.points.push_back(stop);
321 throw std::invalid_argument(
"Empty ros::publisher cannot be used to publish marker messages.");
324 for(
unsigned int i = 0; i < pCloud.size(); i++)
330 visualization_msgs::Marker msg;
337 msg.ns =
"samples/" + boost::lexical_cast<std::string>(pMarkerID);
343 msg.type = visualization_msgs::Marker::SPHERE;
346 msg.action = visualization_msgs::Marker::ADD;
349 msg.pose.position.x = pPoint->x() *
mScale;
350 msg.pose.position.y = pPoint->y() *
mScale;
351 msg.pose.position.z = pPoint->z() *
mScale;
354 msg.pose.orientation.x = 1;
355 msg.pose.orientation.y = 1;
356 msg.pose.orientation.z = 1;
357 msg.pose.orientation.w = 1;
377 if(pPositionVector.size() != 3)
378 throw std::invalid_argument(
"pPositionVector is not a position in terms of dimensionality.");
381 pROSPositionMsg.x = pPositionVector.at(0);
382 pROSPositionMsg.y = pPositionVector.at(1);
383 pROSPositionMsg.z = pPositionVector.at(2);
float mSigmaMultiplicator
visualization_msgs::Marker generatePointCloudPoint(const int pMarkerID, const unsigned int pId, const boost::shared_ptr< Eigen::Quaternion< double > > &pPoint)
void setSigmaMultiplicator(const float pSigmaMultiplicator)
void publishCovarianceEllipsoidMarker(const int pMarkerID, const std_msgs::ColorRGBA &pEllipsoidColor)
void publishArrowToPoint(const int pMarkerID, const std_msgs::ColorRGBA &pColor, const boost::shared_ptr< Eigen::Quaternion< double > > pPoint)
void publishPointCloud(const int pMarkerID, const std::vector< boost::shared_ptr< Eigen::Quaternion< double > > > pCloud)
visualization_msgs::Marker generateArrowToPoint(const int pMarkerID, const std_msgs::ColorRGBA &pColor, const boost::shared_ptr< Eigen::Quaternion< double > > pPoint)
void stlVectorToPointMsg(const std::vector< T > pPositionVector, geometry_msgs::Point &pROSPositionMsg)
void setKernel(const boost::shared_ptr< Eigen::Vector3d > &pMean, const boost::shared_ptr< Eigen::Matrix3d > &pCovariance)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
boost::shared_ptr< Eigen::Vector3d > mMean
boost::shared_ptr< ros::Publisher > mPublisher
boost::shared_ptr< visualization_msgs::Marker > generateCovarianceEllipsoidMarker(const int pMarkerID, const int pMarkerShape, const std::vector< std::vector< std::vector< float > > > &pWireFramePolygons, const float &pWireFrameWidth, const std_msgs::ColorRGBA &pEllipsoidColor)
static void poseTFToMsg(const Pose &bt, geometry_msgs::Pose &msg)
boost::shared_ptr< Eigen::Matrix3d > mCovariance
void setObjectLocationFrameID(const std::string &pObjectLocationFrameID)
void publishCovarianceEllipsoidCoordinateSystemMarker(const int pMarkerID)
void setScaleFactor(double pScale)
void setAlphaChannel(const float pAlphaChannel)
std::string mObjectLocationFrameID