| 
									
										
										
										
											2016-06-11 08:48:42 +08:00
										 |  |  | %% Initialize graph, initial estimate, and odometry noise | 
					
						
							|  |  |  | datafile = findExampleDataFile('sphere2500.txt'); | 
					
						
							| 
									
										
										
										
											2016-06-16 02:26:28 +08:00
										 |  |  | model = noiseModel.Diagonal.Sigmas([5*pi/180; 5*pi/180; 5*pi/180; 0.05; 0.05; 0.05]); | 
					
						
							| 
									
										
										
										
											2016-06-11 08:48:42 +08:00
										 |  |  | [graph,initial] = load3D(datafile, model, true, 2500); | 
					
						
							| 
									
										
										
										
											2016-06-16 02:26:28 +08:00
										 |  |  | plot3DTrajectory(initial, 'g-', false); % Plot Initial Estimate | 
					
						
							| 
									
										
										
										
											2016-06-11 08:48:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | %% Read again, now with all constraints, and optimize | 
					
						
							| 
									
										
										
										
											2016-06-16 02:26:28 +08:00
										 |  |  | graph = load3D(datafile, model, false, 2500); | 
					
						
							|  |  |  | graph.add(NonlinearEqualityPose3(0, initial.atPose3(0))); | 
					
						
							| 
									
										
										
										
											2016-06-11 08:48:42 +08:00
										 |  |  | optimizer = LevenbergMarquardtOptimizer(graph, initial); | 
					
						
							|  |  |  | result = optimizer.optimizeSafely(); | 
					
						
							|  |  |  | plot3DTrajectory(result, 'r-', false); axis equal; |