Skip to content

Commit

Permalink
moving joy cli into Software
Browse files Browse the repository at this point in the history
  • Loading branch information
liampaull committed May 4, 2019
1 parent b53937e commit 8fc2434
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions misc/virtualJoy/joy_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python
# license removed for brevity
import rospy
import sys

from sensor_msgs.msg import Joy

from __builtin__ import True


def keyCatcher(host):
pub = rospy.Publisher('/'+host+'/joy', Joy, queue_size=1)
rospy.init_node('joy-cli', anonymous=True)

while not rospy.is_shutdown():
direction = raw_input('Enter direction(a,w,s,d)--> ')
if direction == 'w':
axes = [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
elif direction == 's':
axes = [0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
elif direction == 'd':
axes = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0]
elif direction == 'a':
axes = [0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0]
else:
axes = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

msg = Joy(header=None, axes=axes, buttons=None)
pub.publish(msg)
rospy.sleep(0.5)

axes = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
msg = Joy(header=None, axes=axes, buttons=None)
pub.publish(msg)

if __name__ == '__main__':
if len(sys.argv) < 2:
raise Exception("No hostname specified!")
else:
hostname = sys.argv[1]

try:
keyCatcher(host = hostname)
except rospy.ROSInterruptException:
pass

0 comments on commit 8fc2434

Please sign in to comment.