-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollision_signal_node.py
More file actions
executable file
·54 lines (46 loc) · 1.19 KB
/
collision_signal_node.py
File metadata and controls
executable file
·54 lines (46 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python3
import rospy
from std_msgs.msg import Bool
#import getch
import curses
import select
import sys
"""
Press 'x' (lowercase) in the correct terminal to indicate roach collision.
"""
def talker(stdscr):
"""Doesn't publish continuously; relies on latch"""
stdscr.nodelay(1)
pub = rospy.Publisher('collision_signal', Bool, latch=True, queue_size=10)
rospy.init_node('collision_signal_node', anonymous=True)
coll_signal = False
while not rospy.is_shutdown():
keystroke = stdscr.getch()
if keystroke!=-1:
#stdscr.refresh()
#stdscr.move(0,0)
if chr(keystroke)=='x':
coll_signal = True
pub.publish(coll_signal)
if __name__ == '__main__':
try:
curses.wrapper(talker)
except rospy.ROSInterruptException:
pass
"""
import curses
def main(stdscr):
# do not wait for input when calling getch
stdscr.nodelay(1)
while True:
# get keyboard input, returns -1 if none available
c = stdscr.getch()
if c != -1:
# print numeric value
stdscr.addstr(str(c) + ' ')
stdscr.refresh()
# return curser to start position
stdscr.move(0, 0)
if __name__ == '__main__':
curses.wrapper(main)
"""