3 from __future__
import print_function
7 import geometry_msgs.msg
8 from geometry_msgs.msg
import Twist
14 Hello User! Lookin' good today 15 Reading from Keyboard, Publishing to keys/cmd_vel 20 NAVIGATION INSTRUCTIONS 30 K : reset speed to default 38 screenMsg = screenMsg.split(
"\n")
69 print (
"Shutting Down!")
71 if __name__==
"__main__":
73 pub = rospy.Publisher(
'keys/cmd_vel', Twist, queue_size = 3)
74 rospy.init_node(
'key_read_node')
79 screen = pygame.display.set_mode((600,600))
85 n = len(screenMsg) + 1
94 while (
not rospy.is_shutdown()
and running):
95 screen.fill((254,128,195))
96 basicfont = pygame.font.SysFont(
None, 38)
99 for word
in screenMsg:
100 text = basicfont.render(word,
True, (0, 0, 0))
101 textrect = text.get_rect()
102 textrect.centerx = screen.get_rect().centerx
103 textrect.centery = count * screen.get_rect().height / n
104 screen.blit(text, textrect)
107 pygame.display.flip()
110 for event
in pygame.event.get():
112 if event.type == pygame.QUIT:
115 if event.type == pygame.KEYDOWN:
117 if event.key == pygame.K_p:
120 rospy.on_shutdown(shutdownHook)
121 if event.unicode
in keyBindings.keys():
122 x = keyBindings[event.unicode][0]
123 y = keyBindings[event.unicode][1]
124 th = keyBindings[event.unicode][2]
125 if (event.unicode
in speedBindings.keys()):
126 if event.key == pygame.K_k:
129 speed = speed * speedBindings[event.unicode]
131 if event.type == pygame.KEYUP:
139 twist.linear.x = x * speed; twist.linear.y = y * speed;
140 twist.angular.z = th*turnspeed;
143 twist.angular.x = 0; twist.angular.y = 0;
149 rospy.on_shutdown(shutdownHook)