40 #include <std_msgs/Float64.h> 57 assert(static_cast<int>(particle) >= 0 && particle <
_listOfSamples.size());
65 double current_weight;
66 std::vector<WeightedSample<StatePosVel> >::const_iterator it_los;
69 current_weight = it_los->WeightGet();
70 pos += (it_los->ValueGet().pos_ * current_weight);
71 vel += (it_los->ValueGet().vel_ * current_weight);
80 assert(num_samples > 0);
85 for (
unsigned int s = 0;
s < num_samples;
s++)
88 for (
unsigned int i = 0; i < 3; i++)
90 if (v[i] < m[i]) m[i] = v[i];
91 if (v[i] > M[i]) M[i] = v[i];
97 unsigned int row = hist.rows();
98 unsigned int col = hist.columns();
99 unsigned int total = 0;
101 for (
unsigned int r = 1; r <= row; r++)
102 for (
unsigned int c = 1; c <= col; c++)
103 if (hist(r, c) > threshold) total++;
105 std::vector<geometry_msgs::Point32> points(total);
106 std::vector<float> weights(total);
107 sensor_msgs::ChannelFloat32 channel;
108 for (
unsigned int r = 1; r <= row; r++)
109 for (
unsigned int c = 1; c <= col; c++)
110 if (hist(r, c) > threshold)
112 for (
unsigned int i = 0; i < 3; i++)
113 points[t].
x = m[0] + (step[0] * r);
114 points[t].
y = m[1] + (step[1] * c);
116 weights[t] =
rgb[999 -
static_cast<int>(trunc(std::max(0.0, std::min(999.0, hist(r, c) * 2 * total * total))))];
119 cloud.header.frame_id =
"odom_combined";
120 cloud.points = points;
121 channel.name =
"rgb";
122 channel.values = weights;
123 cloud.channels.push_back(channel);
147 unsigned int rows = round((M[0] - m[0]) / step[0]);
148 unsigned int cols = round((M[1] - m[1]) / step[1]);
149 Matrix hist(rows, cols);
153 for (
unsigned int i = 0; i < num_samples; i++)
161 unsigned int r = round(rel[0] / step[0]);
162 unsigned int c = round(rel[1] / step[1]);
163 if (r >= 1 && c >= 1 && r <= rows && c <= cols)
void getParticleCloud(const tf::Vector3 &step, double threshold, sensor_msgs::PointCloud &cloud) const
Get evenly distributed particle cloud.
virtual StatePosVel ExpectedValueGet() const
MatrixWrapper::Matrix getHistogram(const tf::Vector3 &min, const tf::Vector3 &max, const tf::Vector3 &step, bool pos_hist) const
Get histogram from certain area.
Class representing state with pos and vel.
virtual WeightedSample< StatePosVel > SampleGet(unsigned int particle) const
virtual unsigned int numParticlesGet() const
TFSIMD_FORCE_INLINE const tfScalar & z() const
TFSIMD_FORCE_INLINE const tfScalar & y() const
TFSIMD_FORCE_INLINE const tfScalar & x() const
MatrixWrapper::Matrix getHistogramPos(const tf::Vector3 &min, const tf::Vector3 &max, const tf::Vector3 &step) const
Get pos histogram from certain area.
virtual ~MCPdfPosVel()
Destructor.
MCPdfPosVel(unsigned int num_samples)
Constructor.
vector< WeightedSample< StatePosVel > > _listOfSamples
static const unsigned int NUM_CONDARG
MatrixWrapper::Matrix getHistogramVel(const tf::Vector3 &min, const tf::Vector3 &max, const tf::Vector3 &step) const
Get vel histogram from certain area.