Get joint velocity

Report crashes, strange behaviour, or apparent bugs
Post Reply
nikolaus
Posts: 18
Joined: 13 Feb 2013, 23:17

Get joint velocity

Post by nikolaus » 21 Feb 2013, 18:58

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!

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

Re: Get joint velocity

Post by coppelia » 22 Feb 2013, 10:59

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

nikolaus
Posts: 18
Joined: 13 Feb 2013, 23:17

Re: Get joint velocity

Post by nikolaus » 24 Feb 2013, 21:53

Oh, I can't believe I missed that! Thanks a lot.

Pikapi
Posts: 14
Joined: 31 Jul 2013, 09:26

Re: Get joint velocity

Post by Pikapi » 02 Aug 2013, 02:12

May i know where is the print value displayed? How to display it at simulation? Thanks.

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

Re: Get joint velocity

Post by coppelia » 02 Aug 2013, 10:07

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

Pikapi
Posts: 14
Joined: 31 Jul 2013, 09:26

Re: Get joint velocity

Post by Pikapi » 02 Aug 2013, 12:03

Thanks a lot for help!

Post Reply