Calculating Mass Inertia Matrix from URDF

Typically: "How do I... ", "How can I... " questions
Post Reply
ravi
Posts: 85
Joined: 24 Oct 2016, 08:00

Calculating Mass Inertia Matrix from URDF

Post by ravi »

Hi,

I want to calculate the Mass Inertia Matrix from URDF in Lua. Earlier, I was using pykdl [1] in ros (python), which has a function for calculating inertia matrix [2,3]. pykdl uses KDL structure internally, which can be initialized from URDF file.

The python library pykdl, internally uses Orocos Kinematics Dynamics library [4], which is written in CPP. At this moment, I can think of two possible solutions to calculate Mass Inertia Matrix from URDF file-

1. Write the code completely in Lua
2. Call the CPP library from Lua

In case of point 1, I need to first read the URDF (xml) file and construct the KDL structure. then using this structure calculate the Mass Inertia Matrix as done in [4]. This is looking like re-inventing the wheel again. In case of point 2, I doubt on the efficiency.

Any idea please.

References-
[1] http://wiki.ros.org/pykdl_utils
[2] https://github.com/gt-ros-pkg/hrl-kdl/b ... cs.py#L293
[3] https://github.com/rethink-kmaroney/bax ... ics.py#L68
[4] https://github.com/orocos/orocos_kinema ... am.cpp#L46


-
Thanks
coppelia
Site Admin
Posts: 10747
Joined: 14 Dec 2012, 00:25

Re: Calculating Mass Inertia Matrix from URDF

Post by coppelia »

Hello,

solution 2 seems the best. You can call a cpp function from Lua, if you write a small plugin that exports a new Lua function. Calling that Lua function will call-back a routine in your plugin. Have a look for instance how the plugin located in programming/v_repExtBubbleRob or programming/v_repExtPluginSkeleton works (or any other of the plugins located in that programming folder).

Cheers
ravi
Posts: 85
Joined: 24 Oct 2016, 08:00

Re: Calculating Mass Inertia Matrix from URDF

Post by ravi »

Seems feasible, although I haven't checked the references you have given above. Since, I am new to VREP, the plugin isn't clear to me, I need to read the documentation once again.
  • Other than that, in case of CPP code, it is present in form of compiled library .so file. Can you please briefly summarize by providing any sample code for calling .so file from plugin?
  • Also, at this moment of time, I am concerned about the communication between this plugin and main script, which is Non-threaded child script (Baxter). Because I am going to perform all the calculations in this file, which communicates to each Joint Control Callback Scripts through signals.
-
Thanks
coppelia
Site Admin
Posts: 10747
Joined: 14 Dec 2012, 00:25

Re: Calculating Mass Inertia Matrix from URDF

Post by coppelia »

You should check some online resources about how to integrate a shared library into your c/c++ project (i.e. your V-REP plugin). There are some plugin examples in the programming folder that do exactly this.

Now about communication between a script and your plugin: do not use signals. Use custom script commands. This is much more elegant and scalable. There also, you have examples in the 2 plugins I suggested in my previous post: you will for instance be able to do something like following, in any script:

Code: Select all

local data,someMoreData=simExtMyPlugin_doSomething(arg1,arg2,arg3)
Above will call a function in your plugin. That function can then execute some code, and return data.

Cheers
Post Reply