6 from geometry_msgs.msg
import TwistStamped
7 from sensor_msgs.msg
import JointState
8 import termios, fcntl, sys, os
12 from std_srvs.srv
import Empty
16 twist_topic=
"/uwsim/g500_C/twist_command" 21 fd = sys.stdin.fileno()
22 oldterm = termios.tcgetattr(fd)
23 newattr = termios.tcgetattr(fd)
24 newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
25 termios.tcsetattr(fd, termios.TCSANOW, newattr)
26 oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
27 fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
30 pubTwist = rospy.Publisher(twist_topic, TwistStamped,queue_size=1)
31 rospy.init_node(
'keyboardCommand_C')
35 while not rospy.is_shutdown():
36 msgTwist = TwistStamped()
44 msgTwist.twist.angular.y=-baseVelocity
46 msgTwist.twist.angular.y=baseVelocity
48 msgTwist.twist.angular.z=baseVelocity
50 msgTwist.twist.angular.z=-baseVelocity
52 msgTwist.twist.linear.x = baseVelocity
54 msgTwist.twist.linear.x = -baseVelocity
56 msgTwist.twist.linear.y = baseVelocity
58 msgTwist.twist.linear.y = -baseVelocity
60 msgTwist.twist.linear.z = baseVelocity
62 msgTwist.twist.linear.z = -baseVelocity
64 msgTwist.twist.angular.x = -baseVelocity
66 msgTwist.twist.angular.x = baseVelocity
71 print "baseVelocity: " , baseVelocity
73 if baseVelocity > 0.1:
77 print "baseVelocity: " , baseVelocity
79 print 'wrong key pressed' 85 pubTwist.publish(msgTwist)
90 termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
91 fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)