Page 1 of 1

Parametric model of robot arm

Posted: 28 Jan 2019, 11:38
by MajorTom
Hi,

I am trying to find an easy way to create a model of a robotic arm where I can change the size of the links (lenght and diameter of cylinder) but the only way I could come up with to do this is to use the createPureShape, setObjectPosition, setObjectParent, etc. functions.

This is very cumbersome and therefore I wanted to ask if there exists a more elegant solution ?

Best regards

Re: Parametric model of robot arm

Posted: 28 Jan 2019, 15:29
by coppelia
Hello,

yes, you can use sim.scaleObject. You might have to previously gather the current object size if you want to set a specific size, instead of just scaling the object. Following could help:

Code: Select all

function model.setObjectSize(h,x,y,z)
    local r,mmin=sim.getObjectFloatParameter(h,sim.objfloatparam_objbbox_min_x)
    local r,mmax=sim.getObjectFloatParameter(h,sim.objfloatparam_objbbox_max_x)
    local sx=mmax-mmin
    local r,mmin=sim.getObjectFloatParameter(h,sim.objfloatparam_objbbox_min_y)
    local r,mmax=sim.getObjectFloatParameter(h,sim.objfloatparam_objbbox_max_y)
    local sy=mmax-mmin
    local r,mmin=sim.getObjectFloatParameter(h,sim.objfloatparam_objbbox_min_z)
    local r,mmax=sim.getObjectFloatParameter(h,sim.objfloatparam_objbbox_max_z)
    local sz=mmax-mmin
    sim.scaleObject(h,x/sx,y/sy,z/sz)
end
Some primitive shapes, compound shapes, and most other objects can only be isometrically scaled.

Cheers

Re: Parametric model of robot arm

Posted: 29 Jan 2019, 11:02
by MajorTom
Hi,

thanks for the fast response but using this approach will cause simulation issues as the absolute position of the parent and child object will remain the same and if the parent object is up scaled then the two intersect.

So basically I would have to rectify the position of the entire robotic arm links and joints which will cost me the same effort as creating an entirely new model from scratch, or am I missing something ?

Cheers

Re: Parametric model of robot arm

Posted: 29 Jan 2019, 14:26
by coppelia
Yes, you will have to adjust the position of the scaled shapes, including the position of its children. This can be tricky, but once set-up and combined with a customization script and custom UIs, then you can quickly configure your arm via the user interface. Have a look at the model models/robots/non-mobile/ragnar.brm

Cheers

Re: Parametric model of robot arm

Posted: 29 Jan 2019, 17:01
by MajorTom
The ragnar model is a lot of help.

Thank you!

Cheers