Robotics StackExchange | Archived questions

How to change the light position in world plugin.

Basically I am using get_scene function. I am getting NULL value in World Plugin. But if i used the same function in System Plugin I am getting proper ScenePtr.

rendering::ScenePtr scene = rendering::get_scene();

Asked by Anshuman on 2016-01-13 15:16:09 UTC

Comments

Answers

I would try to use this as a start.

Then use physics::WorldPtr _parent .

_parent->GetModel("yourLightModelName")

and with the result of the previous line use : SetLinkWorldPose (const math::Pose &_pose, const LinkPtr &_link)

Asked by Brosseau.F on 2016-01-14 10:00:03 UTC

Comments

I tried this but I was getting the NULL as a return value

Asked by Anshuman on 2016-01-14 20:17:53 UTC

That's because lights are not models and currently they cannot be attached to models.

Asked by chapulina on 2016-01-15 01:52:54 UTC

Ok my bad. I thought that light could be model because there is a sun model.

Asked by Brosseau.F on 2016-01-15 02:38:47 UTC

Yeah it can be confusing. It has a model.sdf but no tag. See here: https://bitbucket.org/osrf/gazebo_models/src/9f0a80a06cf3cb41f83183d042274bc3a62bb5b8/sun/model.sdf?at=default&fileviewer=file-view-default

Asked by chapulina on 2016-01-15 02:56:36 UTC

I believe it shouldn't be possible to get a scene pointer form a World plugin because the plugin is in the server and the scene in the client.

On Gazebo versions < 7.0, you could publish a message to the ~/light topic with the new pose. (From Gazebo 7 it's ~/light/modify). Something like this:

auto lightPub = this->dataPtr->node->Advertise<msgs::Light>("~/light");

msgs::Light msg;
msg.set_name(<name>);
msgs::Set(msg.mutable_pose(), <pose>);

lightPub->Publish(msg);

Asked by chapulina on 2016-01-14 12:14:20 UTC

Comments