How to run a plugin function from Lua script (e.g. simURDF plugin)

Typically: "How do I... ", "How can I... " questions
Post Reply
Adrian
Posts: 12
Joined: 22 Jun 2018, 23:03
Contact:

How to run a plugin function from Lua script (e.g. simURDF plugin)

Post by Adrian »

Hi!

The URDF import tool is very useful and I used it many times with the GUI!

I am currently trying to use the same importer from within a LUA script in V-REP (so no GUI wanted). I tried to execute the following command in a child script as well and inside the VREP status bar terminal:
simURDF.importFile('path/to/urdf/file', true, true, false, false, false, false, false, true, false)

For some reason my programmatical approach gives me the following error:
> simURDF.importFile(pathToUrdf, true, true, false, false, false, false, false, true, false)
"[string "SANDBOX SCRIPT"]:1: Argument 6 is not correct. (simURDF.importFile @ 'Urdf' plugin)""
I tried different combinations of boolean values for the input arguments, but the error I get is always about argument 6.
What am I doing wrong? Am I maybe supposed to use sim.callScriptFunction instead to make this work?

Best,
Adrian

Example URDF:

Code: Select all

<?xml version="1.0"?>

<robot name="myfirst">
  <link name="base_link">
    <visual>
      <geometry>
        <cylinder length="0.6" radius="0.2"/>
      </geometry>
    </visual>
  </link>
</robot>

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

Re: How to run a plugin function from Lua script (e.g. simURDF plugin)

Post by coppelia »

Hello Adrian,

the import API indeed has a bug. It should be in file v_repExtURDF.cpp:

Code: Select all

const int inArgs_IMPORT[]={
    10,
    sim_script_arg_string,0, // filenameAndPath or URDF contents
    sim_script_arg_bool,0, // assign collision links to layer 9
    sim_script_arg_bool,0, // assign joints to layer 10
    sim_script_arg_bool,0, // convex decompose
    sim_script_arg_bool,0, // create visual links if none
    sim_script_arg_bool,0, // show convex decomposition dialog
    sim_script_arg_bool,0, // center model above ground
    sim_script_arg_bool,0, // prepare model definition if feasible
    sim_script_arg_bool,0, // alternate local respondable masks
    sim_script_arg_bool,0  // enable position control for revolute and prismatic joints
};
Can you try to recompile and see if that fixed it?
Thanks again for pointing onto that bug,
Cheers

Adrian
Posts: 12
Joined: 22 Jun 2018, 23:03
Contact:

Re: How to run a plugin function from Lua script (e.g. simURDF plugin)

Post by Adrian »

Your change fixed my issue! Thank you for the quick answer!

Adrian

Post Reply