30 using namespace gtsam;
33 static const double ms = 1
e-3;
34 static const double cm = 1
e-2;
42 const double height = 0.5;
43 vector<Point3> microphones;
44 microphones.push_back(
Point3(0, 0, height));
45 microphones.push_back(
Point3(403 *
cm, 0, height));
46 microphones.push_back(
Point3(403 *
cm, 403 *
cm, height));
47 microphones.push_back(
Point3(0, 403 *
cm, 2 * height));
59 Event(timeOfEvent, 245 *
cm +
key * 1.0, 201.5 *
cm, (212 - 45) *
cm));
69 size_t K = microphones.size();
70 vector<double> simulatedTOA(K);
71 for (
size_t i = 0;
i <
K;
i++) {
79 vector<vector<double>>
simulateTOA(
const vector<Point3>& microphones,
81 vector<vector<double>> simulatedTOA;
82 for (
auto event : trajectory) {
83 simulatedTOA.push_back(
simulateTOA(microphones, event));
91 const vector<vector<double>>& simulatedTOA) {
95 auto model = noiseModel::Isotropic::Sigma(1, 0.5 *
ms);
97 size_t K = microphones.size();
99 for (
auto toa : simulatedTOA) {
100 for (
size_t i = 0;
i <
K;
i++) {
121 int main(
int argc,
char* argv[]) {
124 size_t K = microphones.size();
125 for (
size_t i = 0;
i <
K;
i++) {
126 cout <<
"mic" <<
i <<
" = " << microphones[
i] << endl;
134 auto simulatedTOA =
simulateTOA(microphones, groundTruth);
136 for (
size_t i = 0;
i <
K;
i++) {
137 cout <<
"z_" <<
key <<
i <<
" = " << simulatedTOA[
key][
i] /
ms <<
" ms" 147 initialEstimate.print(
"Initial Estimate:\n");
155 result.
print(
"Final Result:\n");
const gtsam::Symbol key('X', 0)
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()
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
Factor Graph consisting of non-linear factors.
vector< Event > createTrajectory(size_t n)
noiseModel::Diagonal::shared_ptr model
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)
static const SmartProjectionParams params
def trajectory(g0, g1, N=20)
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
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.)
void setAbsoluteErrorTol(double value)
Time of arrival to given sensor.
static const TimeOfArrival kTimeOfArrival(330)
void setVerbosityLM(const std::string &s)
vector< Point3 > defineMicrophones()
void insert(Key j, const Value &val)
static const double timeOfEvent