How to show images in Gazebo to a web or application?
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!
Asked by Han on 2020-07-23 03:16:33 UTC
Answers
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();
}
Asked by ahcorde on 2020-07-27 09:16:53 UTC
Comments