ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I got it working by using this code. This is for subscribing to the foot bumpers. For subscribing to other sensors should be the same concept.
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "nao_msgs/Bumper.h"
void bumperCallback(const nao_msgs::Bumper::ConstPtr &msg)
{
ROS_INFO("I heard: %u and %u", msg->bumper, msg->state);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "nao_bumper_listener");
ros:: NodeHandle n;
ros::Subscriber bump= n.subscribe("bumper", 1000, bumperCallback);
ros::spin();
return 0;
}
2 | No.2 Revision |
I got it working by using this code. This is for subscribing to the foot bumpers. For subscribing to other sensors should be the same concept.
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "nao_msgs/Bumper.h"
void bumperCallback(const nao_msgs::Bumper::ConstPtr &msg)
{
ROS_INFO("I heard: %u and %u", msg->bumper, msg->state);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "nao_bumper_listener");
ros:: NodeHandle n;
ros::Subscriber bump= n.subscribe("bumper", 1000, bumperCallback);
ros::spin();
return 0;
}