diff --git a/.gitignore b/.gitignore index 48ba709..7066a48 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,8 @@ Dataset/ .*.ipynb .vscode *.csv +.jupyter +.local_settings +.ipython +.config + diff --git a/settings.yaml b/settings.yaml index d3d9b71..b7a5cbc 100644 --- a/settings.yaml +++ b/settings.yaml @@ -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 #-------------------------------------------------------------------------------------------- @@ -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" diff --git a/slam_method/OrbSlam2.py b/slam_method/OrbSlam2.py index 4c531a6..78cccc9 100644 --- a/slam_method/OrbSlam2.py +++ b/slam_method/OrbSlam2.py @@ -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") @@ -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() diff --git a/slam_method/OrbSlam3.py b/slam_method/OrbSlam3.py index cbf57c9..ae63330 100644 --- a/slam_method/OrbSlam3.py +++ b/slam_method/OrbSlam3.py @@ -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(): @@ -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") @@ -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') @@ -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() @@ -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 diff --git a/usage_example.ipynb b/usage_example.ipynb index acc6147..7fffd3d 100644 --- a/usage_example.ipynb +++ b/usage_example.ipynb @@ -57,7 +57,7 @@ "metadata": {}, "outputs": [], "source": [ - "app = pyslam.System(setting_file,pyslam.Sensor.MONOCULAR)" + "app = slampy.System(setting_file,slampy.Sensor.MONOCULAR)" ] }, { @@ -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",