sim.getObjectPosition

Typically: "How do I... ", "How can I... " questions
Post Reply
Sirena
Posts: 4
Joined: 30 Oct 2018, 16:54

sim.getObjectPosition

Post by Sirena »

hi guys!
I'm using vrep with matlab through ROS to simulate a drone.
To implement the control strategy in Matlab I need the signals from the sensors and the speed and position of my drone, changing in time during the simulation.
In Simulink and Matlab the data of sensors are available with the same values in Vrep, but the position and speed values are still the same (I mean the start conditon).
I used suggestions that I found in other topics, to use LUA command sim.getObjectposition and sim.getVelocity.
These are my commands:
sim.getObjectPosition(sim.getObjectHandle("Hexacopter"),-1)
sim.getVelocity(hexaHandle)
In your opinion, are there something wrong?
Thanks for yours support and suggestions
Sirena

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

Re: sim.getObjectPosition

Post by coppelia »

Hello,

how exactly are you using those commands from Matlab? Via blocking call or streaming?

Cheers

Sirena
Posts: 4
Joined: 30 Oct 2018, 16:54

Re: sim.getObjectPosition

Post by Sirena »

Hello,
I'm using ROS to let Simulink and V-rep communicate.
I tried to use the remote API via blocking call, but I understood that it isn't possible to enter data directly in Simulink.

Thanks for your assistance,

Sirena

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

Re: sim.getObjectPosition

Post by coppelia »

Are you using the correct values for publishing? e.g. is the object really moving, or are you mistakenly using the handle of an object that is not moving? Try adding print directives just before publishing the data to see what the data is, and so that you can locate where the problem occurs.

Cheers

Sirena
Posts: 4
Joined: 30 Oct 2018, 16:54

Re: sim.getObjectPosition

Post by Sirena »

Hi!
I tried your suggestion. As you said, on the console in V-rep I can see the same values I read on Simulink display. (These values are different from zero, as in the initial condition.)
At the same time I added a graph with the object position and Z-velocity and these values change during the simulation. So the object is really moving.
What can I do now? Is there anything wrong with the reference frames?

Regards,

Sirena

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

Re: sim.getObjectPosition

Post by coppelia »

Best would be to prepare a minimalistic, self-contained example that illustrates your problem (e.g. a scene when you print the values to the console, and where you draw the same values to a graph).

Cheers

Sirena
Posts: 4
Joined: 30 Oct 2018, 16:54

Re: sim.getObjectPosition

Post by Sirena »

Unfortunately I have already tried with a simplified example: a cube that moved from its original position to another one. And the result of the prevoius commands was still the initial condition, even if the cube was moving.
However today I probably found the solution for the problem: the command strings were under sysCall_actuation and not under sysCall_sensing. After this change, now my commands seem to work correctly.
Thanks for your help,

Sirena

DOUNIA1
Posts: 1
Joined: 19 Nov 2018, 17:39

Re: sim.getObjectPosition

Post by DOUNIA1 »

Hi Serina,

I have the same problem, I'm using vrep with matlab through ROS to simulate a quadcopter. I 'm using ROS indigo, Vrep 4.0 and matlab 2017a. I read the data on simulink from vrep ( position/orientation of quadcopter and the targert '' green cercle"), and I calculate the command on simulink and send it to vrep, but the quadcopter didn't stop and keep rising, I'm sure that my control is correct, I don't know where is the problem?? Please could you tell me how did you fix your problem.

Kind regards

Post Reply