Skip to content
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

Update ROS interface etc. #49

Merged
merged 34 commits into from
Jul 4, 2019
Merged

Conversation

mintar
Copy link
Contributor

@mintar mintar commented Jun 21, 2019

This is a huge pull request (sorry for that!) that updates the ROS interface among other things. The git history is carefully curated, so for details check the commits contained here. I'm happy to explain in a bit more detail what I changed and why, if you want.

mintar added 28 commits June 13, 2019 09:59
This makes it possible to import the source files without
rospack.get_path(), and should also make it work from the catkin install
space.
By using rospy.myargv(), it becomes possible to use ROS remapping
arguments to remap the topic names.
This code path is never taken, and I'm not sure what will happen with an
all-zero intrinsic matrix, but this commit still changes the line to what
the original author intended.
This enables us to get rid of the global variables and to move the
processing into the image callback in the following commits.
This gets rid of the g_draw global variable
This has the advantage that the processing is event-driven, i.e., an
image is processed as soon as it is received instead of being throttled
by the processing loop frequency. Additionally, it ensures that each
input image is processed at most once, whereas the old code repeatedly
processed the same input image until a new image arrived.
The output message should have the same frame_id and time stamp as the
input message. This makes the "frame_id" parameter superfluous, so this
commit removes it as well.
This makes DOPE work with any ROS camera driver, without having to
specify the camera intrinsics in the config file.
Since DOPE is usually trained on synthetic NDSS data (which is always
rectified), it is strongly suggested to also use a rectified input
topic for inference. If this is not the case for whatever reason, this
commit at least sets the distortion coefficients for solvePnP properly.
The existing camera node doesn't publish a camera_info topic, so it's
not compatible with the previous commits. Also update the README to
suggest existing ROS drivers as alternatives.
Very large input images eat up all the GPU memory and slow down
inference. Also, DOPE seems to work best when the object size (in
pixels) has appeared in the training data. For these reasons,
downscaling large input images improves memory consumption, inference
speed *and* recognition results.
This also has the effect of installing the new dependency vision_msgs.
This allows using any url format that resource_retriever understands,
particularly `package://` URLs, so it becomes possible to load weight
files from other packages than `dope`.
This is useful if the object mesh is rotated differently from the one
the network was trained with.
Without copying the package to the image, the user had to run
"catkin_make" once after the image was built.
Also, now the proper setup.bash is sourced, so the user can directly
type "rosrun dope dope" after building the Docker image.
Rephrase one sentence, fix whitespace
nodes/dope Show resolved Hide resolved
Copy link
Collaborator

@TontonTremblay TontonTremblay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been discussing about the fact of removing webcam.py and we are a little uncertain, because including the script like we did makes it easier for non ROS user to play with the code. Could I propose we update the webcam.py to also publish the camera intrinsic from a yaml file. What do you think?

Otherwise thank you so much for turning the DOPE repo into a proper ROS package :P

readme.md Outdated Show resolved Hide resolved
readme.md Show resolved Hide resolved
readme.md Show resolved Hide resolved
readme.md Show resolved Hide resolved
readme.md Outdated
@@ -94,7 +96,7 @@ This is the official DOPE ROS package for detection and 6-DoF pose estimation of

* To debug in RViz, `rosrun rviz rviz`, then either
* `Add > Image` to view the raw RGB image or the image with cuboids overlaid
* `Add > Pose` to view the object coordinate frame in 3D. If you do not have a coordinate frame set up, you can run this static transformation: `rosrun tf static_transform_publisher 0 0 0 0.7071 0 0 -0.7071 world dope 10`. Make sure that in RViz's `Global Options`, the `Fixed Frame` is set to `world`.
* `Add > Pose` to view the object coordinate frame in 3D. If you do not have a coordinate frame set up, you can run this static transformation: `rosrun tf2_ros static_transform_publisher 0 0 0 0.7071 0 0 -0.7071 world <camera_frame_id>`, where `<camera_frame_id>` is the `frame_id` of your input camera messages. Make sure that in RViz's `Global Options`, the `Fixed Frame` is set to `world`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user now is using a usb_cam we could simply mention to set the usb_cam as the fixed_frame.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I'll update the README to mention that you can simply use <camera_frame_id> as the fixed_frame.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: bfc518f

Copy link
Collaborator

@TontonTremblay TontonTremblay Jun 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reasons when I was testing the code this afternoon I could not put usb_cam or the dope_webcam as my fixed frame in rviz, I am not sure what is going on. After running a fixed frame transform I was able to visualize the poses. When I started rviz alone I do not see world for some reasons...

Here are the transform I had to run:

rosrun tf2_ros static_transform_publisher 0 0 0 0.7071 0 0 -0.7071 world dope_webcam

I was running the dope camera launch file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you solve this issue? I couldn't reproduce.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test it out on a new install of ros and see what is going on there.

@mintar
Copy link
Contributor Author

mintar commented Jun 26, 2019

We have been discussing about the fact of removing webcam.py and we are a little uncertain, because including the script like we did makes it easier for non ROS user to play with the code. Could I propose we update the webcam.py to also publish the camera intrinsic from a yaml file. What do you think?

I've been pondering whether to remove webcam.py before I did it, but in the end I decided to do it because it is a 100% duplicate of all the usb camera drivers in ROS that are out there. If anything, ROS has too many usb cam drivers, not too few. :)

If you prefer though, we could bring back the webcam.py node and update it. This is what would need to be done:

  • start a CameraInfoManager to handle most of the camera_info stuff for us (load the camera intrinsics from file, provide a set_camera_info service so that it works with camera_calibration)
  • read a parameter called ~camera_info_url and pass it to CameraInfoManager
  • whenever publishing an image, also call CameraInfoManager.getCameraInfo() and publish that as well

It's really easy and not a lot of work. I just don't see how this provides any extra value over using an existing ROS node, but it's up to you to decide. Please also take the new tutorial into account, which also explains how to start the usb_cam node: e8750f5

@mintar
Copy link
Contributor Author

mintar commented Jun 28, 2019

Never mind, I've brought the camera node back to life and added support for camera_info, as outlined above. One thing that I like about DOPE is that it was so easy to set up and use, so we should keep it that way. :)

readme.md Outdated
@@ -15,7 +15,6 @@ This is the official DOPE ROS package for detection and 6-DoF pose estimation of
We have tested on Ubuntu 16.04 with ROS Kinetic with an NVIDIA Titan X with python 2.7. The code may work on other systems.
If you do not have the full ROS install, you may need to install some packages, *e.g.*,
```
apt-get install ros-kinetic-tf2
apt-get install ros-kinetic-cv-bridge
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to install ros-kinetic-camera-info-manager-py

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to add this one: apt-get install ros-kinetic-vision-msgs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All documented in the README now: 7f9e1fe

readme.md Outdated
@@ -94,7 +96,7 @@ This is the official DOPE ROS package for detection and 6-DoF pose estimation of

* To debug in RViz, `rosrun rviz rviz`, then either
* `Add > Image` to view the raw RGB image or the image with cuboids overlaid
* `Add > Pose` to view the object coordinate frame in 3D. If you do not have a coordinate frame set up, you can run this static transformation: `rosrun tf static_transform_publisher 0 0 0 0.7071 0 0 -0.7071 world dope 10`. Make sure that in RViz's `Global Options`, the `Fixed Frame` is set to `world`.
* `Add > Pose` to view the object coordinate frame in 3D. If you do not have a coordinate frame set up, you can run this static transformation: `rosrun tf2_ros static_transform_publisher 0 0 0 0.7071 0 0 -0.7071 world <camera_frame_id>`, where `<camera_frame_id>` is the `frame_id` of your input camera messages. Make sure that in RViz's `Global Options`, the `Fixed Frame` is set to `world`.
Copy link
Collaborator

@TontonTremblay TontonTremblay Jun 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reasons when I was testing the code this afternoon I could not put usb_cam or the dope_webcam as my fixed frame in rviz, I am not sure what is going on. After running a fixed frame transform I was able to visualize the poses. When I started rviz alone I do not see world for some reasons...

Here are the transform I had to run:

rosrun tf2_ros static_transform_publisher 0 0 0 0.7071 0 0 -0.7071 world dope_webcam

I was running the dope camera launch file.

@TontonTremblay
Copy link
Collaborator

TontonTremblay commented Jun 29, 2019

Thank you for putting a new webcam node together. I quite like what you did and I agree with you about ROS not needing a new camera node. The webcam tutorial is quite extensive, thank you. Once we update the requirements in the readme and in the docker file I think we should be good to go for the merge.

@mintar
Copy link
Contributor Author

mintar commented Jun 29, 2019

The requirements in the docker file are handled by the rosdep install line; they are specified in the package.xml. I will add the rosdep install line to the Readme on Monday. Thanks for testing it all!

@mintar
Copy link
Contributor Author

mintar commented Jul 1, 2019

I've updated the installation instructions in the README: 7f9e1fe

From my point, it's ready to merge now.

@mintar
Copy link
Contributor Author

mintar commented Jul 1, 2019

Oh, I think I know what is going on with respect to the fixed frame. When there are no tf transforms, nothing appears in the drop down menu. But you can still enter 'dope_webcam' manually. This is normal.

@TontonTremblay
Copy link
Collaborator

I tested on last time, thank you so much this is a huge update to DOPE.

@TontonTremblay TontonTremblay merged commit f95da03 into NVlabs:master Jul 4, 2019
@mintar mintar deleted the ros_interface branch July 5, 2019 11:50
@mintar
Copy link
Contributor Author

mintar commented Jul 5, 2019

Thank you for taking the time to thoroughly test this PR and iterate on it, much appreciated!

athnzc pushed a commit to athnzc/dope_fork that referenced this pull request Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants