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

Gazebo model_states

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

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::Duration(1,0).sleep();
    ROS_INFO("OUT ");

    ros::spin();

  return 0;
}

And the resoult is:

./bin/listener

[ 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

Regars.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

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

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
0

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

Sanxano gravatar image

Thank you very much, I was going crazy.

edit flag offensive delete link more

Comments

3

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 -0600 )edit

Question Tools

Stats

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

Seen: 2,090 times

Last updated: Nov 05 '12