| 
									
										
										
										
											2012-06-11 06:32:24 +08:00
										 |  |  | function VisualISAMPlot(truth, data, isam, result, options)
 | 
					
						
							| 
									
										
										
										
											2012-06-10 11:31:09 +08:00
										 |  |  | % VisualISAMPlot: plot current state of visualSLAM::iSAM object | 
					
						
							|  |  |  | % Authors: Duy Nguyen Ta and Frank Dellaert | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-13 20:05:39 +08:00
										 |  |  | M = result.nrPoses; | 
					
						
							|  |  |  | N = result.nrPoints; | 
					
						
							| 
									
										
										
										
											2012-06-10 11:31:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-09 06:36:34 +08:00
										 |  |  | h=gca; | 
					
						
							|  |  |  | cla(h); | 
					
						
							| 
									
										
										
										
											2012-06-09 04:08:53 +08:00
										 |  |  | hold on; | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | %% Plot points | 
					
						
							| 
									
										
										
										
											2012-06-14 11:55:01 +08:00
										 |  |  | % Can't use data because current frame might not see all points | 
					
						
							|  |  |  | pointKeys = result.allPoints().keys(); | 
					
						
							|  |  |  | for j=0:N-1  % NOTE: uses indexing directly from a C++ vector, so zero-indexed | 
					
						
							|  |  |  |     jj = pointKeys.at(j); | 
					
						
							| 
									
										
										
										
											2012-06-14 00:38:51 +08:00
										 |  |  |     point_j = result.point(jj); | 
					
						
							|  |  |  |     plot3(point_j.x, point_j.y, point_j.z,'marker','o'); | 
					
						
							|  |  |  |     P = isam.marginalCovariance(jj); | 
					
						
							|  |  |  |     covarianceEllipse3D([point_j.x;point_j.y;point_j.z],P); | 
					
						
							| 
									
										
										
										
											2012-06-09 04:08:53 +08:00
										 |  |  | end | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | %% Plot cameras | 
					
						
							|  |  |  | for i=1:options.cameraInterval:M | 
					
						
							|  |  |  |     ii = symbol('x',i); | 
					
						
							|  |  |  |     pose_i = result.pose(ii); | 
					
						
							|  |  |  |     if options.hardConstraint & (i==1) | 
					
						
							|  |  |  |         plotPose3(pose_i,[],10); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         P = isam.marginalCovariance(ii); | 
					
						
							|  |  |  |         plotPose3(pose_i,P,10); | 
					
						
							| 
									
										
										
										
											2012-06-09 06:36:34 +08:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  |     if options.drawTruePoses % show ground truth | 
					
						
							| 
									
										
										
										
											2012-06-11 06:32:24 +08:00
										 |  |  |         plotPose3(truth.cameras{i}.pose,[],10); | 
					
						
							| 
									
										
										
										
											2012-06-09 04:08:53 +08:00
										 |  |  |     end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | %% draw | 
					
						
							| 
									
										
										
										
											2012-06-09 04:08:53 +08:00
										 |  |  | axis([-40 40 -40 40 -10 20]);axis equal | 
					
						
							|  |  |  | view(3) | 
					
						
							|  |  |  | colormap('hot') | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  | drawnow | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | %% do various optional things | 
					
						
							| 
									
										
										
										
											2012-06-09 04:08:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  | if options.saveFigures | 
					
						
							| 
									
										
										
										
											2012-06-09 12:01:37 +08:00
										 |  |  |     fig2 = figure('visible','off'); | 
					
						
							|  |  |  |     newax = copyobj(h,fig2); | 
					
						
							|  |  |  |     colormap(fig2,'hot'); | 
					
						
							|  |  |  |     set(newax, 'units', 'normalized', 'position', [0.13 0.11 0.775 0.815]); | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  |     print(fig2,'-dpng',sprintf('VisualiSAM%03d.png',M)); | 
					
						
							| 
									
										
										
										
											2012-06-09 04:08:53 +08:00
										 |  |  | end | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | if options.saveDotFiles | 
					
						
							|  |  |  |     isam.saveGraph(sprintf('VisualiSAM%03d.dot',M)); | 
					
						
							| 
									
										
										
										
											2012-06-09 04:08:53 +08:00
										 |  |  | end | 
					
						
							| 
									
										
										
										
											2012-06-09 06:36:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  | if options.saveDotFile | 
					
						
							|  |  |  |     isam.saveGraph(sprintf('VisualiSAM.dot')); | 
					
						
							| 
									
										
										
										
											2012-06-10 13:00:42 +08:00
										 |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  | if options.printStats | 
					
						
							| 
									
										
										
										
											2012-06-10 13:00:42 +08:00
										 |  |  |     isam.printStats(); | 
					
						
							|  |  |  | end |