Skip to content

Commit

Permalink
update real-time plot
Browse files Browse the repository at this point in the history
  • Loading branch information
DanteLuo committed Apr 4, 2018
1 parent d318d43 commit bf47b0c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from readImage import readImage
from gtsamSolver import PoseNetiSam
from train import trainer
import matplotlib.pyplot as plt
import pickle
import sys

Expand All @@ -19,6 +20,10 @@ def main(pathOdom_,pathImage_,pathWeight_):
# initilize posenet
poseNet = trainer(pathWeight,pathImage)

# initialize the plot tool
plt.ion()
fig,ax = plt.subplots()

# parameter
resultsId = 1
iSamUpdateRate = 2 # times of updates in one iteration
Expand All @@ -30,7 +35,7 @@ def main(pathOdom_,pathImage_,pathWeight_):
# read data
odom = odometry(pathOdom,startId,endId)
images = readImage(pathImage)
#TODO: read the ground truth for plot comparision
# TODO: read the ground truth for plot comparision

# sensor info
poseNetCov = [0.5,0.5,0.5]
Expand All @@ -46,7 +51,7 @@ def main(pathOdom_,pathImage_,pathWeight_):
startId += numInterval
iSam.addObs(measurement,poseNetCov) # adding first measurement
iSam.update(2) # update the graph

# localization begins here
for i in range(iterations):

Expand All @@ -66,8 +71,10 @@ def main(pathOdom_,pathImage_,pathWeight_):
# increment the Id
startId += numInterval

# TODO: plot tool for the calculated trajetory

# plot tool for the calculated trajetory
ax.plot(records[-2:,1],records[-2:,2]) # plot line from x_t-1 to x_t
plt.pause(0.01) # whether need to pause?
plt.draw()

# store data
pickleOut = open('dict.{0}_result'.format(resultsId),'wb')
Expand Down

0 comments on commit bf47b0c

Please sign in to comment.