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

ROS Video Plugin for Gazebo - allows displaying an image stream in an OG... #86

Merged
merged 4 commits into from
Jul 29, 2013

Conversation

piyushk
Copy link
Contributor

@piyushk piyushk commented Jul 26, 2013

...RE texture inside gazebo. Also provides a fix for #85.

// Initialize the ROS node and subscribe to cmd_vel
int argc = 0;
char** argv = NULL;
ros::init(argc, argv, "gazebo_ros_video_plugin",
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should not initialize your own ROS node. See the example here

@davetcoleman
Copy link
Collaborator

Looks good otherwise, thanks for adding this!

@piyushk
Copy link
Contributor Author

piyushk commented Jul 29, 2013

Removed ros initialization. Thanks for the pointer!

@piyushk
Copy link
Contributor Author

piyushk commented Jul 29, 2013

Hmmm. I am facing a couple of problems with this:

  • I am failing the ros::isInitialized check in both the constructor and Load function of the plugin. I am not sure why, as gazebo_ros_api_plugin is already available after running gzserver
  • Should the check for ros initialization be in the constructor or the Load function?

@davetcoleman
Copy link
Collaborator

It should be in the Load function, the example on the tutorial was wrong, my bad!

@@ -0,0 +1,212 @@
/*
* Copyright 2013 Open Source Robotics Foundation
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you change the file name to .cpp to match everything else?

@piyushk
Copy link
Contributor Author

piyushk commented Jul 29, 2013

I'll make the style changes. I am debugging a weird error with the plugin that I found after I removed the initialization call - it seems that Load for this plugin is getting called twice:

  • One of the Loads is successful:
[ INFO] [1375119335.239259291, 0.629000000]: GazeboRosVideo (ns = /robot1/) has started!
  • The other one is not:
[FATAL] [1375119334.310344044]: GazeboRosVideo Plugin (ns = /robot1/). A ROS node for Gazebo has not been initialized, unable to load plugin. Load the Gazebo system plugin 'libgazebo_ros_api_plugin.so' in the gazebo_ros package)

I'll update the pull request later today once I have debugged this error.

@davetcoleman
Copy link
Collaborator

I talked to John just now about this and we tested your code. The problem is that your visual rendering plugin is running for both gzserver and gzclient, which are two different processes. The gzserver already has a ros node initialized, but the gzclient does not. This is the first plugin in gazebo_plugins to be a Visual type, so I didn't realized this would happen but my advice to you to remove the ros::init() was wrong - add that back in :) Maybe name the node "gazebo_client" to indicate what process it belongs to?

@piyushk
Copy link
Contributor Author

piyushk commented Jul 29, 2013

Thanks for the explanation, as I now understand all my observations.

I have updated the code with the style changes. A node is only initialized if necessary, and there is a small hack which attempts to print whether the instance belongs to gzserver or gzclient. It will have to do for now.

The PR is good to merge on my part, let me know if you spot anything amiss.

@davetcoleman
Copy link
Collaborator

I got it fully working on Baxter just now, I'm pretty excited about this new plugin as Rethink will probably us it!

As a side note from @hsu, your implementation as I understand it does not actually write to the textures, it only displays the image in gzclient. Meaning if a camera or a video is made of the simulation, the video stream will not appear. A better future implementation would actually change the link's texture. But this is still really great work!

Could you please document this plugin on the plugins wiki and include an XML example of the necessary gazebo tags? Thanks!

davetcoleman added a commit that referenced this pull request Jul 29, 2013
ROS Video Plugin for Gazebo - allows displaying an image stream in an OG...
@davetcoleman davetcoleman merged commit 7ac775f into ros-simulation:hydro-devel Jul 29, 2013
@piyushk piyushk deleted the add_video_plugin branch July 29, 2013 19:52
@piyushk
Copy link
Contributor Author

piyushk commented Jul 29, 2013

I'll document the plugin. I've got another plugin I want to submit a PR for.

@hsu That's odd. I don't modify the link texture, but the external texture is visible in a camera/video stream (That's what I use it for). See http://farnsworth.csres.utexas.edu/share/gazebo_ros_video_output.png (I've put an output from my webcam on the simulated laptop screen, which is viewed by the camera on the controllable person model).

@davetcoleman
Copy link
Collaborator

bump to document the plugin on the wiki

cohen39 pushed a commit to cohen39/gazebo_ros_pkgs that referenced this pull request Nov 15, 2021
ROS Video Plugin for Gazebo - allows displaying an image stream in an OG...
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.

None yet

2 participants