Gazebo | Ignition | Community
Ask Your Question
0

How to show images in Gazebo to a web or application?

asked 2020-07-23 03:16:33 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hi

I'm trying to develop a software which is able to show simulations from gazebo in real time. The problem is how to get the data from gazebo? Can gazebo output every frame of the simulation in real time? Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-07-27 09:16:53 -0600

ahcorde gravatar image

Hello,

This snippet of code shows how to subscribe to a camera topic generated by Gazebo using gazebo::Transport::node

In the callback function void cb(ConstImageStampedPtr &_msg) you can handle the data from the image:

gazebo::transport::NodePtr gz_node;

// Function is called everytime a message is received.
void cb(ConstImageStampedPtr &_msg)
{
}

/////////////////////////////////////////////////
int main(int argc, char ** argv)
{
  // Load gazebo
  gazebo::client::setup(argc, argv);

  // Gazebo transport
  gz_node = gazebo::transport::NodePtr(new gazebo::transport::Node());
  gz_node->Init();

  // Listen to Gazebo world_stats topic
  gazebo::transport::SubscriberPtr sub = gz_node->Subscribe("~/camera/link/camera/image", cb);

  while (true)
    gazebo::common::Time::MSleep(10);

  // Make sure to shut everything down.
  gazebo::client::shutdown();
}
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-07-23 03:16:33 -0600

Seen: 40 times

Last updated: Jul 27