๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์นดํ…Œ๊ณ ๋ฆฌ ์—†์Œ

[Spot Dynamixel - 6] Kinematic Motion ์ฝ”๋“œ ์„ค๋ช…

 

๐Ÿฆต๐Ÿผ

Kinematic Motion ์ฝ”๋“œ ์„ค๋ช…

class TrottingGait

gait๋ž€ ๊ฑธ์Œ๊ฑธ์ด๋ฅผ ๋œปํ•ฉ๋‹ˆ๋‹ค. ๊ณง, ์ด ํด๋ž˜์Šค๋Š” ๋กœ๋ด‡์„ ๊ฑท๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•œ ๊ตฌํ˜„์ž…๋‹ˆ๋‹ค.
def __init__(self):
        self.step_gain = 0.8
        self.maxSl=2
        self.bodyPos=(0,100,0)
        self.bodyRot=(0,0,0)
        self.t0=300 #0 #300 # senseless i guess
        self.t1=1200 #1200
        self.t2=300 #0 #300
        self.t3=350 #200
        self.Sl=0
        self.Sw=0
        self.Sh=70 #100
        self.Sa=0
        self.Spf=87
        self.Spr=77
        self.Fo=120
        self.Ro=50

        self.Rc=[-50,0,0,1] # rotation center

๊ฐ ๋งค๊ฐœ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ์„ค๋ช…์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • Sl : ํ•œ๊ฑธ์Œ์„ ๊ฑธ์„๋•Œ ์ „ํ›„ ๋ฐฉํ–ฅ์œผ๋กœ ๋‚ด๋”›๋Š” ๊ธธ์ด
  • Sw : ํ•œ๊ฑธ์Œ์„ ๊ฑธ์„๋•Œ ์ขŒ์šฐ๋ฐฉํ–ฅ ๋‚ด๋”›๋Š” ๊ธธ์ด
  • Sh : ํ•œ๊ฑธ์Œ์„ ๊ฑธ์„๋•Œ ๋ฐœ์„ ๋“ค์–ด์˜ฌ๋ฆฌ๋Š” ๋†’์ด
  • Sa : ๋Œ€๊ฐ์„ ์œผ๋กœ ๊ฑธ์„๋•Œ ์ง€์ƒ์œผ๋กœ๋ถ€ํ„ฐ ์ˆ˜์งํ•œ ์ถ•์„ ๊ธฐ์ค€์œผ๋กœ ํšŒ์ „ํ•˜๋Š” ๊ฐ๋„(Pitch)
  • ์ •์ง€์ƒํƒœ์ผ๋•Œ ๊ฐ ๋‹ค๋ฆฌ์˜ ์œ„์น˜์„ค์ •๊ณผ ๊ด€๋ จ๋œ ๋ณ€์ˆ˜๋“ค⇒ ๊ฐ ๋‹ค๋ฆฌ์˜ ๋์  (x, y, z) ์ขŒํ‘œ๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.2๋ฒˆ ๋‹ค๋ฆฌ: (Fo, -100, -Spf )4๋ฒˆ ๋‹ค๋ฆฌ: (Ro, -100, -Spr )
  • 3๋ฒˆ ๋‹ค๋ฆฌ: (Ro, -100, Spr )
  • 1๋ฒˆ ๋‹ค๋ฆฌ: (Fo, -100, Spf )

 

๐Ÿ˜‰๋‹ค์Œ์œผ๋กœ ์ฃผ์š” ์ธ์Šคํ„ด์Šค ํ•จ์ˆ˜๋“ค์„ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

 

calcLeg

ํ˜„์žฌ์˜ leg point (x, y, z)์™€ ์ฃผ์–ด์ง„ ์‹œ๊ฐ„ t๋ฅผ ํ†ตํ•ด ์ด๋™์‹œํ‚ฌ leg point๋ฅผ ๊ณ„์‚ฐํ•ด์ฃผ๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
def calcLeg(self,t,x,y,z):
        startLp=np.array([x-self.Sl/2.0,y,z-self.Sw,1])
        endY=0 #-0.8 # delta y to jump a bit before lifting legs
        endLp=np.array([x+self.Sl/2,y+endY,z+self.Sw,1])
        
        if(t<self.t0): # TODO: remove t0 and t2 - not practical
            return startLp
        elif(t<self.t0+self.t1): # drag foot over ground

            td=t-self.t0
            tp=1/(self.t1/td)
            diffLp=endLp-startLp
            curLp=startLp+diffLp*tp
            psi=-((math.pi/180*self.Sa)/2)+(math.pi/180*self.Sa)*tp
            Ry = np.array([[np.cos(psi),0,np.sin(psi),0],
                    [0,1,0,0],
                    [-np.sin(psi),0,np.cos(psi),0],[0,0,0,1]])
            #Tlm = np.array([[0,0,0,-self.Rc[0]],[0,0,0,-self.Rc[1]],[0,0,0,-self.Rc[2]],[0,0,0,0]])
            curLp=Ry.dot(curLp)
            return curLp
        elif(t<self.t0+self.t1+self.t2):
            return endLp
        elif(t<self.t0+self.t1+self.t2+self.t3): # Lift foot
            td=t-(self.t0+self.t1+self.t2)
            tp=1/(self.t3/td)
            diffLp=startLp-endLp
            curLp=endLp+diffLp*tp
            curLp[1]+=self.Sh*math.sin(math.pi*tp)
            return curLp
  • psi์™€ Ry๊ฐ€ ๋“ฑ์žฅํ•œ ์ด์œ ๋Š”, ๊ตฌ์ฒด์ ์ธ ๊ณ„์‚ฐ์‹์€ ํฐ ์˜๋ฏธ๋Š” ์—†๊ณ , ๋กœ๋ด‡์ด ๋Œ€๊ฐ์„  ๋ฐฉํ–ฅ์œผ๋กœ ์›€์ง์ด๊ธฐ ์œ„ํ•ด pitch ๋ฐฉํ–ฅ์˜ ์ „ํ™˜์ด ํ•„์š”ํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.
  • ๋กœ๋ด‡์ด ๊ฑธ์–ด๊ฐ€๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋ฐ˜๋ณต์ ์ธ ์›€์ง์ž„๋“ค์ด ์—ฐ์†๋ฉ๋‹ˆ๋‹ค. ์ด ๋ฐ˜๋ณต๋˜๋Š” ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ์—ฌ๋Ÿฌ ๋ถ€๋ถ„์œผ๋กœ ๋‚˜๋ˆ„๊ณ , ์ด์— ๋”ฐ๋ผ Leg point๋ฅผ ์ œ์–ดํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋ผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๐Ÿ’ก
๊ฐ ์ƒํ™ฉ์— ๋Œ€ํ•œ ๊ตฌ์ฒด์ ์ธ ์„ค๋ช…์€ ๋‹ค์Œ ์˜์ƒ์œผ๋กœ ๋Œ€์ฒดํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

positions

ํ‚ค๋ณด๋“œ ์ž…๋ ฅ์„ ๋ฐ›์•„ ๋กœ๋ด‡์„ ์ด๋™์‹œํ‚ฌ ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„๋œ ์ธํ„ฐํŽ˜์ด์Šค์ž…๋‹ˆ๋‹ค.
def positions(self,t,kb_offset={}):
        spf=self.Spf
        spr=self.Spr
        # self.Sh=60.0

        if list(kb_offset.values()) == [0.0, 0.0, 0.0]:
            self.Sl=0.0
            self.Sw=0.0
            self.Sa=0.0
        else:
            self.Sl=kb_offset['IDstepLength']
            self.Sw=kb_offset['IDstepWidth']
            self.Sa=kb_offset['IDstepAlpha']

        Tt=(self.t0+self.t1+self.t2+self.t3)
        Tt2=Tt/2
        rd=0 # rear delta - unused - maybe stupid
        td=(t*1000)%Tt
        t2=(t*1000-Tt2)%Tt
        rtd=(t*1000-rd)%Tt # rear time delta
        rt2=(t*1000-Tt2-rd)%Tt
        Fx=self.Fo
        Rx=-1*self.Ro
        Fy=-100
        Ry=-100
        r=np.array([self.calcLeg(td,Fx,Fy,spf),self.calcLeg(t2,Fx,Fy,-spf),self.calcLeg(rt2,Rx,Ry,spr),self.calcLeg(rtd,Rx,Ry,-spr)])
        #print(r)
        return r
  • ํ‚ค๋ณด๋“œ ์ž…๋ ฅ์— ๋”ฐ๋ผ Sl, Sw, Sa ๊ฐ’์„ ๋ณ€๊ฒฝํ•จ์œผ๋กœ ๋กœ๋ด‡์˜ ์ „ํ›„์ขŒ์šฐ, ๋Œ€๊ฐ์„  ๋ฐฉํ–ฅ์œผ๋กœ์˜ ์ง„ํ–‰ ์ œ์–ด๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.