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

starting get_link_state topic ?

asked 2013-04-07 21:27:47 -0600

hvn gravatar image

Using Electric and assuming you can only subscribe to a topic or use it as a serviceClient if it is visible using "rostopic echo", which launcher should I use to see /gazebo/get_link_state? As links I now have /gazebo/link_states, ~model_states, ~set_link_state and ~set_model_state/. The ~get_link_state topic is not shown.

Thank you.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-04-08 04:53:05 -0600

prasanna.kumar gravatar image

updated 2013-04-09 22:27:09 -0600

/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.

edit flag offensive delete link more
0

answered 2013-04-08 20:49:31 -0600

hvn gravatar image

updated 2013-04-08 21:03:34 -0600

@prasannakumar: Since my reply is too large to put into a comment, I do it in an answer. So here goes:

OK, so I won't see /gazebo/get_link_state in the topic list. In C++, I'm using

ros::ServiceClient gls_client = n.serviceClient<gazebo_msgs::getlinkstate>("/gazebo/get_link_state/pose"); if (gls_client.exists()) { ROS_INFO("link state exists"); gls_request.link_name = right_hand; gls_request" } else { ROS_INFO("Something went wrong"); }

This ends in getting "Something went wrong". So where do I go wrong?

Thank you.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-04-07 21:27:47 -0600

Seen: 738 times

Last updated: Apr 09 '13