Calling setModelConfiguration service within a gazebo plugin/controller [closed]
Hi, I'm trying to modify the gazebo_ros_laser plugin simply adding a function (just before the PutLaserData() method) to move the joint in a way that the sensor can tilt a certain angle and I'm using the gazebo set_model_configuration service cause I don't need dynamics. If a create a stand-alone node or I try from the command line it works, but when I try within the controller source file gazebo gets stuck or fails to call the service. If I try with:
this->client_ = this->rosnode_->serviceClient<gazebo_msgs::SetModelConfiguration>("set_model_configuration");
the call fails. With:
this->client_ = this->rosnode_->serviceClient<gazebo_msgs::SetModelConfiguration>("/gazebo/set_model_configuration");
gazebo gets stuck. The function I'm using is this:
void MyClass::UpdateJointPos()
{
unsigned int index = 0;
gazebo_msgs::SetModelConfiguration srv;
srv.request.model_name = this->modelParent->GetName();
srv.request.urdf_param_name = "robot_description";
srv.request.joint_names.assign(1, this->modelParent->GetJoint(index)->GetName());
srv.request.joint_positions.assign(1, this->jpositions[count]);
if (!this->client_.call(srv)) ROS_ERROR("Failed to call the service");
}
I printed the value I send and they are correct. I wonder if I use an incorrect name to call the service but I tried every combination. I tried even to set the joint position by this->modelParent->GetJoint(index)->..something but there is no SetPosition() function or similar. I really need your help.