Gazebo | Ignition | Community
Ask Your Question

SetMaxForce deprecated in gazebo 5.0

asked 2015-04-13 12:18:07 -0500

djou07 gravatar image

updated 2015-04-16 02:14:12 -0500


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 ?


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



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

edit retag flag offensive close merge delete


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.

mikepurvis gravatar imagemikepurvis ( 2015-07-03 11:38:03 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2015-04-14 02:39:26 -0500

scpeters gravatar image

From another question, try:

joint->SetParam("max_force", index, maxForce);
joint->SetParam("vel", index, velocity);
edit flag offensive delete link more


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

djou07 gravatar imagedjou07 ( 2015-04-14 04:19:28 -0500 )edit

should I go back to gazebo 4

djou07 gravatar imagedjou07 ( 2015-04-14 08:55:47 -0500 )edit

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

clynamen gravatar imageclynamen ( 2015-04-14 09:17:56 -0500 )edit

thanks for your comment. Same thing it does not work

djou07 gravatar imagedjou07 ( 2015-04-14 09:55:53 -0500 )edit

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

scpeters gravatar imagescpeters ( 2015-04-14 18:25:14 -0500 )edit

in the OnUpdate loop right before SetVelocity

djou07 gravatar imagedjou07 ( 2015-04-15 05:05:16 -0500 )edit

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

scpeters gravatar imagescpeters ( 2015-04-15 12:45:35 -0500 )edit

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

djou07 gravatar imagedjou07 ( 2015-04-16 02:04:53 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2015-04-13 12:18:07 -0500

Seen: 1,501 times

Last updated: Apr 16 '15