How to get gazebo topic using c++ and ros ?
Hi, I am using ROS, gazebo and c++ together to perform some tasks. In gazebo I launched "turtlebot_world.launch. It published " /gazebo/default/pose/info " which gives the information of robots position in gazebo. How can I take this topic in c++, does anyone knows ?
Also I have the function below but doesn't take any information or topic:
void subscribe_gazebo_pose()
{
ros::NodeHandle ndh;
ros::ServiceClient gms_c = ndh.serviceClient<gazebo_msgs::GetModelState>("gazebo/default/pose/info");
//gms_c.waitForExistence();
gazebo_msgs::GetModelState getmodelstate;
gms_c.call(getmodelstate);
geometry_msgs::Pose pose;
pose.position.x = getmodelstate.response.pose.position.x;
pose.position.y = getmodelstate.response.pose.position.y;
cout << pose.position.x << endl;
}