| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | from gtsam import * | 
					
						
							|  |  |  | import numpy as np | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | r = Rot3() | 
					
						
							|  |  |  | print(r) | 
					
						
							|  |  |  | print(r.pitch()) | 
					
						
							|  |  |  | r2 = Rot3() | 
					
						
							|  |  |  | r3 = r.compose(r2) | 
					
						
							|  |  |  | print("r3 pitch:", r3.pitch()) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | v = np.array([.1, .1, .1]) | 
					
						
							|  |  |  | print("v = ", v) | 
					
						
							|  |  |  | r4 = r3.retract(v) | 
					
						
							|  |  |  | print("r4 pitch:", r4.pitch()) | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | r4.print_(b'r4: ') | 
					
						
							|  |  |  | r3.print_(b"r3: ") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | v = r3.localCoordinates(r4) | 
					
						
							|  |  |  | print("localCoordinates:", v) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Rmat = np.array([ | 
					
						
							|  |  |  |     [0.990074, -0.0942928, 0.104218],  | 
					
						
							|  |  |  |     [0.104218,  0.990074, -0.0942928],  | 
					
						
							|  |  |  |     [-0.0942928, 0.104218, 0.990074] | 
					
						
							|  |  |  |     ]) | 
					
						
							| 
									
										
										
										
											2016-11-17 06:51:03 +08:00
										 |  |  | r5 = Rot3(R=Rmat) | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | r5.print_(b"r5: ") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | l = Rot3.Logmap(r5) | 
					
						
							|  |  |  | print("l = ", l) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-16 23:42:01 +08:00
										 |  |  | noise = noiseModel_Gaussian.Covariance(Rmat) | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | noise.print_(b"noise:") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | D = np.array([1.,2.,3.]) | 
					
						
							| 
									
										
										
										
											2016-09-16 23:42:01 +08:00
										 |  |  | diag = noiseModel_Diagonal.Variances(D) | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | print("diag:", diag) | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | diag.print_(b"diag:") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | print("diag R:", diag.R()) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | p = Point3() | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | p.print_("p:") | 
					
						
							| 
									
										
										
										
											2016-11-17 06:51:03 +08:00
										 |  |  | factor = BetweenFactorPoint3(1,2,p, noise) | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | factor.print_(b"factor:") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | vv = VectorValues() | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | vv.print_(b"vv:") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | vv.insert(1, np.array([1.,2.,3.])) | 
					
						
							|  |  |  | vv.insert(2, np.array([3.,4.])) | 
					
						
							|  |  |  | vv.insert(3, np.array([5.,6.,7.,8.])) | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | vv.print_(b"vv:") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-17 06:51:03 +08:00
										 |  |  | vv2 = VectorValues(vv) | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | vv2.insert(4, np.array([4.,2.,1])) | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | vv2.print_(b"vv2:") | 
					
						
							|  |  |  | vv.print_(b"vv:") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | vv.insert(4, np.array([1.,2.,4.])) | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | vv.print_(b"vv:") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | vv3 = vv.add(vv2) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | vv3.print_(b"vv3:") | 
					
						
							| 
									
										
										
										
											2016-09-14 19:47:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | values = Values() | 
					
						
							|  |  |  | values.insertPoint3(1, Point3()) | 
					
						
							|  |  |  | values.insertRot3(2, Rot3()) | 
					
						
							| 
									
										
										
										
											2016-09-20 00:39:41 +08:00
										 |  |  | values.print_(b"values:") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-17 06:51:03 +08:00
										 |  |  | factor = PriorFactorVector(1, np.array([1.,2.,3.]), diag) | 
					
						
							|  |  |  | print "Prior factor vector: ", factor |