Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/SLAM/mk_gmux_robot_dbn.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [bnet, Unode, Snode, Lnodes, Rnode, Ynode, Lsnode] = ... | |
2 mk_gmux_robot_dbn(nlandmarks, Q, R, init_x, init_V, robot_block, landmark_block) | |
3 | |
4 % Make DBN | |
5 | |
6 % S | |
7 % | L1 -------> L1' | |
8 % | | L2 ----------> L2' | |
9 % \ | / | |
10 % v v v | |
11 % Ls | |
12 % | | |
13 % v | |
14 % Y | |
15 % ^ | |
16 % | | |
17 % R -------> R' | |
18 % ^ | |
19 % | | |
20 % U | |
21 % | |
22 % | |
23 % S is a switch, Ls is a deterministic gmux, Y = Ls-R, | |
24 % R(t+1) = R(t) + U(t+1), L(t+1) = L(t) | |
25 | |
26 | |
27 % number nodes topologically | |
28 Snode = 1; | |
29 Lnodes = 2:nlandmarks+1; | |
30 Lsnode = nlandmarks+2; | |
31 Unode = nlandmarks+3; | |
32 Rnode = nlandmarks+4; | |
33 Ynode = nlandmarks+5; | |
34 | |
35 nnodes = nlandmarks+5; | |
36 intra = zeros(nnodes, nnodes); | |
37 intra([Snode Lnodes], Lsnode) =1; | |
38 intra(Unode,Rnode)=1; | |
39 intra([Rnode Lsnode], Ynode)=1; | |
40 | |
41 inter = zeros(nnodes, nnodes); | |
42 inter(Rnode, Rnode)=1; | |
43 for i=1:nlandmarks | |
44 inter(Lnodes(i), Lnodes(i))=1; | |
45 end | |
46 | |
47 Lsz = 2; % (x y) posn of landmark | |
48 Rsz = 2; % (x y) posn of robot | |
49 Ysz = 2; % relative distance | |
50 Usz = 2; % (dx dy) ctrl | |
51 Ssz = nlandmarks; % can switch between any landmark | |
52 | |
53 ns = zeros(1,nnodes); | |
54 ns(Snode) = Ssz; | |
55 ns(Lnodes) = Lsz; | |
56 ns(Lsnode) = Lsz; | |
57 ns(Ynode) = Ysz; | |
58 ns(Rnode) = Rsz; | |
59 ns(Ynode) = Usz; | |
60 ns(Unode) = Usz; | |
61 | |
62 bnet = mk_dbn(intra, inter, ns, 'discrete', Snode, 'observed', [Snode Ynode Unode]); | |
63 | |
64 | |
65 bnet.CPD{Snode} = root_CPD(bnet, Snode); % always observed | |
66 bnet.CPD{Unode} = root_CPD(bnet, Unode); % always observed | |
67 for i=1:nlandmarks | |
68 bi = landmark_block(:,i); | |
69 bnet.CPD{Lnodes(i)} = gaussian_CPD(bnet, Lnodes(i), 'mean', init_x(bi), 'cov', init_V(bi,bi)); | |
70 end | |
71 bi = robot_block; | |
72 bnet.CPD{Rnode} = gaussian_CPD(bnet, Rnode, 'mean', init_x(bi), 'cov', init_V(bi,bi), 'weights', eye(2)); | |
73 bnet.CPD{Lsnode} = gmux_CPD(bnet, Lsnode, 'cov', repmat(zeros(Lsz,Lsz), [1 1 nlandmarks]), ... | |
74 'weights', repmat(eye(Lsz,Lsz), [1 1 nlandmarks])); | |
75 W = [eye(2) -eye(2)]; % Y = Ls - R, where Ls is the lower-numbered parent | |
76 bnet.CPD{Ynode} = gaussian_CPD(bnet, Ynode, 'mean', zeros(Ysz,1), 'cov', R, 'weights', W); | |
77 | |
78 % slice 2 | |
79 eclass = bnet.equiv_class; | |
80 W = [eye(2) eye(2)]; % R(t) = R(t-1) + U(t), where R(t-1) is the lower-numbered parent | |
81 bnet.CPD{eclass(Rnode,2)} = gaussian_CPD(bnet, Rnode+nnodes, 'mean', zeros(Rsz,1), 'cov', Q, 'weights', W); | |
82 for i=1:nlandmarks | |
83 bnet.CPD{eclass(Lnodes(i), 2)} = gaussian_CPD(bnet, Lnodes(i)+nnodes, 'mean', zeros(2,1), ... | |
84 'cov', zeros(2,2), 'weights', eye(2)); | |
85 end |