39 import roslib; roslib.load_manifest(
'velma_task_cs_ros_interface')
44 from velma_common
import *
45 from rcprg_ros_utils
import exitError
47 if __name__ ==
"__main__":
49 rospy.init_node(
'head_test', anonymous=
False)
53 print "This test/tutorial executes simple motions"\
56 print "Running python interface for Velma..." 57 velma = VelmaInterface()
58 print "Waiting for VelmaInterface initialization..." 59 if not velma.waitForInit(timeout_s=10.0):
60 print "Could not initialize VelmaInterface\n" 62 print "Initialization ok!\n" 64 diag = velma.getCoreCsDiag()
65 if not diag.motorsReady():
66 print "Motors must be homed and ready to use for this test." 69 print "Motors must be enabled every time after the robot enters safe state." 70 print "If the motors are already enabled, enabling them has no effect." 71 print "Enabling motors..." 72 if velma.enableMotors() != 0:
75 print "Moving to the current position..." 76 js_start = velma.getLastJointState()
77 velma.moveJoint(js_start[1], 0.5, start_time=0.5, position_tol=15.0/180.0*math.pi)
78 error = velma.waitForJoint()
80 print "The action should have ended without error, but the error code is", error
83 print "moving head to position: 0" 85 velma.moveHead(q_dest, 1.0, start_time=0.5)
86 if velma.waitForHead() != 0:
92 print "moving head to position: left" 94 velma.moveHead(q_dest, 3.0, start_time=0.5)
95 if velma.waitForHead() != 0:
101 print "moving head to position: left down" 103 velma.moveHead(q_dest, 2.0, start_time=0.5)
104 if velma.waitForHead() != 0:
110 print "moving head to position: right down" 111 q_dest = (-1.56, 0.7)
112 velma.moveHead(q_dest, 5.0, start_time=0.5)
113 if velma.waitForHead() != 0:
119 print "moving head to position: right" 121 velma.moveHead(q_dest, 2.0, start_time=0.5)
122 if velma.waitForHead() != 0:
128 print "moving head to position: 0" 130 velma.moveHead(q_dest, 3.0, start_time=0.5)
131 if velma.waitForHead() != 0:
def isHeadConfigurationClose(q1, q2, tolerance=0.1)
Check if two configurations of robot neck are close within tolerance.