Allow to load a urdf file in the testplugin.cpp, as first quick test, example pybullet script:
import pybullet as p
p.connect(p.GUI)
pluginUid = p.loadPlugin("E:/develop/bullet3/bin/pybullet_testplugin_vs2010_x64_debug.dll")
commandUid = 0
argument = "plane.urdf"
p.executePluginCommand(pluginUid,commandUid,argument)
p.unloadPlugin(pluginUid)
This commit is contained in:
@@ -78,7 +78,7 @@ struct PhysicsClientSharedMemoryInternalData {
|
||||
m_hasLastServerStatus(false),
|
||||
m_sharedMemoryKey(SHARED_MEMORY_KEY),
|
||||
m_verboseOutput(false),
|
||||
m_timeOutInSeconds(5)
|
||||
m_timeOutInSeconds(30)
|
||||
{}
|
||||
|
||||
void processServerStatus();
|
||||
|
||||
@@ -1516,8 +1516,8 @@ struct PhysicsServerCommandProcessorInternalData
|
||||
|
||||
b3HashMap<b3HashString, char*> m_profileEvents;
|
||||
|
||||
PhysicsServerCommandProcessorInternalData()
|
||||
:
|
||||
PhysicsServerCommandProcessorInternalData(PhysicsCommandProcessorInterface* proc)
|
||||
:m_pluginManager(proc),
|
||||
m_allowRealTimeSimulation(false),
|
||||
m_commandLogger(0),
|
||||
m_logPlayback(0),
|
||||
@@ -1647,8 +1647,9 @@ void PhysicsServerCommandProcessor::setGuiHelper(struct GUIHelperInterface* guiH
|
||||
|
||||
|
||||
PhysicsServerCommandProcessor::PhysicsServerCommandProcessor()
|
||||
:m_data(0)
|
||||
{
|
||||
m_data = new PhysicsServerCommandProcessorInternalData();
|
||||
m_data = new PhysicsServerCommandProcessorInternalData(this);
|
||||
|
||||
createEmptyDynamicsWorld();
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "Bullet3Common/b3ResizablePool.h"
|
||||
#include "plugins/b3PluginAPI.h"
|
||||
#include "SharedMemoryPublic.h"
|
||||
#include "PhysicsDirect.h"
|
||||
#include "plugins/b3PluginContext.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -50,15 +52,19 @@ struct b3PluginManagerInternalData
|
||||
{
|
||||
b3ResizablePool<b3PluginHandle> m_plugins;
|
||||
b3HashMap<b3HashString, b3PluginHandle> m_pluginMap;
|
||||
PhysicsDirect* m_physicsDirect;
|
||||
};
|
||||
|
||||
b3PluginManager::b3PluginManager()
|
||||
b3PluginManager::b3PluginManager(class PhysicsCommandProcessorInterface* physSdk)
|
||||
{
|
||||
m_data = new b3PluginManagerInternalData;
|
||||
m_data->m_physicsDirect = new PhysicsDirect(physSdk,false);
|
||||
|
||||
}
|
||||
|
||||
b3PluginManager::~b3PluginManager()
|
||||
{
|
||||
delete m_data->m_physicsDirect;
|
||||
m_data->m_pluginMap.clear();
|
||||
m_data->m_plugins.exitHandles();
|
||||
delete m_data;
|
||||
@@ -145,7 +151,10 @@ int b3PluginManager::executePluginCommand(int pluginUniqueId, const char* argume
|
||||
b3PluginHandle* plugin = m_data->m_plugins.getHandle(pluginUniqueId);
|
||||
if (plugin)
|
||||
{
|
||||
result = plugin->m_executeCommandFunc(arguments);
|
||||
b3PluginContext context;
|
||||
context.m_arguments = arguments;
|
||||
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
||||
result = plugin->m_executeCommandFunc(&context);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class b3PluginManager
|
||||
|
||||
public:
|
||||
|
||||
b3PluginManager();
|
||||
b3PluginManager(class PhysicsCommandProcessorInterface* physSdk);
|
||||
virtual ~b3PluginManager();
|
||||
|
||||
int loadPlugin(const char* pluginPath);
|
||||
|
||||
@@ -28,7 +28,7 @@ extern "C" {
|
||||
/* Plugin API */
|
||||
typedef B3_API_ENTRY int (B3_API_CALL * PFN_INIT)();
|
||||
typedef B3_API_ENTRY void (B3_API_CALL * PFN_EXIT)();
|
||||
typedef B3_API_ENTRY int (B3_API_CALL * PFN_EXECUTE)(const char* arguments);
|
||||
typedef B3_API_ENTRY int (B3_API_CALL * PFN_EXECUTE)(struct b3PluginContext* context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
13
examples/SharedMemory/plugins/b3PluginContext.h
Normal file
13
examples/SharedMemory/plugins/b3PluginContext.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef B3_PLUGIN_CONTEXT_H
|
||||
#define B3_PLUGIN_CONTEXT_H
|
||||
|
||||
#include "../PhysicsClientC_API.h"
|
||||
|
||||
struct b3PluginContext
|
||||
{
|
||||
const char* m_arguments;
|
||||
|
||||
b3PhysicsClientHandle m_physClient;
|
||||
};
|
||||
|
||||
#endif //B3_PLUGIN_CONTEXT_H
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "testplugin.h"
|
||||
#include "../../SharedMemoryPublic.h"
|
||||
|
||||
#include "../b3PluginContext.h"
|
||||
#include <stdio.h>
|
||||
|
||||
B3_SHARED_API int initPlugin()
|
||||
@@ -10,10 +10,24 @@ B3_SHARED_API int initPlugin()
|
||||
return SHARED_MEMORY_MAGIC_NUMBER;
|
||||
}
|
||||
|
||||
B3_SHARED_API int executePluginCommand(const char* arguments)
|
||||
B3_SHARED_API int executePluginCommand(struct b3PluginContext* context)
|
||||
{
|
||||
printf("arguments:%s\n",arguments);
|
||||
return 42;
|
||||
printf("arguments:%s\n",context->m_arguments);
|
||||
|
||||
b3SharedMemoryStatusHandle statusHandle;
|
||||
int statusType = -1;
|
||||
int bodyUniqueId = -1;
|
||||
|
||||
b3SharedMemoryCommandHandle command =
|
||||
b3LoadUrdfCommandInit(context->m_physClient, context->m_arguments);
|
||||
|
||||
statusHandle = b3SubmitClientCommandAndWaitStatus(context->m_physClient, command);
|
||||
statusType = b3GetStatusType(statusHandle);
|
||||
if (statusType == CMD_URDF_LOADING_COMPLETED)
|
||||
{
|
||||
bodyUniqueId = b3GetStatusBodyIndex(statusHandle);
|
||||
}
|
||||
return bodyUniqueId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ extern "C"
|
||||
|
||||
B3_SHARED_API int initPlugin();
|
||||
B3_SHARED_API void exitPlugin();
|
||||
B3_SHARED_API int executePluginCommand(const char* arguments);
|
||||
B3_SHARED_API int executePluginCommand(struct b3PluginContext* context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user