Skip to content

Commit a78f6c2

Browse files
committed
Fixes for examples and VlcServerRos
1 parent ab52096 commit a78f6c2

File tree

8 files changed

+28
-22
lines changed

8 files changed

+28
-22
lines changed

examples/place_descriptor_debugging.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ def combine_images(left, right):
5858
pose = data.pose
5959
full_poses.append(pose.matrix())
6060

61-
uid = vlc_db.add_image(session_id, datetime.now(), ob.SparkImage(rgb=image))
62-
embedding = embedding_model(image)
61+
simg = ob.SparkImage(rgb=image)
62+
uid = vlc_db.add_image(session_id, datetime.now(), simg)
63+
embedding = embedding_model.infer(simg)
6364
vlc_db.update_embedding(uid, embedding)
6465

6566
# To check our estimate vs. GT later

examples/salad_example.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pathlib
22
import imageio.v3 as iio
33
from ouroboros_salad.salad_model import get_salad_model
4+
import ouroboros as ob
45

56

67
def resource_dir():
@@ -11,4 +12,6 @@ def resource_dir():
1112
model = get_salad_model()
1213
img_d = iio.imread(resource_dir() / "arch.jpg")
1314

14-
out = model(img_d)
15+
simg = ob.SparkImage(rgb=img_d)
16+
out = model.infer(simg)
17+
print("Salad model returned: ", out)

examples/uhumans_example_batch.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
from spark_dataset_interfaces.rosbag_dataloader import RosbagDataLoader
77

88
import ouroboros as ob
9-
from ouroboros.vlc_db.gt_lc_utils import (
10-
VlcPose,
11-
recover_pose,
12-
)
13-
from ouroboros_salad import get_salad_model
9+
from ouroboros_gt.gt_pose_recovery import get_gt_pose_model
10+
from ouroboros_salad.salad_model import get_salad_model
1411

1512

1613
def plot_heading(positions, rpy):
@@ -63,8 +60,9 @@ def plot_heading(positions, rpy):
6360

6461
if not idx % 2 == 0:
6562
continue
66-
uid = vlc_db.add_image(session_id, datetime.now(), ob.SparkImage(rgb=image))
67-
embedding = embedding_model(image)
63+
simg = ob.SparkImage(rgb=image)
64+
uid = vlc_db.add_image(session_id, datetime.now(), simg)
65+
embedding = embedding_model.infer(simg)
6866
# embedding = VlcPose(
6967
# time_ns=data.timestamp,
7068
# position=pose.translation,
@@ -95,7 +93,7 @@ def plot_heading(positions, rpy):
9593
continue
9694
putative_loop_closures.append((matches_to_frame[0][1], matches_to_frame[0][2]))
9795

98-
96+
pose_model = get_gt_pose_model()
9997
# Recover poses from matching loop closures
10098
for img_from, img_to in putative_loop_closures:
10199
key_from = img_from.metadata.image_uuid
@@ -106,7 +104,7 @@ def plot_heading(positions, rpy):
106104
# descriptors = generate_descriptors(img_from.image)
107105
keypoints = np.zeros([1, 2])
108106
pose = uid_to_pose[key_from]
109-
desc = VlcPose(
107+
desc = ob.VlcPose(
110108
time_ns=img_from.metadata.epoch_ns,
111109
position=pose[:3, 3],
112110
rotation=R.from_matrix(pose[:3, :3]).as_quat(),
@@ -123,7 +121,7 @@ def plot_heading(positions, rpy):
123121
# descriptors = generate_descriptors(img_to.image)
124122
keypoints = np.zeros([1, 2])
125123
pose = uid_to_pose[key_to]
126-
desc = VlcPose(
124+
desc = ob.VlcPose(
127125
time_ns=img_to.metadata.epoch_ns,
128126
position=pose[:3, 3],
129127
rotation=R.from_matrix(pose[:3, :3]).as_quat(),
@@ -134,8 +132,7 @@ def plot_heading(positions, rpy):
134132
vlc_db.update_keypoints(key_to, keypoints, descriptors)
135133
img_to = vlc_db.get_image(key_to)
136134

137-
# relative_pose = recover_pose(img_from, img_to)
138-
relative_pose = recover_pose(img_from.descriptors, img_to.descriptors)
135+
relative_pose = pose_model.infer(img_from, img_to)
139136
loop_closure = ob.SparkLoopClosure(
140137
from_image_uuid=key_from,
141138
to_image_uuid=key_to,

extra/ouroboros_ros/config/vlc_server_node.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ fixed_frame: world
22
camera_frame: ground_truth/husky/base
33
show_plots: true
44
lc_recent_pose_lockout_s: 20
5-
lc_similarity_threshold: 0.55
5+
lc_similarity_threshold: 0.65
66
lc_send_delay_s: 15
77
place_method: "salad"
88
keypoint_method: "ground_truth"

extra/ouroboros_ros/src/ouroboros_ros/vlc_server_ros.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def image_callback(self, msg):
169169
if loop_closures is None:
170170
return
171171

172-
pose_cov_mat = self.build_pose_cov_mat
172+
pose_cov_mat = self.build_pose_cov_mat()
173173
pg = PoseGraph()
174174
pg.header.stamp = rospy.Time.now()
175175
for lc in loop_closures:
@@ -189,7 +189,7 @@ def image_callback(self, msg):
189189

190190
pg.edges.append(lc_edge)
191191
self.loop_closure_delayed_queue.append(
192-
(rospy.Time.now().to_sec() + self.lc_send_delay, pg)
192+
(rospy.Time.now().to_sec() + self.lc_send_delay_s, pg)
193193
)
194194

195195
def build_pose_cov_mat(self):

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,12 @@
1010
package_dir={"": "src"},
1111
packages=find_packages("src"),
1212
package_data={"": ["*.yaml"]},
13-
install_requires=["numpy", "imageio", "pyyaml", "pytest", "importlib-resources"],
13+
install_requires=[
14+
"numpy",
15+
"imageio",
16+
"pyyaml",
17+
"pytest",
18+
"importlib-resources",
19+
"scipy",
20+
],
1421
)

src/ouroboros/utils/plotting_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,4 @@ def create_image_pair(left, right):
3232
def display_image_pair(left, right, window="matches"):
3333
img = create_image_pair(left, right)
3434
cv2.imshow(window, img.astype(np.uint8))
35-
print("going to show")
3635
cv2.waitKey(10)
37-
print("showed")

src/ouroboros_salad/salad_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, model):
1616

1717
self.input_transform = get_input_transform((322, 434))
1818

19-
def infer(self, image: ob.SparkImage, pose_hint: ob.VlcPose):
19+
def infer(self, image: ob.SparkImage, pose_hint: ob.VlcPose = None):
2020
img_float = torch.tensor((image.rgb.transpose() / 255.0).astype(np.float32))
2121
img = self.input_transform(img_float)
2222
out = self.model(img.unsqueeze(0).to("cuda")).cpu().detach().numpy()

0 commit comments

Comments
 (0)