diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c45febf..3045dc9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -149,6 +149,7 @@ endif() find_package(Boost REQUIRED COMPONENTS program_options) add_executable(mc_mujoco main.cpp) +target_compile_definitions(mc_mujoco PUBLIC MUJOCO_BIN_DIR="${MUJOCO_BIN_DIR}") target_link_libraries(mc_mujoco PRIVATE mc_mujoco_lib Boost::program_options Boost::disable_autolinking) diff --git a/src/main.cpp b/src/main.cpp index 2d48c0a..2dfe36b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,30 @@ namespace po = boost::program_options; bool render_state = true; +#define MUJOCO_PLUGIN_DIR "mujoco_plugin" + +void scanPluginLibraries() +{ +// define platform-specific strings +#if defined(_WIN32) || defined(__CYGWIN__) + const std::string sep = "\\"; +#else + const std::string sep = "/"; +#endif + + const std::string plugin_dir = MUJOCO_BIN_DIR + sep + MUJOCO_PLUGIN_DIR; + mj_loadAllPluginLibraries( + plugin_dir.c_str(), + +[](const char * filename, int first, int count) + { + std::printf("Plugins registered by library '%s':\n", filename); + for(int i = first; i < first + count; ++i) + { + std::printf(" %s\n", mjp_getPluginAtSlot(i)->name); + } + }); +} + void simulate(mc_mujoco::MjSim & mj_sim) { bool done = false; @@ -68,6 +92,9 @@ int main(int argc, char * argv[]) config.visualize_collisions = vm["with-collisions"].as(); } } + + scanPluginLibraries(); + mc_mujoco::MjSim mj_sim(config); std::thread simThread(simulate, std::ref(mj_sim));