Created
September 15, 2011 23:07
-
-
Save DTrejo/1220749 to your computer and use it in GitHub Desktop.
fixed the indentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import roslib; roslib.load_manifest('enclosure_escape') | |
import rospy | |
from geometry_msgs.msg import Twist | |
from turtlebot_node.msg import TurtlebotSensorState | |
# global variables | |
bump = False | |
# listen (adapted from line_follower | |
def processSensing(TurtlebotSensorState): | |
global bump | |
bump = TurtlebotSensorState.bumps_wheeldrops > 0 | |
#newInfo = True | |
def hello_create(): | |
pub = rospy.Publisher('/turtlebot_node/cmd_vel', Twist) | |
rospy.Subscriber('/turtlebot_node/sensor_state', TurtlebotSensorState, processSensing) | |
rospy.init_node('hello_create') | |
#listen | |
global bump | |
twist = Twist() | |
while not rospy.is_shutdown(): | |
if bump: | |
str = "hello create, you have bumped into something %s"%rospy.get_time() | |
rospy.loginfo(str) | |
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: | |
str = "hello create, you can spin now %s"%rospy.get_time() | |
rospy.loginfo(str) | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment