## bipedal robot

Typically: "How do I... ", "How can I... " questions
efrianto
Posts: 23
Joined: 14 Nov 2014, 10:00

### bipedal robot

I have work in my thesis project to make the simulation of bipedal robot in V-Rep simulation. Here is my bipedal robot looks like:
. Now, i'm in progress to make the behaviour for the bipedal robot, such as walking forward, move left or right, etc. But, i have problem in defining some variables that i need for the formula calculation of bipedal robot. I want to make my bipedal robot in initial position standing with the distance between joint 5 and joint 9, also distance between joint 6 and joint 10 is h1/h2, like i show in my picture below:

Can someone help me how to keep joint 5 and joint 9 stay in distance of h1 or joint 6 and to joint 10 in distance of h2?
Here is i attached also my program:

Code: Select all

simSetThreadSwitchTiming(2) -- Default timing for automatic thread switching
simDelegateChildScriptExecution()

rightfoot = simGetObjectHandle ('Dummy2')

leftfoot = simGetObjectHandle ('Dummy')

motor_2		=	simGetObjectHandle('leftmotor2_1')
motor_4		=	simGetObjectHandle('leftmotor2_2')
motor_6		=	simGetObjectHandle('leftmotor2_3')
motor_8		=	simGetObjectHandle('leftmotor2_4')
motor_10	=	simGetObjectHandle('leftmotor2_5')
motor_12	=	simGetObjectHandle('leftmotor2_6')

motor_1		=	simGetObjectHandle('rightmotor2_1')
motor_3		=	simGetObjectHandle('rightmotor2_2')
motor_5		=	simGetObjectHandle('rightmotor2_3')
motor_7		=	simGetObjectHandle('rightmotor2_4')
motor_9		=	simGetObjectHandle('rightmotor2_5')
motor_11	=	simGetObjectHandle('rightmotor2_6')

--input = simGetUIHandle('Movement')

--offset= 107
--phi= 18
beta_stand= 1.047
beta_liftfoot= 1.57

[color=#FF0040]l1_1d= simGetObjectPosition(motor_5,motor_7)
l1_2d= simGetObjectPosition(motor_7,motor_9)
l2_1d= simGetObjectPosition(motor_6,motor_8)
l2_2d= simGetObjectPosition(motor_8,motor_10)

l1_1=math.sqrt((l1_1d[1]^2)+(l1_1d[2]^2)+(l1_1d[3]^2))
l1_2=math.sqrt((l1_2d[1]^2)+(l1_2d[2]^2)+(l1_2d[3]^2))
l2_1=math.sqrt((l2_1d[1]^2)+(l2_1d[2]^2)+(l2_1d[3]^2))
l2_2=math.sqrt((l2_2d[1]^2)+(l2_2d[2]^2)+(l2_2d[3]^2))[/color]

--initial = simGetUIEventButton(input)

--if(initial == 3 )
--then
--initial position
teta1= beta_stand/2
teta2= beta_stand/2

[color=#FF0040]h1d= (l1_1+l1_2)*(math.cos(teta1))--distance between rightmotor2_3 with rightmotor2_5
h2d= (l2_1+l2_2)*(math.cos(teta2))--distance between leftmotor2_3 with leftmotor2_5[/color]

alpha1= teta1
alpha2= teta2

gamma1= teta1
gamma2= teta2

[color=#FF0040]h1={0,0,h1d}
h2={0,0,h2d}[/color]

[color=#FF0000]simSetObjectPosition(motor_5,motor_9,h1d)
simSetObjectPosition(motor_6,motor_10,h2d)[/color]
simSetJointPosition(motor_1,1.838323549)
simSetJointPosition(motor_2,3.41037182)
simSetJointPosition(motor_3,2.621787345)
simSetJointPosition(motor_4,2.621787345)
simSetJointPosition(motor_5,(2.621787345-alpha1))
simSetJointPosition(motor_6,(2.621787345-alpha2))
simSetJointPosition(motor_7,(2.621787345+beta_stand))
simSetJointPosition(motor_8,(2.621787345+beta_stand))
simSetJointPosition(motor_9,2.621787345-gamma1)
simSetJointPosition(motor_10,2.621787345-gamma2)
simSetJointPosition(motor_11,2.621787345)
simSetJointPosition(motor_12,2.621787345)
end

--end

--tetat= angle between rightmotor2_3 with reference

--teta1= angle of rightmotor2_3 (beta1/2)
--teta2= angle of leftmotor2_3 (beta2/2)

--gamma1= angle of rightmotor2_5 (teta1+tetat)
--gamma2= angle of leftmotor2_5 (teta2-tetat)

--alpha1= angle of rightmotor2_3 (teta1-tetat)
--alpha2= angle of leftmotor2_3 (teta2+tetat)

--phi1.1=phi1.2=phi2.1=phi2.2= angle to turn right / left

--pos1 = {0.2120, 0.03, 0.0738}
--pos2 = {0.06, 0.03, 0.0738}

--simSetObjectPosition (rightfoot, -1, pos2)
--simSetObjectPosition (leftfoot, -1, pos1)

--end



coppelia
Posts: 7680
Joined: 14 Dec 2012, 00:25

### Re: bipedal robot

Hello,

your question is not clear. Are you talking about a control algorithm? How to keep the distance between the two mentionned joints constant?
This forum will quickly help you for questions regarding V-REP and how to use it. But for control algorithms, you have many many possibilities, and we are no experts for that. Maybe some other user on this forum can help you.

Cheers

efrianto
Posts: 23
Joined: 14 Nov 2014, 10:00

### Re: bipedal robot

yes, i mean How to keep the distance between the two mentioned joints constant?
can i use simSetObjectPosition like in my coding that i have been attached? Thank you

coppelia
Posts: 7680
Joined: 14 Dec 2012, 00:25

### Re: bipedal robot

No, you cannot use simSetObjectPosition, otherwise you will break the mechanism. You will have to adjust the joint position (probably simSetJointTargetPosition) by doing some geometric computation.

Cheers

efrianto
Posts: 23
Joined: 14 Nov 2014, 10:00

### Re: bipedal robot

Thanks for the reply. How is i use dummy in every joint? Then i use simGetObjectPosition with the position of the dummy? Is it possible to keep the distance between the two mentioned joints constant? Thank you very much

coppelia
Posts: 7680
Joined: 14 Dec 2012, 00:25

### Re: bipedal robot

You can call simGetObjectPosition in order to retrieve the position of your joint:

Code: Select all

local pos=simGetObjectPosition(jointHandle,-1)
local xCoord=pos[1]
local yCoord=pos[2]
local zCoord=pos[3]
Cheers

efrianto
Posts: 23
Joined: 14 Nov 2014, 10:00

### Re: bipedal robot

sorry, i am wrong, i mean simSetObjectPosition not simGetObjectPosition. how if i use dummy in every joint then i use the coordinate of the dummy in simSetObjectPosition to keep the distance as i mention before? Thank you

efrianto
Posts: 23
Joined: 14 Nov 2014, 10:00

### Re: bipedal robot

I want to ask, i have already written a programming with the logic that i think it's correct. but the simulation doesn't work like i write in the programming, here i attached my programming. Can anyone help me? Thank you very much

Code: Select all

simSetThreadSwitchTiming(2) -- Default timing for automatic thread switching
simDelegateChildScriptExecution()

motor_2		=	simGetObjectHandle('leftmotor2_1')
motor_4		=	simGetObjectHandle('leftmotor2_2')
motor_6		=	simGetObjectHandle('leftmotor2_3')
motor_8		=	simGetObjectHandle('leftmotor2_4')
motor_10	=	simGetObjectHandle('leftmotor2_5')
motor_12	=	simGetObjectHandle('leftmotor2_6')

motor_1		=	simGetObjectHandle('rightmotor2_1')
motor_3		=	simGetObjectHandle('rightmotor2_2')
motor_5		=	simGetObjectHandle('rightmotor2_3')
motor_7		=	simGetObjectHandle('rightmotor2_4')
motor_9		=	simGetObjectHandle('rightmotor2_5')
motor_11	=	simGetObjectHandle('rightmotor2_6')

--offset= 107
phi= 0.31
beta_stand= 1.05
beta_liftfoot= 2.09

function initial()
local teta1= beta_stand/2
local teta2= beta_stand/2

--local h1d= (l1_1+l1_2)*(math.cos(teta1))--distance between rightmotor2_3 with rightmotor2_5
--local h2d= (l2_1+l2_2)*(math.cos(teta2))--distance between leftmotor2_3 with leftmotor2_5

local alpha1= teta1
local alpha2= teta2

local gamma1= teta1
local gamma2= teta2

--h1={0,0,h1d}
--h2={0,0,h2d}

--simSetObjectPosition(motor_5,motor_9,h1d)
--simSetObjectPosition(motor_6,motor_10,h2d)
simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
end -- initial

function tilt_left()
local teta1= beta_stand/2
local teta2= beta_stand/2
local alpha1= teta1
local alpha2= teta2
local gamma1= teta1
local gamma2= teta2

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62-phi)
simSetJointPosition(motor_4,2.62-phi)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62+phi)
simSetJointPosition(motor_12,2.62+phi)
end -- tilt_left

function lift_rightfoot()
local teta1= beta_liftfoot/2
local teta2= beta_stand/2
local tetat=0
local alpha1= teta1-tetat
local alpha2= teta2+tetat
local gamma1= teta1+tetat
local gamma2= teta2-tetat

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62-phi)
simSetJointPosition(motor_4,2.62-phi)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_liftfoot))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62+phi)
simSetJointPosition(motor_12,2.62+phi)
end -- lift_rightfoot

function rightfoot_forward()
local tetat= 0.22
local teta1= beta_stand/2
local teta2=beta_stand/2
local alpha1= teta1+tetat
local alpha2= teta2-tetat
local gamma1= teta1-tetat
local gamma2= teta2+tetat

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
end -- rightfoot_forward

function tilt_right()
local tetat= 0.22
local teta1= beta_stand/2
local teta2=beta_stand/2
local alpha1= teta1+tetat
local alpha2= teta2-tetat
local gamma1= teta1-tetat
local gamma2= teta2+tetat

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62+phi)
simSetJointPosition(motor_4,2.62+phi)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62-phi)
simSetJointPosition(motor_12,2.62-phi)
end -- tilt_right

function lift_leftfoot()
local tetat= 0.22
local teta1= beta_stand/2
local teta2=beta_liftfoot/2
local alpha1= teta1+tetat
local alpha2= teta2-tetat
local gamma1= teta1-tetat
local gamma2= teta2+tetat

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62+phi)
simSetJointPosition(motor_4,2.62+phi)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_liftfoot))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62-phi)
simSetJointPosition(motor_12,2.62-phi)
end -- lift_leftfoot

function leftfoot_forward()
local phi = 0.17
local tetat= 0.22
local teta1= beta_stand/2
local teta2=beta_stand/2
local alpha1= teta1-tetat
local alpha2= teta2+tetat
local gamma1= teta1+tetat
local gamma2= teta2-tetat

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
end -- leftfoot_forward

function tilt_left2()
local tetat= 0.22
local teta1= beta_stand/2
local teta2=beta_stand/2
local alpha1= teta1-tetat
local alpha2= teta2+tetat
local gamma1= teta1+tetat
local gamma2= teta2-tetat

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62-phi)
simSetJointPosition(motor_4,2.62-phi)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62+phi)
simSetJointPosition(motor_12,2.62+phi)
end -- tilt_left2

function lift_rightfoot2()
local tetat= 0.2198
local teta1= beta_liftfoot/2
local teta2=beta_stand/2
local alpha1= teta1-tetat
local alpha2= teta2+tetat
local gamma1= teta1+tetat
local gamma2= teta2-tetat

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62-phi)
simSetJointPosition(motor_4,2.62-phi)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_liftfoot))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62+phi)
simSetJointPosition(motor_12,2.62+phi)
end -- lift_rightfoot2

function rightfoot_forward2()
local teta1= beta_stand/2
local teta2= beta_stand/2
local alpha1= teta1
local alpha2= teta2
local gamma1= teta1
local gamma2= teta2

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
end -- rightfoot_forward2

function tilt_right2()
local teta1= beta_stand/2
local teta2= beta_stand/2
local alpha1= teta1
local alpha2= teta2
local gamma1= teta1
local gamma2= teta2

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62+phi)
simSetJointPosition(motor_4,2.62+phi)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62-phi)
simSetJointPosition(motor_12,2.62-phi)
end -- tilt_right2

input = simGetUIHandle('movement')
input2 = simGetUIHandle('movement')
input3 = simGetUIHandle('movement')
input4 = simGetUIHandle('movement')
input5 = simGetUIHandle('movement')
input6 = simGetUIHandle('movement')
input7 = simGetUIHandle('movement')
input8 = simGetUIHandle('movement')
input9= simGetUIHandle('movement')
input10= simGetUIHandle('movement')
input11= simGetUIHandle('movement')

--l1_1d= simGetObjectPosition(motor_5,motor_7)
--l1_2d= simGetObjectPosition(motor_7,motor_9)
--l2_1d= simGetObjectPosition(motor_6,motor_8)
--l2_2d= simGetObjectPosition(motor_8,motor_10)

--l1_1=math.sqrt((l1_1d[1]^2)+(l1_1d[2]^2)+(l1_1d[3]^2))
--l1_2=math.sqrt((l1_2d[1]^2)+(l1_2d[2]^2)+(l1_2d[3]^2))
--l2_1=math.sqrt((l2_1d[1]^2)+(l2_1d[2]^2)+(l2_1d[3]^2))
--l2_2=math.sqrt((l2_2d[1]^2)+(l2_2d[2]^2)+(l2_2d[3]^2))

dom = true

if(dom == true)
then
print('start')

initialID = simGetUIButtonProperty(input,3)
tilt_leftID = simGetUIButtonProperty(input2,4)
lift_rightfootID = simGetUIButtonProperty(input3,5)
rightfoot_forwardID = simGetUIButtonProperty(input4,6)
tilt_rightID = simGetUIButtonProperty(input5,7)
lift_leftfootID = simGetUIButtonProperty(input6,8)
leftfoot_forwardID = simGetUIButtonProperty(input7,9)
forward_moveID = simGetUIButtonProperty(input8,10)
tilt_left2ID = simGetUIButtonProperty(input9,11)
lift_rightfoot2ID = simGetUIButtonProperty(input10,12)
rightfoot_forward2ID = simGetUIButtonProperty(input11,13)

if(initialID == 8536 ) then
initial()
end

if(tilt_leftID == 8536) then
tilt_left()
end

if(lift_rightfootID == 8536) then
lift_rightfoot()
end

if(rightfoot_forwardID == 8536) then
rightfoot_forward()
end

if(tilt_rightID == 8536) then
tilt_right()
end

if(lift_leftfootID == 8536) then
lift_leftfoot()
end

if (leftfoot_forwardID == 8536) then
leftfoot_forward()
end

if (tilt_left2ID == 8536) then
tilt_left2()
end

if (lift_rightfoot2ID == 8536) then
lift_rightfoot2()
end

if(rightfoot_forward2ID == 8536) then
rightfoot_forward2()
end

s=0
if (forward_moveID == 8536) then
dom = false
if(s==0)then
initial()

j5= simGetJointPosition(motor_5)
j6= simGetJointPosition(motor_6)
j7= simGetJointPosition(motor_7)
j8= simGetJointPosition(motor_8)
j9= simGetJointPosition(motor_9)
j10= simGetJointPosition(motor_10)
print((j5 - j5%0.01),(j6 - j6%0.01),(j7 - j7%0.01),(j8 - j8%0.01),(j9 - j9%0.01),(j10 - j10%0.01))

if(j5<(2.1)and j6<(2.1)and j7<(3.71) and j8<(3.67) and j9<(2.1) and j10<(2.1)) then
--while(j5>(2.098287345) and j6>(2.098287345) and j7>(3.709752772) and j8>(3.668787345) and j9>(2.098287345) and j10>(2.098287345)) do
local teta1= beta_stand/2
local teta2= beta_stand/2
local alpha1= teta1
local alpha2= teta2
local gamma1= teta1
local gamma2= teta2

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
elseif (j5>=(2.09)and j6>=(2.09)and j7>=(3.7) and j8>=(3.66) and j9>=(2.09) and j10>=(2.09)) then
s=1
print("finish_initial")
end
end
if(s==1) then
print('masuk')
tilt_left()

j3= simGetJointPosition(motor_3)
j4= simGetJointPosition(motor_4)
j11= simGetJointPosition(motor_11)
j12= simGetJointPosition(motor_12)

if(j3<(2.3) and j4<(2.3) and j11<(2.93) and j12<(2.93)) then
local teta1= beta_stand/2
local teta2= beta_stand/2
local alpha1= teta1
local alpha2= teta2
local gamma1= teta1
local gamma2= teta2

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62-phi)
simSetJointPosition(motor_4,2.62-phi)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62+phi)
simSetJointPosition(motor_12,2.62+phi)
elseif (j3>=(2.3) and j4>=(2.3) and j11>=(2.93) and j12>=(2.93)) then
s=2
print(s)
print('finish_tilt_left')
end
end
if(s==2)then
print('masuk2')
initial()

j5= simGetJointPosition(motor_5)
j6= simGetJointPosition(motor_6)
j7= simGetJointPosition(motor_7)
j8= simGetJointPosition(motor_8)
j9= simGetJointPosition(motor_9)
j10= simGetJointPosition(motor_10)
print((j5 - j5%0.001),(j6 - j6%0.001),(j7 - j7%0.001),(j8 - j8%0.001),(j9 - j9%0.001),(j10 - j10%0.001))

if(j5<(2.1)and j6<(2.1)and j7<(3.71) and j8<(3.67) and j9<(2.1) and j10<(2.1)) then
--while(j5>(2.098287345) and j6>(2.098287345) and j7>(3.709752772) and j8>(3.668787345) and j9>(2.098287345) and j10>(2.098287345)) do
local teta1= beta_stand/2
local teta2= beta_stand/2
local alpha1= teta1
local alpha2= teta2
local gamma1= teta1
local gamma2= teta2

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
elseif (j5>=(2.09)and j6>=(2.09)and j7>=(3.7) and j8>=(3.66) and j9>=(2.09) and j10>=(2.09)) then
s=3
print(s)
print("finish_initial2")
end
end
if(s==3)then
print('masuk3')

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,2.62)
simSetJointPosition(motor_6,2.62)
simSetJointPosition(motor_7,2.66)
simSetJointPosition(motor_8,2.62)
simSetJointPosition(motor_9,2.62)
simSetJointPosition(motor_10,2.62)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
print("finish_standing")
end
end
end
end

--and j8==(3.668787345) and j9==(2.098287345) and j10==(2.098287345)
--and j8<(3.668787345) and j9<(2.098287345) and j10<(2.098287345)
--function initial()

--tetat= angle between rightmotor2_3 with reference

--teta1= angle of rightmotor2_3 (beta1/2)
--teta2= angle of leftmotor2_3 (beta2/2)

--gamma1= angle of rightmotor2_5 (teta1+tetat)
--gamma2= angle of leftmotor2_5 (teta2-tetat)

--alpha1= angle of rightmotor2_3 (teta1-tetat)
--alpha2= angle of leftmotor2_3 (teta2+tetat)

--phi1.1=phi1.2=phi2.1=phi2.2= angle to turn right / left

--pos1 = {0.2120, 0.03, 0.0738}
--pos2 = {0.06, 0.03, 0.0738}

--simSetObjectPosition (rightfoot, -1, pos2)
--simSetObjectPosition (leftfoot, -1, pos1)

--end



Eric
Posts: 186
Joined: 11 Feb 2013, 16:39

### Re: bipedal robot

if you want help you need to be more specific on what your question is... saying : the simulation doesn t work and just dropping the code is not going to help you to get help

efrianto
Posts: 23
Joined: 14 Nov 2014, 10:00

### Re: bipedal robot

i'm so sorry. I mean in this segment of my code the simulation must move first to initial position, then after that the program will check the position of the joint after finish the checking then the state change from 0 to 1, it prove that initial position has reached. After that with state = 1, the program should be move to the tilt_left postion and the same process with before until the last state = 3 that is standing. But when the simulation start the robot not move like the program said

Code: Select all

s=0
if (forward_moveID == 8536) then
dom = false
if(s==0)then
initial()

j5= simGetJointPosition(motor_5)
j6= simGetJointPosition(motor_6)
j7= simGetJointPosition(motor_7)
j8= simGetJointPosition(motor_8)
j9= simGetJointPosition(motor_9)
j10= simGetJointPosition(motor_10)
print((j5 - j5%0.01),(j6 - j6%0.01),(j7 - j7%0.01),(j8 - j8%0.01),(j9 - j9%0.01),(j10 - j10%0.01))

if(j5<(2.1)and j6<(2.1)and j7<(3.71) and j8<(3.67) and j9<(2.1) and j10<(2.1)) then
--while(j5>(2.098287345) and j6>(2.098287345) and j7>(3.709752772) and j8>(3.668787345) and j9>(2.098287345) and j10>(2.098287345)) do
local teta1= beta_stand/2
local teta2= beta_stand/2
local alpha1= teta1
local alpha2= teta2
local gamma1= teta1
local gamma2= teta2

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
elseif (j5>=(2.09)and j6>=(2.09)and j7>=(3.7) and j8>=(3.66) and j9>=(2.09) and j10>=(2.09)) then
s=1
print("finish_initial")
end
end
if(s==1) then
print('masuk')
tilt_left()

j3= simGetJointPosition(motor_3)
j4= simGetJointPosition(motor_4)
j11= simGetJointPosition(motor_11)
j12= simGetJointPosition(motor_12)

if(j3<(2.3) and j4<(2.3) and j11<(2.93) and j12<(2.93)) then
local teta1= beta_stand/2
local teta2= beta_stand/2
local alpha1= teta1
local alpha2= teta2
local gamma1= teta1
local gamma2= teta2

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62-phi)
simSetJointPosition(motor_4,2.62-phi)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62+phi)
simSetJointPosition(motor_12,2.62+phi)
elseif (j3>=(2.3) and j4>=(2.3) and j11>=(2.93) and j12>=(2.93)) then
s=2
print(s)
print('finish_tilt_left')
end
end
if(s==2)then
print('masuk2')
initial()

j5= simGetJointPosition(motor_5)
j6= simGetJointPosition(motor_6)
j7= simGetJointPosition(motor_7)
j8= simGetJointPosition(motor_8)
j9= simGetJointPosition(motor_9)
j10= simGetJointPosition(motor_10)
print((j5 - j5%0.001),(j6 - j6%0.001),(j7 - j7%0.001),(j8 - j8%0.001),(j9 - j9%0.001),(j10 - j10%0.001))

if(j5<(2.1)and j6<(2.1)and j7<(3.71) and j8<(3.67) and j9<(2.1) and j10<(2.1)) then
--while(j5>(2.098287345) and j6>(2.098287345) and j7>(3.709752772) and j8>(3.668787345) and j9>(2.098287345) and j10>(2.098287345)) do
local teta1= beta_stand/2
local teta2= beta_stand/2
local alpha1= teta1
local alpha2= teta2
local gamma1= teta1
local gamma2= teta2

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,(2.62-alpha1))
simSetJointPosition(motor_6,(2.62-alpha2))
simSetJointPosition(motor_7,(2.66+beta_stand))
simSetJointPosition(motor_8,(2.62+beta_stand))
simSetJointPosition(motor_9,2.62-gamma1)
simSetJointPosition(motor_10,2.62-gamma2)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
elseif (j5>=(2.09)and j6>=(2.09)and j7>=(3.7) and j8>=(3.66) and j9>=(2.09) and j10>=(2.09)) then
s=3
print(s)
print("finish_initial2")
end
end
if(s==3)then
print('masuk3')

simSetJointPosition(motor_1,1.84)
simSetJointPosition(motor_2,3.41)
simSetJointPosition(motor_3,2.62)
simSetJointPosition(motor_4,2.62)
simSetJointPosition(motor_5,2.62)
simSetJointPosition(motor_6,2.62)
simSetJointPosition(motor_7,2.66)
simSetJointPosition(motor_8,2.62)
simSetJointPosition(motor_9,2.62)
simSetJointPosition(motor_10,2.62)
simSetJointPosition(motor_11,2.62)
simSetJointPosition(motor_12,2.62)
print("finish_standing")
end
end
end
the robot just move like this:

beside the program in command window has already enter every process until finish but it is not the same with simulation.
Thank you very much