Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Change link properties programmatically

Hello every one

I want to change position and size of a link programmatically.I tried this code below but when I run it, it gives this error.

THE ERROR

gzserver: /usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr<t>::operator->() const [with T = sdf::Param]: Assertion `px != 0' failed.

THE CODE

 physics::LinkPtr link=this->model->GetLink("box");

 sdf::ElementPtr sdflink=link->GetSDF();

 sdflink->GetAttribute("name")->Set ("newName");

 sdflink->GetElement("pose")->Set(
            math::Pose(math::Vector3(-3, 0, 0), math::Quaternion(0, 0, 0)));

 link->UpdateParameters(sdflink);

What should I do? Thank you in advance!