14 DEFAULT_MOVE_TIME = 1.5
21 import roslib; roslib.load_manifest(
'pioneer_teleop')
24 from geometry_msgs.msg
import Twist
26 rospy.init_node(
'commandline_teleop')
29 direction = sys.argv[1]
30 if (direction !=
"forward")
and (direction !=
"backward")
and (direction !=
"right")
and (direction !=
"left"):
31 print " - Error : incorrect direction " + direction
35 if (len(sys.argv) > 2):
36 speed = float(sys.argv[2])
43 msg =
" (default speed)" 44 elif (speed > MAX_SPEED):
49 if (len(sys.argv) > 3):
50 moveTime = float(sys.argv[3])
54 moveTime = DEFAULT_MOVE_TIME
56 if (direction ==
"forward")
or (direction ==
"backward"):
57 print " >> Move " + str(direction) +
" at speed " + str(speed) + msg +
" for " + str(moveTime) +
" sec\n" 59 print " >> Turn " + str(direction) +
" at speed " + str(speed) + msg +
" for " + str(moveTime) +
" sec\n" 63 rotationalDirection = 0
66 pub = rospy.Publisher(
'cmd_vel', Twist, queue_size=10)
70 if (direction ==
"forward"):
72 elif (direction ==
"backward"):
74 elif (direction ==
"left"):
75 rotationalDirection = 1
76 elif (direction ==
"right"):
77 rotationalDirection = -1
81 twist.linear.x = linearDirection * speed
82 twist.angular.z = rotationalDirection * speed
86 while(t2-t1 < moveTime):