Error when setting dynamically created joints axis in Gazebo 1.8.0
Hi,
I am using Gazebo 1.8.0, during the simulation I create dynamically joints between objects, but when I set their axis I get the following error (this used to work on older Gazebo versions):
Error [SDF.cc:761] Missing element description for [axis]
gazebo: /usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr<T>::operator->() const [with T = sdf::Element]: Assertion `px != 0' failed.
This happens when I use the SetAxis()
function
math::Vector3 axis;
...
this->myJoint->SetAxis(0, axis);
Without it, the joint creation works without any problems.
I noticed a similar error in this question, not sure if they are related, plus it says that it is fixed since release 1.6.3
UPDATE!!! (the working code, thanks to @scpeters, after adding the Load() function):
// create the joint for the given model
this->myJoint = this->model->GetWorld()->GetPhysicsEngine()->CreateJoint("revolute", this->model);
// attach joint to links
this->myJoint->Attach(spatula_link, palm_link);
// load the joint, and set up its anchor point
this->myJoint->Load(spatula_link, palm_link, math::Pose(spatula_link->GetWorldPose().pos, math::Quaternion()));
// set the axis of revolution
this->myJoint->SetAxis(0, axis);
// set other joint attributes
this->myJoint->SetAttribute("stop_cfm",0, this->stop_cfm);
this->myJoint->SetAttribute("stop_erp",0, this->stop_erp);
this->myJoint->SetAttribute("hi_stop",0, this->hi_stop);
this->myJoint->SetAttribute("lo_stop",0, this->lo_stop);
Thanks,
Andrei