ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

/gazebo/get_link_state is not a topic but a service. You can use it like this: rosservice call gazebo/get_link_state '{link_name: cup, reference_frame: world}' See this page for more info.

click to hide/show revision 2
updated to answer the comment

/gazebo/get_link_state is not a topic but a service. You can use it like this: rosservice call gazebo/get_link_state '{link_name: cup, reference_frame: world}' See this page for more info.

Update:

@hvn You have errors in your code: Try this code, it works. I got the output "link state exists"

#include "ros/ros.h"
#include "gazebo_msgs/GetLinkState.h"

using namespace std;

int main(int argc, char** argv)
{
ros::init(argc, argv, "forum");
ros::NodeHandle n;
ros::service::waitForService("gazebo/get_link_state");
ros::ServiceClient gls_client = n.serviceClient<gazebo_msgs::GetLinkState>("gazebo/get_link_state");
gazebo_msgs::GetLinkState gls_request;
if (gls_client.exists()) 
{ ROS_INFO("link state exists"); gls_request.request.link_name = string("right_hand"); gls_request.request.reference_frame=string("world"); gls_client.call(gls_request); } 
else 
{ ROS_INFO("Something went wrong"); }
return 0;
}

There is a service named /gazebo/get_link_state but no service name get_link_state/pose and the client call you are making is wrong.