示例#1
0
文件: render.py 项目: jonkeane/amohs
class specificationError(Exception):
    pass


##### Path to deafult in the base pose to alter #####
baseHCposeFile = path.join(funcs.resources_dir, "fsBaseOpticalClosedToOpen.yml")

##### Establish joint angles for the base hand #####
index = hc.finger(MCP=(180, 5), PIP=180, DIP=180)
middle = hc.finger(MCP=(180, 2), PIP=180, DIP=180)
ring = hc.finger(MCP=(180, -2), PIP=180, DIP=180)
pinky = hc.finger(MCP=(180, -4), PIP=180, DIP=180)
thmb = hc.thumb(CM=hc.joint(dfFlex=15, dfAbd=9, dfRot=27, dfPro=None), MCP=180, IP=180)
wrist = (0, 0, 0)  # the wrist values here are not those in the pose file, these need to be changed in the future

baseHC = hc.armconfiguration(hc.handconfiguration(index, middle, ring, pinky, thmb), wrist)


def ntz(value):
    """Change a none to zero"""
    if value == None:
        value = 0
    return value


def renderImage(hc, imageOutFile, baseHCposeFile=baseHCposeFile, baseHC=baseHC):
    ##### Read in the base pose to alter #####
    baseHCposefile = open(baseHCposeFile, "r")
    baseHCpose = yaml.load(baseHCposefile)
    baseHCposefile.close()
示例#2
0
文件: hs.py 项目: jonkeane/amohs
    def toHandconfigTarget(self):
        handconfig = {
        "index" : None,
        "middle" : None,
        "ring" : None,
        "pinky" : None,
        "thumb" : None
        }
        
        for finger in self.SF.members:
            if finger !=  "thumb":
                handconfig[finger] = hc.finger(
                    MCP=hc.joint(dfFlex=phonoJoints[self.SF.MCP.value],
                             dfAbd=phonoAbduction[finger][self.SF.abd.value]),
                    PIP=hc.joint(dfFlex=phonoJoints[self.SF.PIP.value]),
                    DIP=hc.joint(dfFlex=phonoJoints[self.SF.PIP.value])
                )
            else:
                handconfig[finger] = hc.thumb(
                    MCP=hc.joint(dfFlex=phonoJoints[self.SF.MCP.value]),
                    IP=hc.joint(dfFlex=phonoJoints[self.SF.PIP.value]),
                    CM=hc.joint(
                            dfFlex=phonoAbduction[finger][self.SF.abd.value][self.thumb.oppos.value][0],
                            dfAbd=phonoAbduction[finger][self.SF.abd.value][self.thumb.oppos.value][2],
                            dfRot=phonoAbduction[finger][self.SF.abd.value][self.thumb.oppos.value][1])
                )                
        if self.SSF is not None:
            for finger in self.SSF.members:
                if finger !=  "thumb":
                    handconfig[finger] = hc.finger(
                        MCP=hc.joint(dfFlex=phonoJoints[self.SSF.MCP.value],
                             dfAbd=phonoAbduction[finger][self.SSF.abd.value]),
                    	PIP=hc.joint(dfFlex=phonoJoints[self.SSF.PIP.value]),
                    	DIP=hc.joint(dfFlex=phonoJoints[self.SSF.PIP.value])
                    )
            	else:	
                	handconfig[finger] = hc.thumb(
                    	MCP=hc.joint(dfFlex=phonoJoints[self.SSF.MCP.value]),
                    	IP=hc.joint(dfFlex=phonoJoints[self.SSF.PIP.value]),
                    	CM=hc.joint(                    
                                dfFlex=phonoAbduction[finger][self.SSF.abd.value][self.thumb.oppos.value][0],
                                dfAbd=phonoAbduction[finger][self.SSF.abd.value][self.thumb.oppos.value][2],
                                dfRot=phonoAbduction[finger][self.SSF.abd.value][self.thumb.oppos.value][1])
                    )  

        if self.NSF is not None:
            for finger in self.NSF.members:
                if self.NSF.joints.value == "ext":
                    NSFAbd = "neutralAbducted"
                    NSFAbd = "abducted"
                else:
                    NSFAbd = "adducted"
                if finger !=  "thumb":
                    handconfig[finger] = hc.finger(
                        MCP=hc.joint(dfFlex=phonoJoints[self.NSF.joints.value],
                             dfAbd=phonoAbduction[finger][NSFAbd]),
                        PIP=hc.joint(dfFlex=phonoJoints[self.NSF.joints.value]),
                        DIP=hc.joint(dfFlex=phonoJoints[self.NSF.joints.value])
                        )
                else:
                    handconfig[finger] = hc.thumb(
                        MCP=hc.joint(dfFlex=phonoJoints[self.NSF.joints.value]),
                        IP=hc.joint(dfFlex=phonoJoints[self.NSF.joints.value]),
                    	CM=hc.joint(                    
                                dfFlex=phonoAbduction[finger][NSFAbd]["unopposed"][0],
                                dfAbd=phonoAbduction[finger][NSFAbd]["unopposed"][2],
                                dfRot=phonoAbduction[finger][NSFAbd]["unopposed"][1])
                        )
        # Check!
        return  hc.handconfiguration(handconfig["index"], handconfig["middle"], handconfig["ring"], handconfig["pinky"], handconfig["thumb"] )