SFMdata.py
Go to the documentation of this file.
1 """
2 A structure-from-motion example with landmarks
3  - The landmarks form a 10 meter cube
4  - The robot rotates around the landmarks, always facing towards the cube
5 """
6 # pylint: disable=invalid-name, E1101
7 
8 from typing import List
9 
10 import numpy as np
11 
12 import gtsam
13 from gtsam import Cal3_S2, Point3, Pose3
14 
15 
16 def createPoints() -> List[Point3]:
17  # Create the set of ground-truth landmarks
18  points = [
19  Point3(10.0, 10.0, 10.0),
20  Point3(-10.0, 10.0, 10.0),
21  Point3(-10.0, -10.0, 10.0),
22  Point3(10.0, -10.0, 10.0),
23  Point3(10.0, 10.0, -10.0),
24  Point3(-10.0, 10.0, -10.0),
25  Point3(-10.0, -10.0, -10.0),
26  Point3(10.0, -10.0, -10.0),
27  ]
28  return points
29 
30 
31 def createPoses(K: Cal3_S2) -> List[Pose3]:
32  """Generate a set of ground-truth camera poses arranged in a circle about the origin."""
33  radius = 40.0
34  height = 10.0
35  angles = np.linspace(0, 2 * np.pi, 8, endpoint=False)
36  up = gtsam.Point3(0, 0, 1)
37  target = gtsam.Point3(0, 0, 0)
38  poses = []
39  for theta in angles:
40  position = gtsam.Point3(radius * np.cos(theta), radius * np.sin(theta), height)
41  camera = gtsam.PinholeCameraCal3_S2.Lookat(position, target, up, K)
42  poses.append(camera.pose())
43  return poses
Vector3 Point3
Definition: Point3.h:38


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:35:42