Rosanswers logo


I'm trying to subscribe to turtlebotSensorState to get bumps_wheeldrops. I think I've done everything right but in gazebo simulator when the robot hits an object it's not stopping. below is my codes, any help is appreciated. Also,it doesn't matter that I put the callback before main, does it?

#include turtlebot_node/TurtlebotSensorState.h>

#include ros/rate.h>

void callback01(const turtlebot_node::TurtlebotSensorState::ConstPtr& msg){
turtlebot_node::TurtlebotSensorState bumperState = msg->bumps_wheeldrops;
//this part goes to main:
ros::Subscriber sens_sub_ = n.subscribe<turtlebot_node::TurtlebotSensorState>("sensor_state", 1000, callback01);

ros::Rate loop_rate(10);
while (ros::ok()){
    if (bumperState !=0){
            publish (0,0);

Originally posted by Arash on ROS Answers with karma: 11 on 2012-08-27

Post score: 0


1 Answer 1


Rosanswers logo

ros::Subscriber sens_sub_ = n.subscribe<turtlebot_node::TurtlebotSensorState>("sensor_state", 1000, callback01);

this line should have /turtlebot_node/sensor_state

like this

ros::Subscriber sens_sub_ = n.subscribe<turtlebot_node::TurtlebotSensorState>("/turtlebot_node/sensor_state", 1000, callback01);

and as long as your main program can see bumperState

Originally posted by teichel1 with karma: 51 on 2013-02-13

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by Mai on 2014-12-03:
Sorry! I run this example but there is below error. How can I do to fix this problem? thanks :(

/home/mai/catkin_ws/src/second/src/chan.cpp:1:49: fatal error: turtlebot_node/TurtlebotSensorState.h: No such file or directory #include <turtlebot_node/TurtlebotSensorState.h>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.