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

Cannot get ROS_INFO output in callback function [closed]

asked 2021-01-17 04:11:33 -0600

mkt1412 gravatar image

Hi, I'm new to ROS and I'm trying to subscribe to the pose of a moving turtle and print it out. I believe I subscribed to the right topic but there is no ouput for ROS_INFO in callback function. Anyone can help? Thanks.

#include <ros/ros.h>
#include <turtlesim/Pose.h> 
void poseCallback(const turtlesim::PoseConstPtr& msg)
{

    ROS_INFO("%f %f %f", msg->x, msg->y, msg->theta);
}

int main(int argc, char** argv)
{

    ros::init(argc, argv, "hw1_turtle2_listener");

    ros::NodeHandle node;
    ros::Subscriber sub = node.subscribe("turtle2/pose", 10, &poseCallback);

    ros::spin();

    eturn 0;
};
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by mkt1412
close date 2021-01-18 01:24:01.367407

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-17 06:58:07 -0600

agutenkunst gravatar image

updated 2021-01-17 06:58:46 -0600

This could have multiple reasons:

  1. The loglevel is configured above INFO so only WARN/ERROR is printed.

  2. Maybe the topic is wrong

    • Check with rostopic list if the topic is available.
  3. The topic is right but there is no data published

    • Use rostopic echo turtle2/pose to see if there is data on the topic
edit flag offensive delete link more

Question Tools

Stats

Asked: 2021-01-17 04:11:33 -0600

Seen: 334 times

Last updated: Jan 17 '21