Robotics StackExchange | Archived questions

SetMaxForce deprecated in gazebo 5.0

Hi,

In Gazebo 5.0 when using physics::Joint::SetMaxForce I got this warning :

virtual void gazebo::physics::Joint::SetMaxForce(unsigned int, double)’ is deprecated (declared at /usr/include/gazebo-5.0/gazebo/physics/Joint.hh:365) [-Wdeprecated-declarations] joints[i]->SetMaxForce(0, 1.0);

And when I remove it and use only Joint::SetVelocity the robot starts to do random moves and fly even with 0.1 rad/s

How to fix this ?

UP DATE

here is the source code

#include <boost/bind.hpp>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
#include <stdio.h>

namespace gazebo
{   
  class SetJoints : public ModelPlugin
  {
    public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/) 
    {

      this->model = _parent;

      this->updateConnection = event::Events::ConnectWorldUpdateBegin(
          boost::bind(&SetJoints::OnUpdate, this, _1));
    }
    public: void OnUpdate(const common::UpdateInfo & /*_info*/)
    {

      //this->model->GetJoint("my_joint")->SetParam("fmax", 2, 1.1);
      //this->model->GetJoint("my_joint")->SetParam("vel", 2,6.0 );

      this->model->GetJoint("my_joint")->SetMaxForce(2,1);
      this->model->GetJoint("my_joint")->SetVelocity(2,4);

    }


    private: physics::ModelPtr model;
    private: event::ConnectionPtr updateConnection;

  };
  GZ_REGISTER_MODEL_PLUGIN(SetJoints)
}

Asked by djou07 on 2015-04-13 12:18:07 UTC

Comments

Just moving my comment up here— I'm not sure what the answer is, but I'm seeing a similar result with the Jackal simulator: URDF which once worked with Gazebo 2 is now flying all over the place on Gazebo 5. cf. http://answers.gazebosim.org/question/8994/jackal-simulator-flipping-and-flying-in-gazebo-51/

Asked by mikepurvis on 2015-07-03 11:38:03 UTC

Answers

From another question, try:

joint->SetParam("max_force", index, maxForce);
joint->SetParam("vel", index, velocity);

Asked by scpeters on 2015-04-14 02:39:26 UTC

Comments

I tried this and it did not work, the robot dont move, maybe because the joints have no friction ?

Asked by djou07 on 2015-04-14 04:19:28 UTC

should I go back to gazebo 4

Asked by djou07 on 2015-04-14 08:55:47 UTC

check the warnings (run with --verbose) It should works fine, however I think joint->SetParam("max_force", index, maxForce); should be joint->SetParam("fmax", index, maxForce); according to previous answers

Asked by clynamen on 2015-04-14 09:17:56 UTC

thanks for your comment. Same thing it does not work

Asked by djou07 on 2015-04-14 09:55:53 UTC

right, I screwed up the key in my example; sorry it's not working though. When do you call SetMaxForce?

Asked by scpeters on 2015-04-14 18:25:14 UTC

in the OnUpdate loop right before SetVelocity

Asked by djou07 on 2015-04-15 05:05:16 UTC

Hm...I would have expected it to work.

Asked by scpeters on 2015-04-15 12:45:35 UTC

yeah, but I got the warning... I updated the answer, I think im gonne install gazebo version 4 because I I am limited in time

Asked by djou07 on 2015-04-16 02:04:53 UTC