Using SetForce and GetJoint() Function
I'm trying to use the SetForce() function on my sdf model using a plugin, on a particular joint using the following commands:
std::string joint1 = this->model->GetName() + "::" + "rear_left_wheel_joint";
physics::JointPtr rear_left_wheel_joint=this->model->GetJoint(joint1);
rear_left_wheel_joint->SetForce(0,20.0);
While running this plugin on my sdf model, I keep getting this error:
gzserver: /usr/include/boost/smart_ptr/shared_ptr.hpp:648: typename boost::detail::sp_member_access<t>::type boost::shared_ptr<t>::operator->() const [with T = gazebo::physics::Joint; typename boost::detail::sp_member_access<t>::type = gazebo::physics::Joint*]: Assertion `px != 0' failed.
I couldn't find much documentation for this error online; could someone please help me with this?
Running gazebo 7.14 and ubuntu 16.04
Plugin code:
@kumpakri could you have a look at this? Turns out I was running the wrong plugin when I said it worked
C:\fakepath\throttle_plugin2.cc - plugin code
Can you update this question with your SDF model? That might help with diagnosing the problem.
@josephcoombe, I'm using the Polaris Ranger XP900 file from the model database: https://bitbucket.org/osrf/gazebo_mod...
Your plugin has this line
std::string joint = this->model->GetName()+ "polaris_ranger_xp900" + "rear_left_wheel_joint" ;
The"polaris_ranger_xp900"
substring is what cases the plugin not to find the joint (There forAssertion px != 0 failed.
) The name of the model is already provided by thethis->model->GetName()
and you need to devide the model name and the joint name with::
sign. Just as in you question description.@kumpakri, I'd already tried doing what you have suggested, but the same error showed up.