Gazebo | Ignition | Community
Ask Your Question
0

Create a camera link inside plugin

asked 2020-04-16 04:47:32 -0500

kumpakri gravatar image

I can see how to create a new link to a robot from Gazebo plugin, but I do not see how to attach a camera to this link. I want to run a plugin that will attach camera to a specified robot and make video as if from the first person perspective as the robot drives around. How can I do that?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-04-16 12:10:19 -0500

nlamprian gravatar image

updated 2020-04-21 05:43:13 -0500

I'm working on such a plugin at the moment, and hopefully I'll release it in the next days, gazebo_video_monitor_plugins. Perhaps, it can fit your use case.

But, more specifically on your question...

As a side note, you don't need a new link. It should be enough to just specify a pose inside the camera description, and attach the camera to an existing link. Although, I'm not entirely sure that this is working properly with the camera sensor. But, that's the idea anyway.

The way to create a sensor is by triggering the createSensor event, where you provide the sensor description, the name of the world is which to create the sensor, and the name and id of the link to which to attach the sensor.

#include <gazebo/common/Events.hh>
#include <gazebo/sensors/SensorFactory.hh>

event::Events::createSensor(sdf->GetElement("sensor"), world->Name(),
                            link->GetScopedName(), link->GetId());

This will be picked up by the sensor manager, which it will take care of the rest.

edit flag offensive delete link more

Comments

How do you get this camera sensor description? The first parameter must be of type sdf::ElementPtr. I haven't found how to create this element with a text description (such as "<sensor name="camera" type="camera">...</sensor>").

kumpakri gravatar imagekumpakri ( 2020-04-17 08:51:18 -0500 )edit
1

I define the camera in the plugin configuration. If you really want to have it defined inside the plugin, you can use sdf::initString.

nlamprian gravatar imagenlamprian ( 2020-04-17 08:58:44 -0500 )edit

@nlamprian Thank you! May I ask you how long it took to create this gazebo video package? I'm just curious. This looks like a lot of work.

kumpakri gravatar imagekumpakri ( 2020-04-22 09:07:53 -0500 )edit

I worked on it sporadically for several weeks. It was quite painful, because of all the different ways that gazebo crashes and misbehaves for no obvious reason, while trying to figure out how everything works. It still doesn't do everything I wanted to implement, but at least it records videos successfully.

nlamprian gravatar imagenlamprian ( 2020-04-22 09:42:27 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-04-16 04:47:32 -0500

Seen: 69 times

Last updated: Apr 21