def openhand(config,hand,amount):
    """Opens the hand of the given Hubo configuration config by the given amount.
    hand is either 'l','r', 'left', or 'right' and amount is in the range [0,1]
    ranging from closed to open.
    """
    if hand!='left' and hand!='right' and hand!='l' and hand != 'r':
        raise ValueError("Invalid hand specified, must be l or r")
    leftdofs = range(14,29)
    rightdofs = range(35,50)
    leftopen = [0.0]*15
    rightopen = [0.0]*15
    leftclose = [-1.0,0.7,0.7]*5
    rightclose = [-1.0,0.7,0.7]*5

    output = config[:]
    dofs = None
    if hand[0]=='l':
        dofs = leftdofs
        vals = [a+amount*(b-a) for (a,b) in zip(leftclose,leftopen)]
    else:
        dofs = rightdofs
        vals = [a+amount*(b-a) for (a,b) in zip(rightclose,rightopen)]
    for (d,v) in zip(dofs,vals):
        assert d < len(config),"Config does not have enough entries"
        output[d] = v
    return output