diff --git a/matlab/createGaussianFactorGraph.m b/matlab/createGaussianFactorGraph.m new file mode 100644 index 000000000..b9560ebf1 --- /dev/null +++ b/matlab/createGaussianFactorGraph.m @@ -0,0 +1,61 @@ +% create a linear factor graph +% The non-linear graph above evaluated at NoisyConfig +function fg = createGaussianFactorGraph() + +c = createNoisyConfig(); + +% Create +fg = GaussianFactorGraph; +sigma1=.1; + +% prior on x1 +A11=eye(2); +b = - c.get('x1'); + +f1 = GaussianFactor('x1', A11, b, sigma1); % generate a Gaussian factor of odometry +fg.push_back(f1); + +% odometry between x1 and x2 +sigma2=.1; + +A21=-eye(2); +A22=eye(2); +b = [.2;-.1]; + +f2 = GaussianFactor('x1', A21, 'x2', A22, b,sigma2); + +fg.push_back(f2); + +% measurement between x1 and l1 +sigma3=.2; +A31=-eye(2); +A33=eye(2); +b = [0;.2]; + + +f3 = GaussianFactor('x1', A31, 'l1', A33, b,sigma3); + +fg.push_back(f3); + +% measurement between x2 and l1 +sigma4=.2; +A42=-eye(2); +A43=eye(2); +b = [-.2;.3]; + + +f4 = GaussianFactor('x2', A42, 'l1', A43, b,sigma4); + +fg.push_back(f4); + + +% Optimization +n=1; +m=2; + +ord = create_ordering(n,m); + +%BayesNet = GaussianFactorGraph.eliminate_(ord); + + +end \ No newline at end of file diff --git a/matlab/createLinearFactorGraph.m b/matlab/createLinearFactorGraph.m deleted file mode 100644 index 2d9ef93e3..000000000 --- a/matlab/createLinearFactorGraph.m +++ /dev/null @@ -1,62 +0,0 @@ -% create a linear factor graph -% The non-linear graph above evaluated at NoisyConfig -function fg = createGaussianFactorGraph() - -c = createNoisyConfig(); - -% Create -fg = GaussianFactorGraph; -sigma1=.1; - -% prior on x1 -A11=eye(2); -b = - c.get('x1'); - -<<<<<<< .mine -f1 = LinearFactor('x1', A11, b, sigma1); -======= -f1 = GaussianFactor('x1', A11, b); ->>>>>>> .r1017 -fg.push_back(f1); - -% odometry between x1 and x2 -sigma2=.1; - -<<<<<<< .mine -A21=-eye(2); -A22=eye(2); -b = [.2;-.1]; - -f2 = LinearFactor('x1', A21, 'x2', A22, b,sigma2); -======= -f2 = GaussianFactor('x1', A21, 'x2', A22, b); ->>>>>>> .r1017 -fg.push_back(f2); - -% measurement between x1 and l1 -sigma3=.2; -A31=-eye(2); -A33=eye(2); -b = [0;.2]; - -<<<<<<< .mine -f3 = LinearFactor('x1', A31, 'l1', A33, b,sigma3); -======= -f3 = GaussianFactor('x1', A31, 'l1', A32, b); ->>>>>>> .r1017 -fg.push_back(f3); - -% measurement between x2 and l1 -sigma4=.2; -A42=-eye(2); -A43=eye(2); -b = [-.2;.3]; - -<<<<<<< .mine -f4 = LinearFactor('x2', A42, 'l1', A43, b,sigma4); -======= -f4 = GaussianFactor('x2', A41, 'l1', A42, b); ->>>>>>> .r1017 -fg.push_back(f4); - -end \ No newline at end of file diff --git a/matlab/create_config.m b/matlab/create_config.m index b0be9ed97..63ae0eb7c 100644 --- a/matlab/create_config.m +++ b/matlab/create_config.m @@ -6,7 +6,7 @@ function config = create_config(n,m) config = VectorConfig(); for j = 1:n - config.insert(sprintf('m%d',j), [0;0]); + config.insert(sprintf('l%d',j), [0;0]); end for i = 1:m diff --git a/matlab/create_good_ordering.m b/matlab/create_good_ordering.m index aeb119e1f..36275f80e 100644 --- a/matlab/create_good_ordering.m +++ b/matlab/create_good_ordering.m @@ -10,7 +10,7 @@ mes=size(measurements,2); while (pose<=m)&&(j<=mes) ord.push_back(sprintf('x%d',pose)); while (j