## Parametric model of robot arm

Typically: "How do I... ", "How can I... " questions
MajorTom
Posts: 4
Joined: 21 Jan 2019, 10:31

### Parametric model of robot arm

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

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

### Re: Parametric model of robot arm

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

MajorTom
Posts: 4
Joined: 21 Jan 2019, 10:31

### Re: Parametric model of robot arm

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

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

### Re: Parametric model of robot arm

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

MajorTom
Posts: 4
Joined: 21 Jan 2019, 10:31

### Re: Parametric model of robot arm

The ragnar model is a lot of help.

Thank you!

Cheers