Retrieving Object position/size/etc from Remote API

Typically: "How do I... ", "How can I... " questions
engharat
Posts: 7
Joined: 18 Feb 2013, 12:22

Retrieving Object position/size/etc from Remote API

Hi,
I hope to not bother anyone with such a question: I know it can be done but I have some troubles figuring myself how to do that.
Basically I've linked V-rep with Matlab. The link is okey, as I can run the matlab test.m
What I have to do now is to send to Matlab the list of object in the scene,their type, their position and their size. For example I'm filling the scene with some walls and a robot; I have to send the walls position and width, height,etc to matlab in order to perform some calculations,and the robot status. Then matlab will send back some results.

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

Re: Retrieving Object position/size/etc from Remote API

Hello,

You will have to:

1) Retrieve the handle of your objects. Use something like this (C/C++ example):

Code: Select all

int objHandle;
if (simxGetObjectHandle("TheNameOfMyObject",&objHandle,simx_opmode_oneshot_wait)==simx_error_noerror)
{
// Here I have the handle of my object!
}
2) Assign a new position/orientation to your objects. Something like this:

Code: Select all

float newPos[3]={x,y,z};
simxSetObjectPosition(objHandle,-1,newPos,simx_opmode_oneshot);

Refer to simxGetObjectHandle and simxSetObjectPosition

Cheers

engharat
Posts: 7
Joined: 18 Feb 2013, 12:22

Re: Retrieving Object position/size/etc from Remote API

Hi I'm now stuck at how to get ibject size, i.e. bounding box size. I have to pass to matlab floor and walls sizes. Thanks

coppelia