Page 1 of 1

Get joint velocity

Posted: 21 Feb 2013, 18:58
by nikolaus
I am trying to read the velocity of a joint, and I'm having trouble. I am using the following code:

Code: Select all

handle = simGetObjectAssociatedWithScript(sim_handle_self)
print(simGetObjectFloatParameter(handle, 2012))
The "2012" comes from here:

Code: Select all

2012: float parameter (can only be read) : joint velocity. This is a calculated value.
For some reason, though, it always just prints "1" instead of the joint velocity. Is this the incorrect parameter number to be using?
Thanks!

Re: Get joint velocity

Posted: 22 Feb 2013, 10:59
by coppelia
Hello,

this is not a bug. According to the function documentation, the function returns the desired value as the second return value in Lua:

result,value=simGetObjectFloatParameter(handle,2012)

Cheers

Re: Get joint velocity

Posted: 24 Feb 2013, 21:53
by nikolaus
Oh, I can't believe I missed that! Thanks a lot.

Re: Get joint velocity

Posted: 02 Aug 2013, 02:12
by Pikapi
May i know where is the print value displayed? How to display it at simulation? Thanks.

Re: Get joint velocity

Posted: 02 Aug 2013, 10:07
by coppelia
Hello,

Please make a new topic instead of reviving old ones.
From within a child script, or from within a plugin, the output of print or printf commands go to the console.
  • on Windows, the console is hidden by default. You can make it visible via the user settings dialog.
  • on Mac, the output goes to the system console, but are delayed. The best is to open a terminal, start V-REP with ./vrep.app/Contents/MacOS/vrep. Then all the console outputs are correctly displayed.
  • on Linux, the output goes to the console/terminal from where you start V-REP
Cheers

Re: Get joint velocity

Posted: 02 Aug 2013, 12:03
by Pikapi
Thanks a lot for help!