Gazebo | Ignition | Community
Ask Your Question
1

How to change the light position in world plugin.

asked 2016-01-13 14:16:09 -0500

this post is marked as community wiki

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

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();
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-01-14 11:14:20 -0500

chapulina gravatar image

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);
edit flag offensive delete link more
0

answered 2016-01-14 09:00:03 -0500

Brosseau.F gravatar image

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)

edit flag offensive delete link more

Comments

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

Anshuman gravatar imageAnshuman ( 2016-01-14 19:17:53 -0500 )edit
1

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

chapulina gravatar imagechapulina ( 2016-01-15 00:52:54 -0500 )edit

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

Brosseau.F gravatar imageBrosseau.F ( 2016-01-15 01:38:47 -0500 )edit
chapulina gravatar imagechapulina ( 2016-01-15 01:56:36 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-01-13 14:16:09 -0500

Seen: 1,740 times

Last updated: Jan 14 '16