Skip to content

Commit

Permalink
format with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
GiordanoLaminetti committed Apr 18, 2021
1 parent 4b306fd commit ab5a673
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 48 deletions.
4 changes: 2 additions & 2 deletions slampy.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def process_image_stereo(self, image_left, image_right, tframe):
"""
self.image_shape = image_left.shape
self.slam.process_image_stereo(image_left, image_right, tframe)
self.image = image
self.image = image_left
if self.get_state() == State.OK:
self.pose_array.append(self.get_pose_to_target())
return self.get_state()
Expand Down Expand Up @@ -141,7 +141,7 @@ def process_image_imu_stereo(self, image_left, image_right, tframe, imu):
"""
self.image_shape = image_left.shape
self.slam.process_image_imu_stereo(image_left, image_right, tframe, imu)
self.image = image
self.image = image_left
if self.get_state() == State.OK:
self.pose_array.append(self.get_pose_to_target())
return self.get_state()
Expand Down
91 changes: 45 additions & 46 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def save_pose_txt(args, name, pose):
"""
pose_file_path = os.path.join(args.dest, "pose.txt")
fp = open(pose_file_path, "a")
pose34 = pose[:3]
pose34 = pose[:3]
fp.write(name)
for row in pose34:
fp.write(" ")
Expand All @@ -242,31 +242,28 @@ def save_pose_txt(args, name, pose):
fp.close()




def save_pose_and_times_txt(args, name, pose):
"""Save pose and time in two different txt files."""

time_file_path = os.path.join(args.dest, "times.txt")
pose_file_path = os.path.join(args.dest, "pose.txt")
fd = open(time_file_path, "a")
fp = open(pose_file_path, "a")
pose34 = pose[:3]
pose34 = pose[:3]
fd.write(name)
fd.write("\n")
fd.close()
line=""
for row in pose34:
line+=(" ".join(str(round(i, 10)) for i in row))
line+=(" ")
line=line[:-1]
line+=("\n")
line = ""
for row in pose34:
line += " ".join(str(round(i, 10)) for i in row)
line += " "
line = line[:-1]
line += "\n"
fp.write(line)
# fp.write('\n')
fp.close()



def evaluate_pose(args):
"""Evaluate odometry on the KITTI dataset"""
orb_pose_dir = os.path.join(args.dest, "pose")
Expand Down Expand Up @@ -398,7 +395,6 @@ def get_error(args, filename, points, gt_filename):
return err



def load_images_KITTI_VO(path_to_sequence):
"""Return the sequence of the images found in the path and the corrispondent timestamp
Expand Down Expand Up @@ -454,10 +450,10 @@ def load_images_OTHERS(path_to_sequence):
two array : one contains the sequence of the image filename and the second the timestamp in whitch they are acquired
Inside of path_to_sequence must be: +data
xxxxxxxx.png
xxxxxxxx.png
xxxxxxxy.png
....
-times.txt
-times.txt
where times.txt simply contains timestamps of every frame
"""
Expand All @@ -469,67 +465,70 @@ def load_images_OTHERS(path_to_sequence):
for line in times_file:
if len(line) > 0 and not line.startswith("#"):
timestamps.append(float(line))
for framename in sorted(os.listdir(os.path.join(path_to_sequence,"data"))):

for framename in sorted(os.listdir(os.path.join(path_to_sequence, "data"))):
if framename.endswith(".png"):
framenames.append(framename)

return [os.path.join(path_to_sequence,"data",name) for name in framenames], timestamps
return [
os.path.join(path_to_sequence, "data", name) for name in framenames
], timestamps


def load_images_TUM_VI(path_to_sequence):

""" This loader is created for Visual Inertial TUM datasets. Format of such datasets is:
path_to_sequence/mav0/cam0/+data/xxxx.png
/-times.txt
"""This loader is created for Visual Inertial TUM datasets. Format of such datasets is:
path_to_sequence/mav0/cam0/+data/xxxx.png
/-times.txt
"""
timestamps = []
framenames = []
with open(os.path.join(path_to_sequence,"mav0/cam0/times.txt")) as times_file:

with open(os.path.join(path_to_sequence, "mav0/cam0/times.txt")) as times_file:
for line in times_file:
if len(line) > 0 and not line.startswith("#"):
framenames.append(line.split()[0] + ".png")
timestamps.append(float(line.split()[1]))

return [os.path.join(path_to_sequence,"mav0/cam0/data",name) for name in framenames], timestamps

return [
os.path.join(path_to_sequence, "mav0/cam0/data", name) for name in framenames
], timestamps


def load_images_EuRoC(path_to_sequence):

""" This loader is created for Visual Inertial EuRoC datasets. Format of such datasets is:
path_to_sequence/mav0/cam0/+data/xxxx.png
/-times.txt
"""This loader is created for Visual Inertial EuRoC datasets. Format of such datasets is:
path_to_sequence/mav0/cam0/+data/xxxx.png
/-times.txt
"""
timestamps = []
framenames = []
with open(os.path.join(path_to_sequence,"mav0/cam0/data.csv")) as times_file:

with open(os.path.join(path_to_sequence, "mav0/cam0/data.csv")) as times_file:
for line in times_file:
if len(line) > 0 and not line.startswith("#"):
framenames.append(line.split(",")[1].rstrip())
timestamps.append(float(line.split(",")[0])*1e-9)

return [os.path.join(path_to_sequence,"mav0/cam0/data",name) for name in framenames], timestamps
timestamps.append(float(line.split(",")[0]) * 1e-9)

return [
os.path.join(path_to_sequence, "mav0/cam0/data", name) for name in framenames
], timestamps


def load_IMU_datas_TUM_VI(path_to_sequence):
timestamp = []
gyro_data = []
acc_data = []
with open(os.path.join(path_to_sequence,"mav0/imu0/data.csv")) as imu_file:
with open(os.path.join(path_to_sequence, "mav0/imu0/data.csv")) as imu_file:
for line in imu_file:
if len(line) > 0 and not line.startswith("#"):
imu_line=line.split(",")
timestamp.append(float(imu_line[0])*1e-9)
gyro_data.append([float(imu_line[1]),float(imu_line[2]),float(imu_line[3])])
acc_data.append([float(imu_line[4]),float(imu_line[5]),float(imu_line[6])])

return acc_data,gyro_data,timestamp






imu_line = line.split(",")
timestamp.append(float(imu_line[0]) * 1e-9)
gyro_data.append(
[float(imu_line[1]), float(imu_line[2]), float(imu_line[3])]
)
acc_data.append(
[float(imu_line[4]), float(imu_line[5]), float(imu_line[6])]
)

return acc_data, gyro_data, timestamp

0 comments on commit ab5a673

Please sign in to comment.