Inquiry for follow-path code

Typically: "How do I... ", "How can I... " questions
Luis Nieto
Posts: 49
Joined: 26 Oct 2021, 01:35

Re: Inquiry for follow-path code

Post by Luis Nieto »

Predefined Movement Sequence?

Does this essentially mean that every joint on the legs has a path and is enabled with Inverse-Kinematics in order to assure that the robot model has the best balance everytime? Or is it using more of position control?

Thanks

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Inquiry for follow-path code

Post by coppelia »

The relative foot motion is defined for each foot, i.e. each foot has a list of pos-time pairs. Then, ik is applied to compute for a given pair the corresponding joint angles. Those joint angles are then applied to the leg joints, which all operate in position control mode.

Cheers

Luis Nieto
Posts: 49
Joined: 26 Oct 2021, 01:35

Re: Inquiry for follow-path code

Post by Luis Nieto »

What would be an example of a position-time pair? This is a term that relatively new for me.

Thanks.

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Inquiry for follow-path code

Post by coppelia »

That's entirely up to you, e.g.:

t=0.00 , p={0,0,0}
t=0.05, p={0,0,0.1}
t=0.10, p={0,0,0.2}
etc.

and you can keep that in code like:

Code: Select all

positions={{0,0,0},{0,0,0.1},{0,0,0.2}}
times={0,0.05,0.1}

or

data={{0,{0,0,0}},{0.05,{0,0,0.1}},{0.1,{0,0,0.2}}}

or

...
Cheers

Luis Nieto
Posts: 49
Joined: 26 Oct 2021, 01:35

Re: Inquiry for follow-path code

Post by Luis Nieto »

Is there a sensor or any way on Coppeliasim to detect how tilted a shape is? - A way to read what its orientation with respect to an axis in the world is or something and then a way to print the angle in order to use it in code?

Thank you in advanced...

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Inquiry for follow-path code

Post by coppelia »

Yes, you can use e.g. sim.getObjectOrientation or sim.getObjectMatrix

sim.getObjectOrientation returns Euler angles of the reference frame of the object, relative to the world (if the second argument is -1 or sim.handle_world), or relative to another reference frame.

sim.getObjectMatrix can also be used, knowing that:

Code: Select all

local m=sim.getObjectMatrix(objectHandle,-1)
unitAxisX={m[1],m[5],m[9]}
unitAxisY={m[2],m[6],m[10]}
unitAxisZ={m[3],m[7],m[11]}
With above vectors, you can do many types of calculations, also orientation-related.

Cheers

Luis Nieto
Posts: 49
Joined: 26 Oct 2021, 01:35

Re: Inquiry for follow-path code

Post by Luis Nieto »

May I know what are the values that sim.getObjectOrientation returns please? And what they mean?

Thanks in advance.

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Inquiry for follow-path code

Post by coppelia »

Those are Euler angles

Cheers

Luis Nieto
Posts: 49
Joined: 26 Oct 2021, 01:35

Re: Inquiry for follow-path code

Post by Luis Nieto »

Would there be a way to execute sim.getObjectOrientation repeatedly during a simulation - like obtaining the alpha, beta and gamma of an selected object every instant or every so often during?

Thanks in advance for the advice.

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Inquiry for follow-path code

Post by coppelia »

Code: Select all

function sysCall_init()
    objectHandle=sim.getObject('.')
end

function sysCall_sensing()
    print(sim.getObjectOrientation(objectHandle,-1))
end
Cheers

Post Reply