From 982d81e1c974ef784b84d278b394b84e12e25982 Mon Sep 17 00:00:00 2001 From: Ellon Mendes Date: Mon, 23 Nov 2015 12:34:15 +0100 Subject: [PATCH] Add python version of SFMdata as gtsam.examples submodule The gtsam.examples submodule should be loaded explicitely: >>> import gtsam.examples --- python/gtsam/examples/SFMdata.py | 32 +++++++++++++++++++++++++++++++ python/gtsam/examples/__init__.py | 1 + 2 files changed, 33 insertions(+) create mode 100644 python/gtsam/examples/SFMdata.py create mode 100644 python/gtsam/examples/__init__.py diff --git a/python/gtsam/examples/SFMdata.py b/python/gtsam/examples/SFMdata.py new file mode 100644 index 000000000..21a438226 --- /dev/null +++ b/python/gtsam/examples/SFMdata.py @@ -0,0 +1,32 @@ + + # A structure-from-motion example with landmarks + # - The landmarks form a 10 meter cube + # - The robot rotates around the landmarks, always facing towards the cube + +import gtsam +import numpy as np + +def createPoints(): + # Create the set of ground-truth landmarks + points = [gtsam.Point3(10.0,10.0,10.0), + gtsam.Point3(-10.0,10.0,10.0), + gtsam.Point3(-10.0,-10.0,10.0), + gtsam.Point3(10.0,-10.0,10.0), + gtsam.Point3(10.0,10.0,-10.0), + gtsam.Point3(-10.0,10.0,-10.0), + gtsam.Point3(-10.0,-10.0,-10.0), + gtsam.Point3(10.0,-10.0,-10.0)] + return points + +def createPoses(): + # Create the set of ground-truth poses + radius = 30.0 + angles = np.linspace(0,2*np.pi,8,endpoint=False) + up = gtsam.Point3(0,0,1) + target = gtsam.Point3(0,0,0) + poses = [] + for theta in angles: + position = gtsam.Point3(radius*np.cos(theta), radius*np.sin(theta), 0.0) + camera = gtsam.PinholeCameraCal3_S2.Lookat(position, target, up) + poses.append(camera.pose()) + return poses diff --git a/python/gtsam/examples/__init__.py b/python/gtsam/examples/__init__.py new file mode 100644 index 000000000..41889bb40 --- /dev/null +++ b/python/gtsam/examples/__init__.py @@ -0,0 +1 @@ +from SFMdata import *