turtlrbot1 bumper

asked 2013-11-20 22:29:47 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hello, i am going to use bumper with Turtlebot1

Although i ran the source as below, i couldn't run the callback function. Why?


#!/usr/bin/env python    
import roslib; roslib.load_manifest('enclosure_escape')    
import rospy   
from geometry_msgs.msg import Twist    
from create_node.msg import TurtlebotSensorState

bump = False

def callback(TurtlebotSensorState):    
   global bump   
   bump = TurtlebotSensorState.bumps_wheeldrops > 0       
def hello_create():    
   pub = rospy.Publisher('mobile_base/commands/velocity', Twist)    
   rospy.Subscriber('/create_node/sensor_state', TurtlebotSensorState, callback)    
   rospy.init_node('hello_create')    
   global bump    
   twist = Twist()

   while not rospy.is_shutdown():    
       if bump:   
           rospy.loginfo("bump")    
           twist.linear.x = 0; twist.linear.y = 0; twist.linear.z = 0   
           twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = 0    
           bump = False    
       else:
           rospy.loginfo("go")    
           twist.linear.x = 0.1; twist.linear.y = 0; twist.linear.z = 0    
           twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = 0.1    
       pub.publish(twist)    
       rospy.sleep(0.25)

if __name__ == '__main__':    
   try:    
       hello_create()    
   except rospy.ROSInterruptException: pass
edit retag flag offensive close merge delete