-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
depth_image_proc register cover all angles with fill_upsampling_holes #722
Open
lucasw
wants to merge
7
commits into
ros-perception:noetic
Choose a base branch
from
lucasw:register-depth-fill-angles
base: noetic
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ec5980d
reformatting the depth register code some, can factor some things out…
lucasw ac8c09d
make the filled upsampling holes more filled in more relative angle c…
lucasw b303b75
factored out common code from depth_image_proc register convert
lucasw 7554850
Now fully cover the area to fill with rectangles in the target image …
lucasw 4b8c45f
don't pass through negative depth values for now
lucasw 28c6ac4
basic depth_image_proc unit test of a camera situated behind the dept…
lucasw 0b14afe
don't take a timestamp too early
lucasw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/usr/bin/env python | ||
|
||
import copy | ||
import unittest | ||
|
||
import numpy as np | ||
import rospy | ||
import rostest | ||
from cv_bridge import CvBridge | ||
from sensor_msgs.msg import CameraInfo | ||
from sensor_msgs.msg import Image | ||
|
||
|
||
class TestRegister(unittest.TestCase): | ||
def test_register(self): | ||
# publish a 2x2 float depth image with depths like | ||
# [1.0, 2.0], [2.0, 1.0] | ||
# publish a camera info with a aov of around 90 degrees | ||
# publish two static tfs in the .test file, one shifted | ||
# by 1.0 in x from the depth camera_info frame | ||
# another by 2.0 in x, and 1.5 in z, with a 90 degree rotation | ||
# looking back at those depth points | ||
# publish another camera info, in series, have it shift from one frame to the other | ||
# subscribe to the depth_image_proc node and verify output | ||
# (make numbers come out even with 90 degree aov) | ||
|
||
self.output_depth = rospy.get_param("~output_depth", 1.0) | ||
self.expected_depth = rospy.get_param("~expected_depth", 7.0) | ||
rospy.loginfo(f"published depth: {self.output_depth}, expected input depth: {self.expected_depth}") | ||
|
||
self.cv_bridge = CvBridge() | ||
self.depth_image_pub = rospy.Publisher("depth/image_rect", Image, queue_size=2) | ||
self.depth_ci_pub = rospy.Publisher("depth/camera_info", CameraInfo, queue_size=2) | ||
self.rgb_ci_pub = rospy.Publisher("rgb/camera_info", CameraInfo, queue_size=2) | ||
|
||
self.received_msg = None | ||
|
||
# TODO(lucasw) use time sync subscriber | ||
self.depth_sub = rospy.Subscriber("depth_registered/image_rect", Image, self.depth_callback, queue_size=2) | ||
self.ci_sub = rospy.Subscriber("depth_registered/camera_info", CameraInfo, self.ci_callback, queue_size=2) | ||
|
||
ci_msg = CameraInfo() | ||
wd = 3 | ||
ht = 3 | ||
ci_msg.header.frame_id = "station1" | ||
ci_msg.height = ht | ||
ci_msg.width = wd | ||
ci_msg.distortion_model = "plumb_bob" | ||
|
||
cx = 1.5 | ||
cy = 1.5 | ||
fx = 1.5 | ||
fy = 1.5 | ||
ci_msg.K = [fx, 0.0, cx, | ||
0.0, fy, cy, | ||
0.0, 0.0, 1.0] | ||
ci_msg.R = [1, 0, 0, | ||
0, 1, 0, | ||
0, 0, 1] | ||
ci_msg.P = [fx, 0.0, cx, 0.0, | ||
0.0, fy, cy, 0.0, | ||
0.0, 0.0, 1.0, 0.0] | ||
|
||
depth = np.ones((ht, wd, 1), np.float32) * self.output_depth | ||
rospy.loginfo(depth) | ||
|
||
depth_msg = self.cv_bridge.cv2_to_imgmsg(depth, "32FC1") | ||
rgb_ci_msg = copy.deepcopy(ci_msg) | ||
rgb_ci_msg.header.frame_id = "station2" | ||
depth_msg.header = ci_msg.header | ||
|
||
for i in range(6): | ||
rospy.loginfo(f"{i} waiting for register connections...") | ||
num_im_sub = self.depth_image_pub.get_num_connections() | ||
num_ci_sub = self.depth_ci_pub.get_num_connections() | ||
num_rgb_ci_sub = self.rgb_ci_pub.get_num_connections() | ||
rospy.sleep(1) | ||
if num_im_sub > 0 and num_ci_sub > 0 and num_rgb_ci_sub > 0: | ||
break | ||
|
||
self.assertGreater(self.depth_image_pub.get_num_connections(), 0) | ||
self.assertGreater(self.depth_ci_pub.get_num_connections(), 0) | ||
self.assertGreater(self.rgb_ci_pub.get_num_connections(), 0) | ||
rospy.sleep(1.0) | ||
|
||
self.count = 0 | ||
rospy.loginfo("publishing depth and ci, wait for callbacks") | ||
for i in range(4): | ||
stamp = rospy.Time.now() | ||
ci_msg.header.stamp = stamp | ||
rgb_ci_msg.header.stamp = stamp | ||
depth_msg.header.stamp = stamp | ||
self.depth_image_pub.publish(depth_msg) | ||
self.depth_ci_pub.publish(ci_msg) | ||
self.rgb_ci_pub.publish(rgb_ci_msg) | ||
rospy.sleep(0.1) | ||
|
||
while i in range(6): | ||
if self.count > 1: | ||
break | ||
rospy.sleep(1) | ||
rospy.loginfo("done waiting") | ||
|
||
self.assertIsNotNone(self.received_msg, "no depth message received") | ||
registered_depth = self.cv_bridge.imgmsg_to_cv2(self.received_msg, "32FC1") | ||
# the edges of the expected 3x3 image may be nans, but the center should be valid | ||
valid_depth = registered_depth[1, 1] | ||
self.assertAlmostEqual(valid_depth, self.expected_depth, places=1) | ||
|
||
def depth_callback(self, msg): | ||
rospy.loginfo("received depth") | ||
self.received_msg = msg | ||
self.count += 1 | ||
|
||
def ci_callback(self, msg): | ||
rospy.logdebug("received camera info") | ||
|
||
|
||
if __name__ == "__main__": | ||
node_name = 'test_register' | ||
rospy.init_node(node_name) | ||
# rostest.rosrun("depth_image_proc", node_name, sys.argv) | ||
rostest.rosrun("depth_image_proc", node_name, TestRegister) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could keep track of the depth values at each corner of the square and interpolate between them