Using SetForce and GetJoint() Function

asked 2019-04-14 22:51:04 -0500

mukund24 gravatar image

updated 2019-04-15 20:54:42 -0500

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);


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:

edit retag flag offensive close merge delete


@kumpakri could you have a look at this? Turns out I was running the wrong plugin when I said it worked

mukund24 gravatar imagemukund24 ( 2019-04-14 22:52:51 -0500 )edit
mukund24 gravatar imagemukund24 ( 2019-04-15 09:23:12 -0500 )edit

Can you update this question with your SDF model? That might help with diagnosing the problem.

josephcoombe gravatar imagejosephcoombe ( 2019-04-15 14:18:55 -0500 )edit

@josephcoombe, I'm using the Polaris Ranger XP900 file from the model database:

mukund24 gravatar imagemukund24 ( 2019-04-15 18:29:12 -0500 )edit

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 for Assertion px != 0 failed.) The name of the model is already provided by the this->model->GetName() and you need to devide the model name and the joint name with :: sign. Just as in you question description.

kumpakri gravatar imagekumpakri ( 2019-04-17 03:12:29 -0500 )edit

@kumpakri, I'd already tried doing what you have suggested, but the same error showed up.

mukund24 gravatar imagemukund24 ( 2019-04-17 09:20:31 -0500 )edit