logo资料库

Inverse Kinematics.pdf

第1页 / 共6页
第2页 / 共6页
第3页 / 共6页
第4页 / 共6页
第5页 / 共6页
第6页 / 共6页
资料共6页,全文预览结束
Triangulation:AnewalgorithmforInverseKinematicsR.M¨uller-Cajar1andR.Mukundan11UniversityofCanterbury,Dept.ComputerScience&SoftwareEngineering.Email:rdc32@student.canterbury.ac.nzAbstractInverseKinematicsisusedincomputergraphicsandroboticstocontrolthepostureofanarticulatedbody.Weintroduceanewmethodutilisingthelawofcosines,whichquicklydeterminesthejointanglesofakinematicchainwhengivenatarget.OurmethodincursalowercomputationalandrotationalcostthanCyclic-CoordinateDescent(CCD),yetisalsoguaranteedtofindasolutionifoneisavailable.Additionallyitmovestheupperjointsofanykinematicchainfirst,thusensuringaclosersimulationofnaturalmovementthanCCD,whichtendstooveremphasisethemovementofjointsclosertotheend-effectorofthekinematicchain.Keywords:InverseKinematics,Cyclic-CoordinateDescent,Triangulation1IntroductionItistrivialtodeterminethefinalpositionofakinematicchainwhengivenasetofjointangles.Thereverse,findingasetofjointanglesgivenatarget,isnon-trivial,asthereareoftenmultipleandsometimesnosolutions.Yetweneedtosolvethisinversekinematicsprobleminanimationandrobotics,whereacharactercomposedofseveralkinematicchainsneedstointeractwithatargetofwhichonlytheCartesiancoordinatesareknown.Currentlymanyalgorithmsthatsolvetheinversekinematicsproblemusenumericalanditerativepro-cedures[1,2,3,4],astheseavoidtheproblemoffindingaclosed-formsolution.AnothercommonmethodistoconstructaJacobianmatrixandtheninvertortransposeit[5].Thismethodtendstobecomputationallyexpensive,especiallyforlargematrices.Weproposeanewalgorithmtofindasolutiontotheinversekinematicsproblem.Thisalgorithm,termedtriangulation,usesthecosineruletocal-culateeachjointanglestartingattherootofthekinematicchain.Itisguaranteedtofindasolutionwhenusedwithunconstrainedjointsandthetargetisinrange.ThismethodiscomparabletoCyclic-CoordinateDescent(CCD),aseachjointattemptstofinditsbestorientationwithoutconsideringtheorientationofanyprecedingjoints.Afterreviewingrelatedworkoninversekinematics,wewilldescribeouralgorithmindetail.Thenwewillreportonaexperimentcomparingtriangula-tiontoCCDwhichcommonlyusedinanimationtoday.Laterwewillgoontodiscussfurtherre-searchonthisalgorithminfuturework.2Background2.1InverseKinematicsThestudyofinversekinematicshasrisenwithrobotics.Thusitisnotsurprisingthatsomeofthefirstsolutionsfortheinversekinematicsproblemwererestrictedtocertaintypesofrobotgeometries[4].Pieperpresentedclosed-forminversekinematicsso-lutionsfortwodifferentclassesofrobotgeome-tries[6],butdidnotdosoforageneralkinematicchain.GuptaandKazerounianpresentedanumer-icalsolutionusingtheNewton-Raphsonmethod,whichcouldbeusedasageneralpurposeinversekinematicssolution[1].Althoughthismethodisguaranteedtoconvergeonasolutionifoneexists,itrequiresseveraliterationstodoso.MethodsrequiringtheJacobianInverseareoftencomputationallyexpensiveandcanbenumericallyunstable[7],astheychangeallthejointvariablessimultaneouslyonapaththatwillmovetheend-effectortowardsthetarget.AlsotheJacobianMa-trixcanbesingular,thusmakingitimpossibletofindaninverseforthesolution.CanutescuandDunbrackreviewtheuseofJacobianMatricesandconsiderthemtohavetoomanydrawbackstouseinproteinstructureprediction[8].Criticallytheyfindthat“placingconstraintsonsomedegreesoffreedommayproduceunpredictableresults.”TheuseofCCDtosolvetheinversekinematicsproblemwasfirstproposedbyWangandChen[9].TheyfoundittobenumericallystableaswellR.M¨uller-Cajar,R.Mukundan,‘Triangulation:ANewAlgorithmforInverseKine-matics’,ProceedingsofImageandVisionComputingNewZealand2007,pp.181–186,Hamilton,NewZealand,December2007.181
Figure1:UsingCCD:Eachjointpcisrotatedsothatθ=0asefficient.Fedorinhiscomparisonofdifferentalgorithmsfoundittobeagoodcompromisebe-tweenspeedandaccuracy[5].Althoughitcantakemanyiterationstoreachthetarget,eachiterationiscomputationallycheap,whichmakesitpossibletousethismethodinrealtimeapplications.FortheabovereasonswehavechosentocompareourmethodtoCCD,asbothmethodsareguar-anteedtoreachorconvergeonthetarget,andarecomputationallyfastenoughtobeusedinrealtime.2.2CyclicCoordinateDescent(CCD)CCDisaniterativemethodthatmovesjointsinoppositeordertotheirimportance.Outerjointsareturnedfirst,whichmakesthemovementseemunnatural,especiallywhenthismethodisusedfortheanimationofhumanoidmodels.Asshowninfigure1,thealgorithmmeasuresthedifferencebetweenajoint’spositionpcandtheend-effectorspositionpe,andajointspositionpcandthetargetspositionpt.Itthencalculatesei-therarotationorquaterniontoreducethisdiffer-encetozero.Itdoesthisforeachjoint,iteratingfromtheend-effectortotheimmobilejointattherootofthekinematicchain.Asthejointsclosetotheend-effectorrotatemorethanthejointsclosetotheimmobilejoint,thekinematicchainwillappeartorollinonitself.Theuseofweightsandspringscanmitigatethiseffect,butespeciallychainswithmanyjointswilltendtohavesomeunnaturalarrangementofanglesuponreachingthetarget(showninfigure2).IfweuserotationtoimplementtheCCD,wesolvethefollowingequationsforeachjoint:cos(θ)=pe−pc||pe−pc||•pt−pc||pt−pc||(1)−→r=pe−pc||pe−pc||×pt−pc||pt−pc||(2)Figure2:UnnaturaljointanglesexhibitedbyCCDafterthefirst(left)andlast(right)iteration.Whereptisthetargetpoint,peistheend-effector,andpcisthecurrentjointthatwearerotating(seefigure1).Thevector−→ristheaxisofrotation.Thuseachjointpcisrotatedbyθabout−→r.Toreachthetargetweiteratethroughthechainrepeatedly,solvingequations(1)and2foreachjoint.Thiswillmovetheendofthekinematicchaintowardsthetarget.ItisworthnotingthatCCDdoesnotattempttofindtheoptimalsolution.WecandefinethecostCofrotatingthekinematicchainusingthesumofalltherequiredrotations.Thisproducesequation(3):C=nXi=1θi(3)AsCCDrotateseachjoint,oftenproducingazig-zagpatternascanbeseeninfigure2,thiscostwillbefarfromtheoptimum.2.3LawofCosinesThisisastatementaboutanygeneraltrianglewhichrelatesthelengthsofitssidestothecosinesofitsangles.Themathematicalformulais:b2=a2+c2−2accosδb(4)Wherea,bandcarethethreesidesofatriangleandδbistheangleoppositesideb.Byusingthedotproductoftwonormalisedvectorstofindtheanglebetweenthemwecanadaptthisformulatofindtheanglesrequiredtocompleteatrianglein3-Dspace.3Triangulation3.1MathematicalBackgroundOurmethodusesthepropertiesoftrianglestoac-curatelycalculatetheanglesrequiredtomovethekinematicchaintowardsthetarget.Forthisal-gorithmwerearrangethelawofcosinestotheformula:182
Figure3:TriangularMethod:Foreachjointawefindtheanglesothatwecanform4abcδb=cos−1(−(b2−a2−c2)2ac)(5)Whereaisthelengthofthejointwearecurrentlymoving,bisthelengthoftheremainingchainandcisthedistancefromthetargettothecurrentjoint.Thiswillgiveustheanglethatthevector−→aneedsinrespecttothevector−→c.Tothencalculatetheangleθasshowninfigure3,weneedtoonlysolvetheequation:θ=cos−1(−→a•−→c)−δb(6)Werotateeachjointbyθcalculatedinequation(6),abouttheaxisofrotation−→rdefinedby:−→r=(−→a×−→c)(7)Intheidealcasethismethodwillrotateonlythefirsttwojoints,leavingtheremainderstraight.Thisisanattempttokeepthecostfunctionshowninequation(3)ataminimum.Thereareseveralspecialcasesthatneedtobedealtwithseparately,wheretheaboveequationscannothold.3.1.1UndefinedAxisofRotationWheneverthetargetvector(−→c)isparalleltothecurrentjointdirection(−→a),thentheaxisofrota-tion(−→r)willbeundefined.Inthiscaseanarbi-trary−→rneedstobechosen.Thiscaneitherbethesameaxisasusedbythelastjoint,oraconstantaxissuchastheverticaly-axis.3.1.2FulltrianglehasbeenformedThisoccursassoonasasequations(6)and(7)weresolvedsuccessfully.Themethodhasjustformedatrianglewiththesidesoflengtha,bandc.Thuswesimplyrotatetheremainingjointssothattheirdirection,−→a,isequaltothetargetvector−→c.Figure4:TriangularMethod:Ifthetargetistooclosetoform4abc,weshortenbtoreflectthelengthofthecollapsedchain3.1.3AtrianglecannotbeformedIfthetargetistoofarawayfromthecurrentjointthenwecannotreachit.Thuswehavec>a+b.Inthiscasethecurrentjointsimplyrotatessothat−→a=−→c.Thisensuresthattheend-effectorcomesasclosetothetargetasispossible.Ifthetargetistooclosetothecurrentjoint,thenwecannotformatrianglewiththesidesa,bandc.Clearlythiswillhappenwheneverc<|a−b|.Wesolvethisproblemusinganaiveapproach:Assumingthatb>aandeachjointcanrotatefreelyabout360owerotatethecurrentjointsothat−→a=−−→c.Mathematicallythisistheeasiestsolution,as:limc→b−aδb=180o(8)Thereforewesimplyfixδbat180o,whenwecannotformatriangle.Thismakesitpossibleforthenextjointtoattemptthesamecalculationfromadifferentposition,withnewvaluesfora,bandc.Ineffect,forjointi+1,ci+1=ci+ai.Ifa>bthenthetargetcannotbereachedandthereisnosolutiontotheproblem.Forconstrainedjointstheabovemethodwillocca-sionallyfailtofindasolution.Thuswechangebtonolongerbethelengthoftheremainingchainwhenstraight,butinsteadthelengthofthechainwhenfullycollapsed.Thiscanbeseeninfigure4,werebisnowmuchshorterthaninfigure3.Ifthetargetisstilltoclosetoformatriangle,thenthereisnosolutiontotheinversekinematicsproblem.Theend-effectoragaincannotreachthetarget.Ifthetargetistoofarfromthecurrentjoint,sothatc>a+b,thenitcannotbereached.Inthis183
casewealsorotatethejointsothatitsdirection,−→a,isequaltothetargetvector−→c.3.2AlgorithmThealgorithmforourmethoditeratesthroughev-eryjointtotheend-effector.Ateachjointwesolvethesamesetofequations,thusbythelastjointasolutionwillhavebeenfoundifpossible.Thuswerequireonlyoneiterationtoreachthetarget.Werotatethemostsignificantjoints(thefurthestawayfromtheend-effector)first,whichissimilartothewayhumansmovetheirarms.Thisisusefulincharacteranimation.foreachJointidoCalculate−→ci,c;ifc≥a+bthen−→ai=−→ci;endelseifc<|a−b|then−→ai=−−→ci;endelseθ=cos−1(−→a•−→c)−cos−1(−(b2−a2−c2)2ac);if−→ai=−−→cior−→ai=−→cithen−→r=(0,1,0);endelse−→r=(−→a×−→c);endrotate(−→aibyθabout−→r);endendAlgorithm1:ThetriangulationalgorithmforakinematicchainwithnoconstraintsThisalgorithmassumesthateachjointistoresitsorientationrelativetothelastjoint,andthencal-culatesitsorientationinglobalspaceasai.Ifthisisnotthecase,thenaftercalculatingthenewaiwewouldneedtoiteratethrougheachjointbelowiandrotatethejointbyθ.Thiswouldalmostsquarethenumberofcalculationsrequired,thusmakingthealgorithmsignificantlylessefficient.Eachjointalsoneedstostorethemaximumlengthofthechaininfrontofit(b).Thiscanbecalculatedonce,asitdoesnotchange.Constraintsthatrestrictthemaximumanglerel-ativetotheprecedingjointcanbeimplementedbycheckingθbeforerotatingandreducingitasrequired.Thismakesthealgorithmsloweraswecannolongersimplyassigntheorientationascanbeseeninthefirsttwoifstatementsinalgorithm1,butinsteadhavetoalwayscalculateθ.Figure5:Thestartingpositionsofbothkinematicchains4ComparingCCDandTriangu-lationInthissectionwerunasmallexperimenttocom-paretwoinversekinematicsalgorithmswitheachother.ThecomparedalgorithmsareCCDandournewmethodcalledtriangulation.4.1ApplicationWecreatedasimpleOpenGLapplicationinC++,whichanimatesasimplekinematicchainwithoneend-effector.Thechainhasalengthof40units,splitintofourjointsoflengthnine,andonejointoflengthfour,orintotwojointsoflengtheighteenandonejointoflengthfour.Thelatterchainhasthejointsrestrictedsothatjointtwo(theelbow)cannotrotatebymorethan126orelativetojointone,andjointthree(thewrist)cannotrotatebymorethan90orelativetojointtwo.Thisisasimpleapproximationofahumanarm.Bothchainsasshownbytheapplicationcanbeseeninfigure5.Thetargetwhicheachchainwillattempttoreachisrepresentedbyawireframesphere.Itspositioniscreatedrandomly,tobewithinaboxofsidelength60.Thismakesitpossiblethatthetargetisoutsidetherangeofthekinematicchain,whichiscentredattheorigin.4.2ExperimentalSetupToexperimentallycompareCCDwithournewmethod,wemovethetargetto10000differentpositions.AteachpositionweuseboththeCCDalgorithmandtriangulationtomovetheend-effectorasclosetothetargetaspossible.Thetargetisconsideredreachedassoonastheend-effectormoveswithin0.5unitsofit.IfittakesCCDmorethan99iterationstoreachthetargetthealgorithmaborts.Thisexperimentisrepeatedforbothkinematicchains.Fortheconstrainedchain,itispossible184
010203040506070809010001020304050607080DistanceIterationsFigure6:GraphshowingthenumberofiterationsrequiredbyCCDtoreachthetarget,comparedtotheoriginaldistanceofthehandtothetarget.thatsometargetsevenwithintheradiusofthechainareunreachable.WerecordthenumberofiterationsrequiredbytheCCDmethodtoeitherreachthetargetortoreachastableposition.ForbothmethodswerecordhowcloselythetargetisreachedandthesumofthejointanglesascostC.5Results8.27%oftargetswereoutsidetheradiusofthechain.Afurther2.23%wereunreachablebytheconstrainedchain.CCDreached92.97%ofallreachabletargetswhenconstrainedwithin20iterations,withameannum-berof8.727iterations.Whenunconstraineditreached92.12%ofthetargetswithin20iterationswithameanof8.351.Notethatthemeanalsodoesnotincludethosetargetsthatwereunreachable.Ascanbeseeninfigure6,thenumberofiterationsincreasesexponentiallywiththeoriginaldistanceoftheend-effectortothetarget.Theoriginalangleofthetargetvectortothechainisalsosignificant.Asitincreasessodoesthenumberofiterations.Triangulationreachedeachtargetonthefirstiter-ationasexpected.TheaveragecostofCCDusingtheunconstrainedchainwas315.5o,comparedto173.9owhenus-ingtheconstrainedchain.Thetriangularmethodwhenunconstrainedhadameancostof159.9o;Whenconstrainedthisvaluewas141.5o.6DiscussionEverytargetthatcouldtheoreticallybereachedwasreachedbybothalgorithms,asexpected.ItisinterestingtonotethattheconstrainedversionofCCDperformedslightlyfasterthantheuncon-strainedversion.Thereareseveralreasonsforthis:Figure7:5-Jointedkinematicchainreachingforaclosetarget.•Theconstraintspreventedthechainfrom’rollingin’onitselfasshowninfigure2.Thusthechaindidnothavetounrollitselfbeforereach-ingthetarget.•Theconstrainedchainhadfewerbutlongerjointsthantheunconstrainedchain.Thustherotationofeachjointhadmoreofaneffectontheremainingchain,especiallyinlateriterations.Ascanbeseeninfigure7,triangulationachievedmorenaturalposeswhenreachingforthesametargetasCCDinfigure2.Thisiscausedbythemajorjointsrotatingbeforethejointsclosetotheend-effector.Itisalsoworthnoticingthatmostjointssimplyremainstraight,insteadoftwistinginseveraldifferentdirections.Thishadaneffectonthecostfunction,whichwaslowerforthetrian-gularmethodthanforCCDusingbothkinematicchains.Wecancomparethecomplexityofthetwoalgo-rithmsusingthenumberofcalculationsrequiredforeachjoint.Thedotproductoftwovectorsinthree-dimensionalspacerequiresthreemulti-plicationstocompute.Thecrossproductneedssixmultiplications.Solvingthecosineequationasshowninequation(5)needs5multiplicationsandonedivision.Thisisapproximatelyascomplicatedasacrossproduct.Wedefinethenumberofcalcu-lationsrequiredfortherotationortransormationasr.Ifwelabelthenumberofcalculationsre-quiredforadotproductn,thenboththecrossproductandthecosineequationbothrequire2ncalculations.Wecanrepresentthesevaluesbythefollowingequa-tions:185
NCCD=numIter∗numJoints∗(n+2n+r)(9)NTriangulation=numJoints∗(n+2n+2n+r)(10)ClearlyNCCD>NTriangulation,whenCCDre-quiresmorethanoneiteration.Ifwecomparethiswithourdata,thenfortheunconstrainedchainwehaveameannumberof8.351∗5∗(3n+r)=125.265n+41.755rcalcu-lationsusingCCD,comparedto5∗(5n+r)=25n+5rcalculationsusingtriangulation.Obvi-ouslyourmethodrequiressignificantlyfewercalcu-lations,andisthusfastertoimplementthanCCD.7FutureWorkOurimplementationofthetriangularmethodhasonlybeenforkinematicchainswithoneend-effector.Ifthisalgorithmweretobemodifiedintoaformthatcouldfindsolutionsforseveralendeffectors,itcouldbeusedformorecomplexcharactermodels.Thealgorithmasitstandscannotacceptconstric-tionsontheaxisofrotation.Bothincharacteranimationandroboticstheserestrictionsoftenex-ist.Thusourmethodneedstobeadaptedtoalsoaccepttheserestrictions.Modifyingthealgorithm,bychangingδbto90oinsteadof180owhenatrianglecannotbeformed,shouldalsobeinvestigated.Thisalternativemightreducethecostfurther,especiallyforconstrainedjoints.8ConclusionInthispaperwehavepresentedanovelmethodofsolvingtheinversekinematicsproblem.Thisnewmethod,whichisguaranteedtofindasolutionwhenitisavailable,isnotiterative,thereforemak-ingitpossibletopredictthenumberofcalculationsrequiredtoreachatarget.LikemethodsusingtheJacobianMatrixthealgorithmwillfindasolutionimmediately,insteadofconvergingonasolutionafterseveraliterations.YetunlikethesemethodsitcandealwithsingularitiesasitdoesnotrequiretheJacobianMatrixforitscalculations.OurexperimentshowsthatthetriangularmethodrequiresonaveragemanyfewercalculationsthanCCD,bothwithconstrainedandunconstrainedkinematicchains.Atthesametimeitisjustasaccurate,findingasolutioneverytimeCCDdoes.Thusthetriangulationmethodcombinesthebestofbothworlds.ItiscomputationallycheaperthanCCD,yetjustasaccurateasalgorithmscalculat-ingtheJacobianinverseortransposeofanin-versekinematicsproblem.UsingacostfunctionwecouldshowthatitconsistentlyrequireslessrotationsthanCCD,yetitisworthnotingthatourmethoddoesnotguaranteeoptimalrotations(whereeachjointmovesbyaminimalamount);LikeCCDitcalculatesanglesonejointatatime,thusitisnotpossibleforittofindsuchaminimalsolutionfortheentirekinematicchain.References[1]K.C.GuptaandK.Kazerounian,“Improvednumericalsolutionsofinversekinematicsofrobots,”inProceedingsofthe1985IEEEInter-nationalConferenceonRoboticsandAutoma-tion,vol.2,March1985,pp.743–748.[2]A.Goldenberg,B.Benhabib,andR.Fenton,“Acompletegeneralizedsolutiontothein-versekinematicsofrobots,”IEEEJournalofRoboticsandAutomation,vol.1,pp.14–20,March1985.[3]V.J.Lumelsky,“Iterativecoordinatetrans-formationprocedureforoneclassofrobots,”IEEETransactionsonSystemsManandCy-bernetics,vol.14,pp.500–505,Jun.1984.[4]V.D.TourassisandJ.Ang,M.H.,“Amodu-lararchitectureforinverserobotkinematics,”IEEETransactionsonRoboticsandAutoma-tion,vol.5,pp.555–568,October1989.[5]M.Fedor,“Applicationofinversekinematicsforskeletonmanipulationinreal-time,”inSCCG’03:Proceedingsofthe19thspringconferenceonComputergraphics.NewYork,NY,USA:ACMPress,2003,pp.203–212.[6]D.L.Pieper,“Thekinematicsofmanipulatorsundercomputercontrol,”Ph.D.dissertation,StanfordUniversityDepartmentofComputerScience,October1968.[7]J.Lander,“Makingkinemoreflexible,”GameDeveloper,vol.1,pp.15–22,November1998.[8]A.CanutescuandR.Dunbrack,Jr.,“Cycliccoordinatedescent:Aroboticsalgorithmforproteinloopclosure,”ProteinScience,vol.12,pp.963–972,May2003.[9]L.-C.T.WangandC.C.Chen,“Acombinedoptimizationmethodforsolvingtheinversekinematicsproblemsofmechanicalmanipu-lators,”IEEETransactionsonRoboticsandAutomation,vol.7,pp.489–499,August1991.186
分享到:
收藏