Change VisualISAM2Example to work with python 2 and python 3

release/4.3a0
Ellon Mendes 2015-11-28 00:36:29 +01:00
parent dfa2b53eeb
commit 72bcc4f08e
1 changed files with 10 additions and 8 deletions

View File

@ -1,3 +1,4 @@
from __future__ import print_function
import gtsam import gtsam
from gtsam.examples.SFMdata import * from gtsam.examples.SFMdata import *
from gtsam.utils import * from gtsam.utils import *
@ -36,8 +37,9 @@ def visual_ISAM2_plot(poses, points, result):
ax.set_xlim3d(-40, 40) ax.set_xlim3d(-40, 40)
ax.set_ylim3d(-40, 40) ax.set_ylim3d(-40, 40)
ax.set_zlim3d(-40, 40) ax.set_zlim3d(-40, 40)
plt.show(block=False) plt.ion()
plt.draw(); plt.show()
plt.draw()
def visual_ISAM2_example(): def visual_ISAM2_example():
# Define the camera calibration parameters # Define the camera calibration parameters
@ -104,15 +106,15 @@ def visual_ISAM2_example():
# to perform multiple optimizer iterations every step. # to perform multiple optimizer iterations every step.
isam.update() isam.update()
currentEstimate = isam.calculate_estimate(); currentEstimate = isam.calculate_estimate();
print "****************************************************" print( "****************************************************" )
print "Frame", i, ":" print( "Frame", i, ":" )
for j in range(i+1): for j in range(i+1):
print gtsam.Symbol('x',j) print( gtsam.Symbol('x',j) )
print currentEstimate.pose3_at(int(gtsam.Symbol('x',j))) print( currentEstimate.pose3_at(int(gtsam.Symbol('x',j))) )
for j in range(len(points)): for j in range(len(points)):
print gtsam.Symbol('l',j) print( gtsam.Symbol('l',j) )
print currentEstimate.point3_at(int(gtsam.Symbol('l',j))) print( currentEstimate.point3_at(int(gtsam.Symbol('l',j))) )
visual_ISAM2_plot(poses, points, currentEstimate); visual_ISAM2_plot(poses, points, currentEstimate);
time.sleep(1) time.sleep(1)