27 #include <boost/bind.hpp> 28 #include <boost/format.hpp> 33 using namespace gtsam;
36 static const double ms = 1
e-3;
37 static const double cm = 1
e-2;
45 const double height = 0.5;
46 vector<Point3> microphones;
47 microphones.push_back(
Point3(0, 0, height));
48 microphones.push_back(
Point3(403 *
cm, 0, height));
49 microphones.push_back(
Point3(403 *
cm, 403 *
cm, height));
50 microphones.push_back(
Point3(0, 403 *
cm, 2 * height));
62 Event(timeOfEvent, 245 *
cm +
key * 1.0, 201.5 *
cm, (212 - 45) *
cm));
72 size_t K = microphones.size();
73 vector<double> simulatedTOA(K);
74 for (
size_t i = 0;
i <
K;
i++) {
82 vector<vector<double>>
simulateTOA(
const vector<Point3>& microphones,
84 vector<vector<double>> simulatedTOA;
85 for (
auto event : trajectory) {
86 simulatedTOA.push_back(
simulateTOA(microphones, event));
94 const vector<vector<double>>& simulatedTOA) {
98 auto model = noiseModel::Isotropic::Sigma(1, 0.5 *
ms);
100 size_t K = microphones.size();
102 for (
auto toa : simulatedTOA) {
103 for (
size_t i = 0;
i <
K;
i++) {
124 int main(
int argc,
char* argv[]) {
127 size_t K = microphones.size();
128 for (
size_t i = 0;
i <
K;
i++) {
129 cout <<
"mic" <<
i <<
" = " << microphones[
i] << endl;
137 auto simulatedTOA =
simulateTOA(microphones, groundTruth);
139 for (
size_t i = 0;
i <
K;
i++) {
140 cout <<
"z_" <<
key <<
i <<
" = " << simulatedTOA[
key][
i] /
ms <<
" ms" 150 initialEstimate.print(
"Initial Estimate:\n");
158 result.
print(
"Final Result:\n");
NonlinearFactorGraph createGraph(const vector< Point3 > µphones, const vector< vector< double >> &simulatedTOA)
vector< double > simulateTOA(const vector< Point3 > µphones, const Event &event)
virtual const Values & optimize()
Factor Graph consisting of non-linear factors.
vector< Event > createTrajectory(size_t n)
noiseModel::Diagonal::shared_ptr model
void insert(Key j, const Value &val)
EIGEN_DONT_INLINE Scalar zero()
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
NonlinearFactorGraph graph
int main(int argc, char *argv[])
Values createInitialEstimate(size_t n)
def trajectory(g0, g1, N=20)
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&...args)
Emplace a shared pointer to factor of given type.
A "Time of Arrival" factor - so little code seems hardly worth it :-)
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static SmartStereoProjectionParams params
void setAbsoluteErrorTol(double value)
Time of arrival to given sensor.
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
static const TimeOfArrival kTimeOfArrival(330)
void setVerbosityLM(const std::string &s)
vector< Point3 > defineMicrophones()
static const double timeOfEvent