Gazebo | Ignition | Community
Ask Your Question

Is it possible to apply force/Set velocity or set position on ball joint?

asked 2019-11-24 22:50:51 -0500

Suyash gravatar image

updated 2019-11-25 03:50:45 -0500

kumpakri gravatar image


I am using Gazebo 9 and ROS Melodic. I am trying to develop a robot which has 2 ball joints (using an sdf file). I wrote a model plugin for setting force (torque) and position (angular position) for each of these joints using joint->SetForce and joint->SetPosition functions, however, nothing happened. I changed the index from 0 to 1 & 2 but nothing seems to be working. However, when I change the joint type to revolute, I am able to apply force and set position of the joints. Please suggest if I can set the force and position for a ball joint using sdf format and a model plugin or not. If there is no way, what is the alternate of using a ball joint as I need to model a ball joint for my robot and apply torques/change positions and velocities around all the three axes. I was thinking of three revolute joints but that is not working for same parent and child for all the three revolute joints. Below are my code for sdf file and whole code for the plugin. Please let me know if full code for sdf is required. Thank you.

For defining joint in sdf file:

 <joint name='Body_to_RW_Z' type='revolute'>
    <pose frame=''>0 0 0 0 -0 0</pose>
      <xyz>0 0 1</xyz>

Code for plugin:

/#include <functional>
/#include <gazebo/gazebo.hh>
/#include <gazebo/physics/physics.hh>
/#include <gazebo/common/common.hh>
/#include <ignition/math/Vector3.hh>

int i = 0;

namespace gazebo
  class ModelPush : public ModelPlugin
     public: void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
      // Store the pointer to the model
      this->model = _parent;

      // Listen to the update event. This event is broadcast every
      // simulation iteration.
      this->updateConnection = event::Events::ConnectWorldUpdateBegin(
          std::bind(&ModelPush::OnUpdate, this));

    // Called by the world update start event
    public: void OnUpdate()
      // Apply a small linear velocity to the model.
      //this->model->SetLinearVel(ignition::math::Vector3d(0, 0, 0));
      this->model->GetJoint("Body_to_RW_Z")->SetParam("fmax",0, 1000000000);      
      this->model->GetJoint("Body_to_LW_Z")->SetParam("fmax",0, 1000000000);

      if (i < 10)




         // this->model->GetJoint("Body_to_LW_Z")->SetPosition(0,0,false ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-11-25 03:48:36 -0500

kumpakri gravatar image

There is no way how to control a ball joint or get any information about a ball joint. I was looking through the sourcecode of ODE and Gazebo to see what can I do with a ball joint. Turned out there is nothing you can do with it. It does not have any methods for control nor acquiring information about its state.

edit flag offensive delete link more


Thank you for your response. I am now try trying to create two intermediate links with no collision and zero inertia. Through this I am able to define three revolute joints perpendicular to each other. It is working very well with the drawback that I am unable to set force due to zero inertia.

Suyash gravatar imageSuyash ( 2019-11-26 10:34:19 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-11-24 22:50:51 -0500

Seen: 736 times

Last updated: Nov 25 '19