Skip to content

Commit ae39579

Browse files
committed
Miscellaneous refactoring
1 parent 37dfde3 commit ae39579

File tree

3 files changed

+13
-45
lines changed

3 files changed

+13
-45
lines changed

include/octree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace la3dm {
1818
void hash_key_to_node(OcTreeHashKey key, unsigned short &depth, unsigned short &index);
1919

2020
/*
21-
* @brief A simple OcTree to organize GP occupancy data in one block.
21+
* @brief A simple OcTree to organize occupancy data in one block.
2222
*
2323
* OcTree doesn't store positions of nodes in order to reduce memory usage.
2424
* The nodes in OcTrees are indexed by OcTreeHashKey which can be used to

include/octree_node.h

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ namespace la3dm {
1212
};
1313

1414
/*
15-
* @brief GP regression ouputs and occupancy state.
15+
* @brief Inference ouputs and occupancy state.
1616
*
17-
* Occupancy has member variables: m_ivar (m*ivar), ivar (1/var) and State.
18-
* This representation speeds up the updates via BCM.
17+
* Occupancy has member variables: m_A and m_B (kernel densities of positive
18+
* and negative class, respectively) and State.
1919
* Before using this class, set the static member variables first.
2020
*/
2121
class Occupancy {
@@ -47,9 +47,9 @@ namespace la3dm {
4747
~Occupancy() { }
4848

4949
/*
50-
* @brief Bayesian Committee Machine (BCM) update for Gaussian Process regression.
51-
* @param new_m mean resulted from GP regression
52-
* @param new_var variance resulted from GP regression
50+
* @brief Exact updates for nonparametric Bayesian kernel inference
51+
* @param ybar kernel density estimate of positive class (occupied)
52+
* @param kbar kernel density of negative class (unoccupied)
5353
*/
5454
void update(float ybar, float kbar);
5555

@@ -76,23 +76,15 @@ namespace la3dm {
7676
bool classified;
7777

7878
private:
79-
// float m; // m / var or m * ivar
80-
// float var; // 1.0 / var
8179
float m_A;
8280
float m_B;
8381
State state;
8482

85-
static float sf2; // signal variance
83+
static float sf2;
8684
static float ell; // length-scale
87-
// static float noise; // noise variance
88-
// static float l; // gamma in logistic functions
8985

90-
// static float max_ivar; // minimum variance
91-
// static float min_ivar; // maximum variance
92-
// static float min_known_ivar; // maximum variance for nodes to be considered as FREE or OCCUPIED
93-
94-
static float prior_A;
95-
static float prior_B;
86+
static float prior_A; // prior on alpha
87+
static float prior_B; // prior on beta
9688

9789
static float free_thresh; // FREE occupancy threshold
9890
static float occupied_thresh; // OCCUPIED occupancy threshold
@@ -102,4 +94,4 @@ namespace la3dm {
10294
typedef Occupancy OcTreeNode;
10395
}
10496

105-
#endif //GPOCTOMAP_OCCUPANCY_H
97+
#endif // LA3DM_OCCUPANCY_H

src/octree_node.cpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
#include "octree_node.h"
2-
// #include "gpregressor.h"
32
#include <cmath>
43

54
namespace la3dm {
65

76
/// Default static values
87
float Occupancy::sf2 = 1.0f;
98
float Occupancy::ell = 1.0f;
10-
// float Occupancy::noise = 0.01f;
11-
// float Occupancy::l = 100.f;
12-
13-
// float Occupancy::max_ivar = 1000.0f;
14-
// float Occupancy::min_ivar = 0.001f;
15-
16-
// float Occupancy::min_known_ivar = 10.0f;
179
float Occupancy::free_thresh = 0.3f;
1810
float Occupancy::occupied_thresh = 0.7f;
11+
float Occupancy::var_thresh = 1000.0f;
1912
float Occupancy::prior_A = 0.5f;
2013
float Occupancy::prior_B = 0.5f;
21-
float Occupancy::var_thresh = 1000.0f;
22-
2314

2415
Occupancy::Occupancy(float A, float B) : m_A(Occupancy::prior_A + A), m_B(Occupancy::prior_B + B) {
2516
classified = false;
2617
float var = get_var();
27-
// std::cout << var << std::endl;
2818
if (var > Occupancy::var_thresh)
2919
state = State::UNKNOWN;
3020
else {
@@ -35,33 +25,19 @@ namespace la3dm {
3525
}
3626

3727
float Occupancy::get_prob() const {
38-
// logistic regression function
39-
// return 1.0f / (1.0f + (float) exp(-l * m_ivar / Occupancy::max_ivar));
40-
// return m_ivar;
4128
return m_A / (m_A + m_B);
4229
}
4330

4431
void Occupancy::update(float ybar, float kbar) {
45-
// ivar += 1.0 / new_var - Occupancy::sf2;
46-
// m_ivar += new_m / new_var;
47-
// m_ivar = new_m;
4832
classified = true;
4933
m_A += ybar;
50-
if (kbar < 0.0)
51-
{
52-
std::cerr << "YBAR: " << ybar << ", KBAR: " << kbar << std::endl;
53-
abort();
54-
}
5534
m_B += kbar - ybar;
5635

57-
5836
float var = get_var();
59-
// std::cout << var << std::endl;
6037
if (var > Occupancy::var_thresh)
6138
state = State::UNKNOWN;
6239
else {
6340
float p = get_prob();
64-
// if (p != 0.75) std::cout << "ERR: " << p << std::endl;
6541
state = p > Occupancy::occupied_thresh ? State::OCCUPIED : (p < Occupancy::free_thresh ? State::FREE
6642
: State::UNKNOWN);
6743
}
@@ -84,4 +60,4 @@ namespace la3dm {
8460
std::ostream &operator<<(std::ostream &os, const Occupancy &oc) {
8561
return os << '(' << oc.m_A << ' ' << oc.m_B << ' ' << oc.get_prob() << ')';
8662
}
87-
}
63+
}

0 commit comments

Comments
 (0)