Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Add message type to subscriber and correct message type in call back. check 1,2,3 comments


//2. recieves laserscan message type
void chatterCallback(const sensor_msgs::LaserScan::ConstPtr& msg)
{
    ROS_INFO("I heard: [%s]", msg->seq); // 3.prints sequence number of scan
}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "redirector");
    ros::NodeHandle n;
   //1. add message type sensor_msgs::LaserScan to subbscriber
    ros::Subscriber sub = n.subscribe<sensor_msgs::LaserScan>("lms200", 1000, chatterCallback); 

    ros::spin();
    return 0;
}

Add message type to subscriber and correct message type in call back. check 1,2,3 comments


//2. recieves message of laserscan message type
void chatterCallback(const sensor_msgs::LaserScan::ConstPtr& msg)
{
    ROS_INFO("I heard: [%s]", msg->seq); // 3.prints sequence number of scan
}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "redirector");
    ros::NodeHandle n;
   //1. add message type sensor_msgs::LaserScan to subbscriber
    ros::Subscriber sub = n.subscribe<sensor_msgs::LaserScan>("lms200", 1000, chatterCallback); 

    ros::spin();
    return 0;
}

Add message type to subscriber and correct message type in call back. check 1,2,3 comments


//2. recieves message of laserscan type
void chatterCallback(const sensor_msgs::LaserScan::ConstPtr& msg)
{
    ROS_INFO("I heard: [%s]", msg->seq); msg->header.seq); // 3.prints sequence number of scan
}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "redirector");
    ros::NodeHandle n;
   //1. add message type sensor_msgs::LaserScan to subbscriber
    ros::Subscriber sub = n.subscribe<sensor_msgs::LaserScan>("lms200", 1000, chatterCallback); 

    ros::spin();
    return 0;
}