Develop plugin for Coppelia Sim using LibPlugin

Typically: "How do I... ", "How can I... " questions
Florent
Posts: 14
Joined: 20 Mar 2020, 23:22

Develop plugin for Coppelia Sim using LibPlugin

Post by Florent »

Hello,

I would like to develop a plugin for coppeliaSim but I have some problems. And several github pages are pointing to the ReadMe of the libPlugin but every links are 404 errors.
The link: https://github.com/CoppeliaRobotics/sim ... /README.md
Where can we find this ReadMe file. I think that there are precious informations inside it. For example, I am not able to compile the simExtSkeletonNG using cmake.

Thanks for your help,

Best regards

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Develop plugin for Coppelia Sim using LibPlugin

Post by fferri »

If you are having some build issue you should post the relevant output, and provide additional details about your environment, OS, etc, in order to get some help.

libPlugin is a framework used by many plugins, consisting (currently) of three parts:
  • simPlusPlus: some C++ stuff to ease the writing of a plugin by providing an object-oriented interface to some parts of the CoppeliaSim C++ API. See README for more details.
  • simStubsGen: a code generator that will generate html documentation and boilerplate code to read/write arguments of Lua callbacks, given an input XML file. See README for more details.
  • a cmake module for finding CoppeliaSim stuff and performing build tasks required to build plugins.
simExtPluginSkeletonNG is a simple usage example of all of the above.

Florent
Posts: 14
Joined: 20 Mar 2020, 23:22

Re: Develop plugin for Coppelia Sim using LibPlugin

Post by Florent »

For example, when I try to compile simExtSkeletonNG plugin using CMake, I get the error CoppeliaSim_DIR-NOTFOUND. Then I point to the cmake file at this path: C:\Program Files\CoppeliaRobotics\CoppeliaSimEdu\programming\libPlugin\cmake.
But still, the error remains. I don't know I should put the simExtPluginSkeletonNG folder before compiling it.

To be honest, I am a little bit lost on how to compile the source code using CMake. How should I use the file FindCoppeliaSim.cmake. And also how to use these 3 folders you pointed on Libplugin. This is why I wanted to compile the example simExtPluginSkeletonNG before starting writing code.

Image
Image

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Develop plugin for Coppelia Sim using LibPlugin

Post by fferri »

If you stick with the standard layout it should build without any extra settings: just put simExtPluginSkeletonNG and libPlugin in the CoppeliaSim's programming subdirectory.

Otherwise you need to specify the LIBPLUGIN_DIR CMake variable and/or the COPPELIASIM_ROOT_DIR environment variable.

Florent
Posts: 14
Joined: 20 Mar 2020, 23:22

Re: Develop plugin for Coppelia Sim using LibPlugin

Post by Florent »

I figured out how to go further, I had to define new entries and then define manually the paths of:
- LIBPLUGIN_DIR
- COPPELIASIM_ROOT_DIR

Which compiler do you use with Cmake? Do you use visual studio or something else?

Thank you,

Florent
Posts: 14
Joined: 20 Mar 2020, 23:22

Re: Develop plugin for Coppelia Sim using LibPlugin

Post by Florent »

When I open the created visual studio project, there is a problem with the statement #py. I think that you created the PyCPP. Is there a way to integrate it in visual studio?

Thank you,

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Develop plugin for Coppelia Sim using LibPlugin

Post by fferri »

Nope. PyCPP is a custom preprocessor, and no IDE has support for its syntax. However it is integrated in the CMake build, and it will generate the .cpp files which can be compiled by your compiler.
PyCPP tempates should not (directly) be part of the project. Which file is that?

Florent
Posts: 14
Joined: 20 Mar 2020, 23:22

Re: Develop plugin for Coppelia Sim using LibPlugin

Post by Florent »

The file stubs.h that the project included was the one inside libPlugin\simStubsGen\cpp. This one is the one containing the #pi preprocessor statement.
Inside the plugin I changed the #include "simStubsGen/cpp/stubs.h" path to #include "generated/stubs.h" and it solved the problem. I was able to compile the plugin with Visual Studio.
To sum up everything for the next, this is what I did:
- Add the Entry LIBPLUGIN_DIR to the path to the libplugin before configure with Cmake
- Change the #include "simStubsGen/cpp/stubs.h" to #include "generated/stubs.h" into plugin.cpp after generating the project with Cmake

Edit: I am coding with visual studio. Afterward I compiled the project and get the dll. It worked fine into CoppeliaSim

Thanks for your help.

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Develop plugin for Coppelia Sim using LibPlugin

Post by fferri »

Florent wrote: 24 Mar 2020, 16:45 - Change the #include "simStubsGen/cpp/stubs.h" to #include "generated/stubs.h" into plugin.cpp after generating the project with Cmake
There's no such #include in simExtPluginSkeletonNG.

simExtPluginSkeletonNG #includes "stubs.h", and since $CMAKE_BINARY_DIR/generated is added to the include path, stubs.h is found there.

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

Re: Develop plugin for Coppelia Sim using LibPlugin

Post by coppelia »

Hello Florent,

you can always try your hands with another approach to writing a CoppeliaSim plugin, without libPlugin (it is a little bit more verbose, but maybe easier to understand). There are several examples available, e.g. simExtPluginSkeleton, simExtVision, simExtRRS1, etc.

Cheers

Post Reply