| 
									
										
										
										
											2012-06-11 06:32:24 +08:00
										 |  |  | function VisualISAMPlot(truth, data, isam, result, options)
 | 
					
						
							| 
									
										
										
										
											2012-09-08 13:28:25 +08:00
										 |  |  | % VisualISAMPlot plots current state of ISAM2 object | 
					
						
							| 
									
										
										
										
											2012-06-10 11:31:09 +08:00
										 |  |  | % Authors: Duy Nguyen Ta and Frank Dellaert | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-20 14:49:56 +08:00
										 |  |  | import gtsam.* | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2012-07-28 03:02:11 +08:00
										 |  |  | marginals = Marginals(isam.getFactorsUnsafe(), isam.calculateEstimate()); % TODO - this is slow | 
					
						
							| 
									
										
										
										
											2012-08-04 05:02:45 +08:00
										 |  |  | gtsam.plot3DPoints(result, [], marginals); | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | %% Plot cameras | 
					
						
							| 
									
										
										
										
											2012-07-28 03:02:11 +08:00
										 |  |  | M = 1; | 
					
						
							|  |  |  | while result.exists(symbol('x',M)) | 
					
						
							|  |  |  |     ii = symbol('x',M); | 
					
						
							| 
									
										
										
										
											2014-11-14 07:51:11 +08:00
										 |  |  |     pose_i = result.atPose3(ii); | 
					
						
							| 
									
										
										
										
											2012-07-28 03:02:11 +08:00
										 |  |  |     if options.hardConstraint && (M==1) | 
					
						
							| 
									
										
										
										
											2012-08-04 05:02:45 +08:00
										 |  |  |         gtsam.plotPose3(pose_i,[],10); | 
					
						
							| 
									
										
										
										
											2012-06-10 23:26:59 +08:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2012-07-28 03:02:11 +08:00
										 |  |  |         P = marginals.marginalCovariance(ii); | 
					
						
							| 
									
										
										
										
											2012-08-04 05:02:45 +08:00
										 |  |  |         gtsam.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-08-04 05:02:45 +08:00
										 |  |  |         gtsam.plotPose3(truth.cameras{M}.pose,[],10); | 
					
						
							| 
									
										
										
										
											2012-06-09 04:08:53 +08:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-07-28 03:02:11 +08:00
										 |  |  |      | 
					
						
							|  |  |  |     M = M + options.cameraInterval; | 
					
						
							| 
									
										
										
										
											2012-06-09 04:08:53 +08:00
										 |  |  | 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-09-04 13:13:35 +08:00
										 |  |  |     figToSave = figure('visible','off'); | 
					
						
							|  |  |  |     newax = copyobj(h,figToSave); | 
					
						
							|  |  |  |     colormap(figToSave,'hot'); | 
					
						
							| 
									
										
										
										
											2012-06-09 12:01:37 +08:00
										 |  |  |     set(newax, 'units', 'normalized', 'position', [0.13 0.11 0.775 0.815]); | 
					
						
							| 
									
										
										
										
											2012-09-04 13:13:35 +08:00
										 |  |  |     print(figToSave,'-dpng',sprintf('VisualiSAM%03d.png',M)); | 
					
						
							|  |  |  |     axes(h); | 
					
						
							| 
									
										
										
										
											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 |