Turtlebot 1 Bumper and IR Sensor Problem
Hi everybody,
Kindly please help me out here. I am trying to access to Bumper and IR sensors on turtlebot1 (roomba500 series). Just would like to know whether I need a launch file to access this sensors? If so,could anybody please advise or give me an example of the launch file. I also put a check point in the call back function to check whether it goes into the loop but it didn't print anything on my screen as shown below. Follow is my source code that I used:
#include <ros/ros.h>
#include <turtlebot_node/TurtlebotSensorState.h>
#include <geometry_msgs/Twist.h>
#include <ros/rate.h>
#include <iostream>
#include <stdio.h>
using namespace std;
uint8_t bumper;
//define the bumperCallback function
void bumperCallback(const turtlebot_node::TurtlebotSensorState::ConstPtr& msg)
{
cout<<"Check point 11111111111111111"<<endl;
bumper = msg->bumps_wheeldrops;
ROS_INFO("bumper hit. value = [%d]", bumper);
}
//ROS node entry point
int main(int argc, char **argv)
{
ros::init(argc, argv, "turtlebot_test_node");
ros::NodeHandle n;
ros::Subscriber bumperSubscriber = n.subscribe("/turtlebot_node/sensor_state", 1000, bumperCallback);
ros::Publisher velocityPublisher = n.advertise<geometry_msgs::Twist>("cmd_vel", 1);
//create a Twist message to publish the velocity
geometry_msgs::Twist velMessage;
velMessage.linear.x = 0.0;
velMessage.angular.z = 0.0;
//publish the message
velocityPublisher.publish(velMessage);
ros::spin();
return 0;
}
Many thanks!