88 double determinant = cov[0][0] * cov[1][1] - cov[1][0] * cov[0][1];
92 if (!std::isfinite(determinant))
95 5.0,
"Covariance matrix has non-finite values in ProbabilityEllipseCovarianceVisual::setMeanCovariance(): " 100 if (std::abs(cov[0][1] - cov[1][0]) > 0.00001)
104 "Covariance matrix is not symmetric in ProbabilityEllipseCovarianceVisual::setMeanCovariance(): " << cov);
108 if ((determinant > 0 && cov[0][0] > 0) || (std::abs(determinant - 0.00001) == 0.0 && (cov[0][0] > 0 || cov[1][1] > 0)) )
110 calc_prob_elli_99(mean.x, mean.y, cov[0][0], cov[1][1], cov[0][1], numberOfPoints, xs, ys);
114 for (
int i = 0; i < numberOfPoints; i++)
116 Ogre::Vector3 vertex(xs[i], ys[i], mean.z);
123 "ProbabilityEllipseCovarianceVisual::setMeanCovariance(): " 131 while (alpha >= min + 2.0 * M_PI)
146 const int N_ELLI_POINTS = 40;
148 double t, cr, sr, ca, sa, xi, yi, reso;
149 static double x[N_ELLI_POINTS + 1];
150 static double y[N_ELLI_POINTS + 1];
151 reso = 2 * M_PI / N_ELLI_POINTS;
152 offset = N_ELLI_POINTS / 2;
161 xi = a * cr * ca - b * sr * sa;
162 yi = a * cr * sa + b * sr * ca;
165 x[offset + i] = -xi + xc;
166 y[offset + i] = -yi + yc;
170 x[N_ELLI_POINTS] = x[0];
171 y[N_ELLI_POINTS] = y[0];
172 np = N_ELLI_POINTS + 1;
181 double la, lb, a, b, phi;
182 la = (sxx + syy + sqrt((sxx - syy) * (sxx - syy) + 4 * sxy * sxy)) / 2;
183 lb = (sxx + syy - sqrt((sxx - syy) * (sxx - syy) + 4 * sxy * sxy)) / 2;
184 a = sqrt(5.991464 * la);
185 b = sqrt(5.991464 * lb);
194 double la, lb, a, b, phi;
195 la = (sxx + syy + sqrt((sxx - syy) * (sxx - syy) + 4 * sxy * sxy)) / 2;
196 lb = (sxx + syy - sqrt((sxx - syy) * (sxx - syy) + 4 * sxy * sxy)) / 2;
197 a = sqrt(9.210340 * la);
198 b = sqrt(9.210340 * lb);
virtual void setColor(const Ogre::ColourValue &c)
void addPoint(const Ogre::Vector3 &point)
void calc_prob_elli_95(double xc, double yc, double sxx, double syy, double sxy, int &np, double *&x, double *&y)
virtual void setMeanCovariance(const Ogre::Vector3 &mean, const Ogre::Matrix3 &cov)
NOTE: It is assumed that the covariance matrix is already rotated into the target frame of the sceneN...
virtual ~ProbabilityEllipseCovarianceVisual()
TFSIMD_FORCE_INLINE const tfScalar & y() const
void setPosition(const Ogre::Vector3 &position)
ProbabilityEllipseCovarianceVisual(Ogre::SceneManager *sceneManager, Ogre::SceneNode *parentNode)
virtual void setColor(float r, float g, float b, float a)
CovarianceVisual(Ogre::SceneManager *sceneManager, Ogre::SceneNode *parentNode)
void calc_ellipse(double xc, double yc, double a, double b, double phi, int &np, double *&xvec, double *&yvec)
virtual void setLineWidth(float lineWidth)
void setVisible(bool visible)
TFSIMD_FORCE_INLINE const tfScalar & x() const
void setOrientation(const Ogre::Quaternion &orientation)
void setMaxPointsPerLine(uint32_t max)
#define ROS_WARN_STREAM_THROTTLE(rate, args)
Ogre::SceneManager * m_sceneManager
rviz::BillboardLine * m_line
virtual ~CovarianceVisual()
Ogre::SceneNode * m_sceneNode
double set_angle_to_range(double alpha, double min)
void calc_prob_elli_99(double xc, double yc, double sxx, double syy, double sxy, int &np, double *&x, double *&y)
void setLineWidth(float width)