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

implementing turtlebot bumper sensor

asked 2012-08-27 08:37:40 -0500

Arash gravatar image

updated 2014-01-28 17:13:28 -0500

ngrennan gravatar image

Hi,

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);
    }else
            publish(angular_,linear_):
loop_rate.sleep();
ros::spin();
}

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-02-13 03:23:18 -0500

teichel1 gravatar image

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

edit flag offensive delete link more

Comments

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="">

Mai gravatar image Mai  ( 2014-12-03 00:15:29 -0500 )edit

Question Tools

Stats

Asked: 2012-08-27 08:37:40 -0500

Seen: 2,481 times

Last updated: Feb 13 '13