Add wrapping and tests
parent
c2f7827748
commit
64bbc79bf6
|
@ -5,20 +5,37 @@
|
|||
namespace gtsam {
|
||||
|
||||
|
||||
// typedef pair<size_t, size_t> DiscreteKey;
|
||||
#include<gtsam/discrete/DiscreteKey.h>
|
||||
class DiscreteKey {};
|
||||
|
||||
class DiscreteKeys {
|
||||
DiscreteKeys();
|
||||
size_t size() const;
|
||||
bool empty() const;
|
||||
gtsam::DiscreteKey at(size_t n) const;
|
||||
void push_back(const gtsam::DiscreteKey& point_pair);
|
||||
};
|
||||
|
||||
#include <gtsam/discrete/DiscreteFactor.h>
|
||||
class DiscreteFactor {
|
||||
};
|
||||
|
||||
#include <gtsam/discrete/Signature.h>
|
||||
class Signature {
|
||||
Signature(gtsam::DiscreteKey key);
|
||||
};
|
||||
|
||||
#include <gtsam/discrete/DecisionTreeFactor.h>
|
||||
class DecisionTreeFactor {
|
||||
class DecisionTreeFactor: gtsam::DiscreteFactor {
|
||||
DecisionTreeFactor();
|
||||
};
|
||||
|
||||
#include <gtsam/discrete/DiscreteFactorGraph.h>
|
||||
class DiscreteFactorGraph {
|
||||
DiscreteFactorGraph();
|
||||
void add(const gtsam::DiscreteKey& j, string table);
|
||||
void add(const gtsam::DiscreteKeys& j, string table);
|
||||
void print(string s = "") const;
|
||||
};
|
||||
|
||||
} // namespace gtsam
|
||||
|
|
|
@ -49,6 +49,7 @@ set(ignore
|
|||
gtsam::Pose3Vector
|
||||
gtsam::KeyVector
|
||||
gtsam::BinaryMeasurementsUnit3
|
||||
gtsam::DiscreteKey
|
||||
gtsam::KeyPairDoubleMap)
|
||||
|
||||
set(interface_headers
|
||||
|
|
|
@ -12,3 +12,5 @@
|
|||
*/
|
||||
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
PYBIND11_MAKE_OPAQUE(gtsam::DiscreteKeys);
|
||||
|
|
|
@ -10,3 +10,6 @@
|
|||
* with `PYBIND11_MAKE_OPAQUE` this allows the types to be modified with Python,
|
||||
* and saves one copy operation.
|
||||
*/
|
||||
|
||||
// Seems this is not a good idea with inherited stl
|
||||
//py::bind_vector<std::vector<gtsam::DiscreteKey>>(m_, "DiscreteKeys");
|
|
@ -31,20 +31,32 @@ from gtsam.utils.test_case import GtsamTestCase
|
|||
# using namespace std
|
||||
# using namespace gtsam
|
||||
|
||||
from gtsam import DiscreteKeys, DiscreteFactorGraph
|
||||
|
||||
class TestDiscreteFactorGraph(GtsamTestCase):
|
||||
"""Tests for Discrete Factor Graphs."""
|
||||
|
||||
def test_evaluation(self):
|
||||
# Three keys P1 and P2
|
||||
P1=DiscreteKey(0,2)
|
||||
P2=DiscreteKey(1,2)
|
||||
P3=DiscreteKey(2,3)
|
||||
P1 = (0, 2)
|
||||
P2 = (1, 2)
|
||||
P3 = (2, 3)
|
||||
|
||||
# Create the DiscreteFactorGraph
|
||||
graph = DiscreteFactorGraph()
|
||||
# graph.add(P1, "0.9 0.3")
|
||||
# graph.add(P2, "0.9 0.6")
|
||||
# graph.add(P1 & P2, "4 1 10 4")
|
||||
graph.add(P1, "0.9 0.3")
|
||||
graph.add(P2, "0.9 0.6")
|
||||
|
||||
# NOTE(fan): originally is an operator overload in C++ &
|
||||
def discrete_and(a, b):
|
||||
dks = DiscreteKeys()
|
||||
dks.push_back(a)
|
||||
dks.push_back(b)
|
||||
return dks
|
||||
|
||||
graph.add(discrete_and(P1, P2), "4 1 10 4")
|
||||
|
||||
print(graph)
|
||||
|
||||
# # Instantiate Values
|
||||
# DiscreteFactor::Values values
|
||||
|
|
Loading…
Reference in New Issue