def main(args): pi = 3.1416 rospy.init_node('gummi', anonymous=True) r = rospy.Rate(60) cocont = 0.25 #desired = (0.77, 0.69, 0.64, 0.72, 0.10, -0.05, 0.01) #desired = (0.0, 0.9, 0.25, 0.0, -0.2, 0.0, 0.01) #desired = (0.0, 0.9, 0.3, 0.0, 0.15, 0.0, 0.01) desired = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) gummi = Gummi() print('WARNING: Moving joints sequentially to equilibrium positions.') gummi.doGradualStartup() print('WARNING: Moving to resting pose, hold arm!') rospy.sleep(3) gummi.goRestingPose(True) for i in range(0, 400): gummi.goRestingPose(False) r.sleep() print("GummiArm is live!") gummi.setCocontraction(cocont, cocont, cocont, cocont, 0.4) print("Moving arm into place.") gummi.goTo(desired, True) for i in range(0, 400): gummi.goTo(desired, False) r.sleep() print("Setting co-contraction - hold arm.") for i in range(0, 200): gummi.servoTo(desired) r.sleep() print("Test started, cocontraction: " + str(cocont) + ".") while True: gummi.passiveHold() r.sleep()
def main(args): pi = 3.1416 rest = (0.0, -0.34770231192074535, 0.03579288505066496, 0.0030679615757712823, -0.7465373167710121, -1.55, -0.0051132692929521375) mid = (0.0, 0.10737865515199489, 0.14317154020265985, -0.21475731030398976, -0.4755340442445488, -1.55, 0.0) desired = (0.3170226961630325, 0.5777994301035916, 0.22498384888989406, -0.2684466378799872, -0.3681553890925539, -1.25, 0.0) width = 1.2 #0.6 frequency = 4.5 rospy.init_node('gummi', anonymous=True) r = rospy.Rate(60) hand_shake = HandShake() gummi = Gummi() gummi.setCocontraction(0.6, 0.6, 0.6, 0.6, 0.6) print('WARNING: Moving joints sequentially to equilibrium positions.') gummi.doGradualStartup() print('WARNING: Moving to resting pose, hold arm!') rospy.sleep(1) for i in range(0, 400): gummi.goTo(rest, False) r.sleep() print("GummiArm is live!") do_shake_hand = False hand_is_closed = False time_counter = 1 while True: hand_shake.doUpdate() if do_shake_hand: if time_counter < 60: print "Moving, first step" gummi.setCocontraction(0.6, 0.6, 0.85, 0.6, 0.2) gummi.goTo(mid, False) r.sleep() else: if time_counter < 250: print "Moving, second step" gummi.setCocontraction(0.5, 0.4, 0.6, 0.55, 0.2) gummi.goTo(desired, False) # TODO: CALIB r.sleep() else: print "Waiting..." if time_counter < 1150: if not hand_is_closed: if hand_shake.havePersistentTouch(): print "Closing hand" gummi.handClose.servoTo(1.5) elbow_waiting = gummi.elbow.angle.getEncoder() hand_is_closed = True time_counter = 750 else: elbow = elbow_waiting + width / 2 * math.sin( frequency * time_counter / 60.0) gummi.elbow.servoTo(elbow, 0.3) else: if time_counter < 1350: print "Opening hand" gummi.handClose.servoTo(-2.2) hand_is_closed = False else: if time_counter < 1600: print "Go to rest" gummi.setCocontraction(0.6, 0.6, 0.6, 0.6, 0.6) gummi.goTo(rest, False) else: print "Done with hand shake" hand_shake.done() do_shake_hand = False time_counter = 0 time_counter = time_counter + 1 else: print "Passive hold" gummi.passiveHold() if hand_shake.haveNewPerson(): if hand_shake.havePersistentPerson(): do_shake_hand = True print "Do hand shake" r.sleep()