Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
GiordanoLaminetti committed Nov 12, 2020
1 parent 316a6e4 commit c4d4d4f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,8 @@ Dataset/
.*.ipynb
.vscode
*.csv
.jupyter
.local_settings
.ipython
.config

4 changes: 2 additions & 2 deletions settings.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SLAM.alg: "OrbSlam3"
SLAM.alg: "OrbSlam2"
#--------------------------------------------------------------------------------------------
# SLAM Method: change with the name of the .py file in whitch there are the class SLAM
#--------------------------------------------------------------------------------------------
Expand All @@ -7,4 +7,4 @@ SLAM.alg: "OrbSlam3"
# SLAM Params: add your own to run the algorithm
#--------------------------------------------------------------------------------------------
SLAM.vocab_path: "slam_method/Settings/ORBvoc.bin"
SLAM.settings_path: "slam_method/Settings/OrbSlam3_KITTI_02.yaml"
SLAM.settings_path: "slam_method/Settings/OrbSlam2_KITTI_02.yaml"
26 changes: 13 additions & 13 deletions slam_method/OrbSlam2.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import orbslam2
import sys
import os.path
sys.path.append("..")
from pyslam import State
from pyslam import Sensor
from slampy import Sensor
from slampy import State
import orbslam2
import os.path


class SLAM():
class Slam():
def __init__(self, params, sensor_type):
config_file = params['SLAM.settings_path']
vocab_file = params['SLAM.vocab_path']

#check the existence of the configuration file
# check the existence of the configuration file

if not os.path.exists(config_file):
raise FileNotFoundError(config_file+" not found")

if not os.path.exists(vocab_file):
raise FileNotFoundError(vocab_file+" not found")

Expand Down Expand Up @@ -70,20 +71,19 @@ def get_pose(self):

def get_abs_cloud(self):
if self.slam.get_tracking_state() == orbslam2.TrackingState.OK:
return self.get_tracked_mappoints()
return self.slam.get_tracked_mappoints()

def get_camera_matrix(self):
return self.slam.get_camera_matrix()

def get_state(self):
if self.slam.get_tracking_state() == orbslam2.TrackingState.OK:
if self.slam.get_tracking_state() == orbslam2.TrackingState.OK:
return State.OK
elif self.slam.get_tracking_state() == orbslam2.TrackingState.LOST:
elif self.slam.get_tracking_state() == orbslam2.TrackingState.LOST:
return State.LOST
elif self.slam.get_tracking_state() == orbslam2.TrackingState.NOT_INITIALIZED:
elif self.slam.get_tracking_state() == orbslam2.TrackingState.NOT_INITIALIZED:
return State.NOT_INITIALIZED


def reset(self):
self.slam.reset()

Expand Down
14 changes: 7 additions & 7 deletions slam_method/OrbSlam3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import sys
import os.path
sys.path.append("..")
from pyslam import State
from pyslam import Sensor
from slampy import State
from slampy import Sensor

class Slam():

Expand All @@ -12,10 +12,10 @@ def __init__(self, params, sensor_type):
vocab_file = params['SLAM.vocab_path']

#check the existence of the configuration file

if not os.path.exists(config_file):
raise FileNotFoundError(config_file+" not found")

if not os.path.exists(vocab_file):
raise FileNotFoundError(vocab_file+" not found")

Expand Down Expand Up @@ -68,7 +68,7 @@ def process_image_imu_mono(self, image, tframe, imu):
self.slam.process_image_imu_mono(image, tframe, imu,'0')
else:
raise Exception("The sensor type is not MONOCULAR_IMU")

def process_image_imu_stereo(self,image_left,image_right,tframe,imu):
if self.sensor_type == Sensor.STEREO_IMU:
self.slam.process_image_imu_stereo(image,tframe,imu,'0')
Expand All @@ -80,7 +80,7 @@ def process_image_rgbd(self,image,tframe):
self.slam.process_image_rgbd(image,tframe,'0')
else:
raise Exception("The sensor type is not RGBD")

def get_pose(self):
if self.slam.get_tracking_state() == orbslam3.TrackingState.OK:
return self.slam.get_frame_pose()
Expand All @@ -91,7 +91,7 @@ def get_abs_cloud(self):

def get_camera_matrix(self):
return self.slam.get_camera_matrix()

def get_state(self):
if self.slam.get_tracking_state() == orbslam3.TrackingState.OK:
return State.OK
Expand Down
4 changes: 2 additions & 2 deletions usage_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"metadata": {},
"outputs": [],
"source": [
"app = pyslam.System(setting_file,pyslam.Sensor.MONOCULAR)"
"app = slampy.System(setting_file,slampy.Sensor.MONOCULAR)"
]
},
{
Expand Down Expand Up @@ -104,7 +104,7 @@
" state = app.process_image_mono(image,timestamps[idx])\n",
" t2 = time.time()\n",
" \n",
" if state == pyslam.State.OK:\n",
" if state == slampy.State.OK:\n",
" \n",
" #get the depth\n",
" depth = app.get_depth()\n",
Expand Down

0 comments on commit c4d4d4f

Please sign in to comment.