Gazebo does support this functionality for ODE revolute, prismatic, and universal joints refer pull request https://bitbucket.org/osrf/gazebo/pul... for details. This also highlights the interaction between fmax and friction and not to set them at the same time.
To avoid the conflict of setting fmax and friction while maintaining existing functionality I copied SetJointProperties.srv and ODEJointProperties.msg making SetJointFriction.srv and ODEJointFriction.msg
SetJointFriction.srv
string joint_name # name of joint
gazebo_msgs/ODEJointFriction ode_joint_config # access to ODE joint dynamics properties
---
bool success # return true if get successful
string status_message # comments if available
ODEJointFriction.msg
# access to low level joint properties, change these at your own risk
float64[] friction # joint friction
gazebo_ros_api_plugin.cpp was modified by copying setJointProperties() to create
bool GazeboRosApiPlugin::setJointFriction(gazebo_msgs::SetJointFriction::Request &req,
gazebo_msgs::SetJointFriction::Response &res)
{
/// @todo: current settings only allows for setting of 1DOF joints (e.g. HingeJoint and SliderJoint) correctly.
gazebo::physics::JointPtr joint;
#if GAZEBO_MAJOR_VERSION >= 8
for (unsigned int i = 0; i < world_->ModelCount(); i ++)
{
joint = world_->ModelByIndex(i)->GetJoint(req.joint_name);
#else
for (unsigned int i = 0; i < world_->GetModelCount(); i ++)
{
joint = world_->GetModel(i)->GetJoint(req.joint_name);
#endif
if (joint) break;
}
if (!joint)
{
res.success = false;
res.status_message = "SetJointFriction: joint not found";
return true;
}
else
{
for(unsigned int i=0;i< req.ode_joint_config.friction.size();i++)
joint->SetParam("friction",i,req.ode_joint_config.friction[i]);
res.success = true;
res.status_message = "SetJointFriction: properties set";
return true;
}
}
finally, duplicate the service advertisers