35 for(
unsigned int i = 0; i < samples.size(); i++) {
36 visualization_msgs::Marker m;
38 m.header.frame_id =
"/map";
43 m.type = visualization_msgs::Marker::SPHERE;
44 m.action = visualization_msgs::Marker::ADD;
46 m.pose.position.x = samples[i][0];
47 m.pose.position.y = samples[i][1];
48 m.pose.position.z = samples[i][2];
50 m.pose.orientation.x = 1;
51 m.pose.orientation.y = 1;
52 m.pose.orientation.z = 1;
53 m.pose.orientation.w = 1;
74 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> es(covariance);
75 Eigen::Quaterniond q(es.eigenvectors());
78 for(
int i = 0; i < 3; i++) {
79 visualization_msgs::Marker e =
createArrowMarker(mean, mean + es.eigenvectors().col(i) * es.eigenvalues()[i]);
82 e.ns =
"eigenvectors";
83 e.color.r = (i == 0) ? 1.0 : 0.0;
84 e.color.g = (i - 1 == 0) ? 1.0 : 0.0;
85 e.color.b = (i - 2 == 0) ? 1.0 : 0.0;
103 visualization_msgs::Marker m;
105 m.header.frame_id =
"/map";
107 m.ns =
"gaussian_distribution";
110 m.type = visualization_msgs::Marker::SPHERE;
111 m.action = visualization_msgs::Marker::ADD;
115 m.scale.x = (std::abs(es.eigenvalues()[0]) * 2) + 0.1;
116 m.scale.y = (std::abs(es.eigenvalues()[1]) * 2) + 0.1;
117 m.scale.z = (std::abs(es.eigenvalues()[2]) * 2) + 0.1;
119 m.pose.position.x = mean[0];
120 m.pose.position.y = mean[1];
121 m.pose.position.z = mean[2];
123 m.pose.orientation.w = q.w();
124 m.pose.orientation.x = q.x();
125 m.pose.orientation.y = q.y();
126 m.pose.orientation.z = q.z();
137 Eigen::Vector3d mean(0, 0, 0);
138 Eigen::Matrix3d covariance = Eigen::Matrix3d::Zero();
141 for(
unsigned int i = 0; i < samples.size(); i++) {
144 mean /= samples.size();
147 for(
unsigned int i = 0; i < samples.size(); i++) {
148 covariance += (samples[i] - mean) * (samples[i].adjoint() - mean.adjoint());
150 covariance /= (samples.size());
158 visualization_msgs::Marker m;
161 m.header.frame_id =
"/map";
167 m.type = visualization_msgs::Marker::ARROW;
168 m.action = visualization_msgs::Marker::ADD;
177 geometry_msgs::Point p;
void publish(const boost::shared_ptr< M > &message) const
ros::Publisher eigenPublisher
ros::Publisher gaussianPublisher
geometry_msgs::Point createPointMessage(Eigen::Vector3d point)
void drawSamples(std::vector< Eigen::Vector3d > samples)
ros::Publisher samplePublisher
visualization_msgs::Marker createArrowMarker(const Eigen::Vector3d a, const Eigen::Vector3d b)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
static const int ID_GAUSSIAN
void drawDistribution(Eigen::Vector3d mean, Eigen::Matrix3d covariance)