Robotics StackExchange | Archived questions

irobot_create bumper

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

Asked by choi woo young on 2013-11-22 04:36:25 UTC

Comments

Not enough information. No error or description of how to reproduce.

Asked by tfoote on 2014-10-13 20:12:19 UTC

Answers