Ask Your Question

Gazebo model_states

asked 2012-11-05 02:41:20 -0500

Sanxano gravatar image

Hi everyone,

My question is very simple: What I'm doing wrong????

I did a easy subscriptor:

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

void chatterCallback(const gazebo_msgs::ModelState::ConstPtr& msg)
    int i = 0;

    ROS_INFO("I heard: %d", i);

int main(int argc, char **argv)
  ros::init(argc, argv, "listener");

  ros::NodeHandle n;

  ros::Subscriber sub = n.subscribe("gazebo/model_states",1000, chatterCallback);
    ROS_INFO("IN ");
    ROS_INFO("OUT ");


  return 0;

And the resoult is:


[ INFO] [1352123368.021140417]: IN 
[ INFO] [1352123369.264976085, 18.667000000]: OUT 
(.. nothing ..)

While I do: (I obtain a lot of topic)

rostopic echo /gazebo/model_states


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-11-05 03:07:47 -0500

Lorenz gravatar image

You are using the wrong message type when subscribing. The type is ModelStates, not ModelState. Change your include line and the signature of the function chatterCallback and it should work.

edit flag offensive delete link more

answered 2012-11-05 22:52:17 -0500

Sanxano gravatar image

Thank you very much, I was going crazy.

edit flag offensive delete link more



You are welcome. But please do not use answers for comments or discussion. Instead, please either use the comment functionality or edit your original post. This site is not a forum.

Lorenz gravatar image Lorenz  ( 2012-11-05 22:59:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-11-05 02:41:20 -0500

Seen: 1,505 times

Last updated: Nov 05 '12