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

Revision history [back]

I think you shouldn't use ros::spinOnce():, use ros::spin(); instead.

I think you shouldn't use ros::spinOnce():, use ros::spin(); instead.

EDIT:

Sorry, didn't see the while... have you tried to add something like loop_rate.sleep() at the end of loop? what is the output of rosnode info YOUR_NODE?

I think you shouldn't use ros::spinOnce():, use ros::spin(); instead.

EDIT:

Sorry, didn't see the while... have you tried to add something like loop_rate.sleep() at the end of loop? what is the output of rosnode info YOUR_NODE?YOUR_NODE?

I think you shouldn't use ros::spinOnce():, use ros::spin(); instead.

EDIT:

Sorry, didn't see the while... have you tried to add something like loop_rate.sleep() at the end of loop? what is the output of rosnode info YOUR_NODE?

EDIT 2:

First check this on your callback arguments:

void chatterCallback(const std_msgs::String**::ConstPtr&** msg)
{
   ROS_INFO("I heard: [%s]", msg->data.c_str());
}

Then, if that doesn't work, use ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback); instead of just invoke the method 'subscribe'

I think you shouldn't use ros::spinOnce():, use ros::spin(); instead.

EDIT:

Sorry, didn't see the while... have you tried to add something like loop_rate.sleep() at the end of loop? what is the output of rosnode info YOUR_NODE?

EDIT 2:

First check this on your callback arguments: arguments (see the ConstPtr&)

void chatterCallback(const std_msgs::String**::ConstPtr&** std_msgs::String::ConstPtr& msg)
{
   ROS_INFO("I heard: [%s]", msg->data.c_str());
}

Then, if that doesn't work, use ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback); instead of just invoke the method 'subscribe'

I think you shouldn't use ros::spinOnce():, use ros::spin(); instead.

EDIT:

Sorry, didn't see the while... have you tried to add something like loop_rate.sleep() at the end of loop? what is the output of rosnode info YOUR_NODE?

EDIT 2:

First check this on your callback arguments (see the ConstPtr&)

void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
   ROS_INFO("I heard: [%s]", msg->data.c_str());
}

Then, if that doesn't work, use ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback); instead of just invoke the method 'subscribe'

This is from tutorial: /** * The subscribe() call is how you tell ROS that you want to receive messages * on a given topic. This invokes a call to the ROS * master node, which keeps a registry of who is publishing and who * is subscribing. Messages are passed to a callback function, here * called chatterCallback. subscribe() returns a Subscriber object that you * must hold on to until you want to unsubscribe. When all copies of the Subscriber * object go out of scope, this callback will automatically be unsubscribed from * this topic. * * The second parameter to the subscribe() function is the size of the message * queue. If messages are arriving faster than they are being processed, this * is the number of messages that will be buffered up before beginning to throw * away the oldest ones. */

I think you shouldn't use ros::spinOnce():, use ros::spin(); instead.

EDIT:

Sorry, didn't see the while... have you tried to add something like loop_rate.sleep() at the end of loop? what is the output of rosnode info YOUR_NODE?

EDIT 2:

First check this on your callback arguments (see the ConstPtr&)

void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
   ROS_INFO("I heard: [%s]", msg->data.c_str());
}

Then, if that doesn't work, use ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback); instead of just invoke the method 'subscribe'

This is from subscriber/publisher tutorial:

/**
   * The subscribe() call is how you tell ROS that you want to receive messages
   * on a given topic.  This invokes a call to the ROS
   * master node, which keeps a registry of who is publishing and who
   * is subscribing.  Messages are passed to a callback function, here
   * called chatterCallback.  subscribe() returns a Subscriber object that you
   * must hold on to until you want to unsubscribe.  When all copies of the Subscriber
   * object go out of scope, this callback will automatically be unsubscribed from
   * this topic.
   *
   * The second parameter to the subscribe() function is the size of the message
   * queue.  If messages are arriving faster than they are being processed, this
   * is the number of messages that will be buffered up before beginning to throw
   * away the oldest ones.
   */

*/