small progress towards shared memory C-api and test.c.
This commit is contained in:
@@ -1,6 +1,49 @@
|
||||
#include "PhysicsClientC_API.h"
|
||||
#include "PhysicsClient.h"
|
||||
#include "Bullet3Common/b3Scalar.h"
|
||||
#include <string.h>
|
||||
|
||||
int b3LoadUrdfCommandInit(struct SharedMemoryCommand* command, const char* urdfFileName)
|
||||
{
|
||||
b3Assert(command);
|
||||
command->m_type = CMD_LOAD_URDF;
|
||||
int len = strlen(urdfFileName);
|
||||
if (len<MAX_URDF_FILENAME_LENGTH)
|
||||
{
|
||||
strcpy(command->m_urdfArguments.m_urdfFileName,urdfFileName);
|
||||
} else
|
||||
{
|
||||
command->m_urdfArguments.m_urdfFileName[0] = 0;
|
||||
}
|
||||
command->m_updateFlags = URDF_ARGS_FILE_NAME;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int b3LoadUrdfCommandSetStartPosition(struct SharedMemoryCommand* command, double startPosX,double startPosY,double startPosZ)
|
||||
{
|
||||
b3Assert(command);
|
||||
b3Assert(command->m_type == CMD_LOAD_URDF);
|
||||
command->m_urdfArguments.m_initialPosition[0] = startPosX;
|
||||
command->m_urdfArguments.m_initialPosition[1] = startPosY;
|
||||
command->m_urdfArguments.m_initialPosition[2] = startPosZ;
|
||||
command->m_updateFlags|=URDF_ARGS_INITIAL_POSITION;
|
||||
return 0;
|
||||
}
|
||||
int b3LoadUrdfCommandSetStartOrientation(struct SharedMemoryCommand* command, double startOrnX,double startOrnY,double startOrnZ, double startOrnW)
|
||||
{
|
||||
b3Assert(command);
|
||||
b3Assert(command->m_type == CMD_LOAD_URDF);
|
||||
command->m_urdfArguments.m_initialOrientation[0] = startOrnX;
|
||||
command->m_urdfArguments.m_initialOrientation[1] = startOrnY;
|
||||
command->m_urdfArguments.m_initialOrientation[2] = startOrnZ;
|
||||
command->m_urdfArguments.m_initialOrientation[3] = startOrnW;
|
||||
command->m_updateFlags|=URDF_ARGS_INITIAL_ORIENTATION;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b3InitPhysicsParamCommand(struct SharedMemoryCommand* command)
|
||||
{
|
||||
@@ -20,6 +63,66 @@ int b3PhysicsParamSetGravity(struct SharedMemoryCommand* command, double gra
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b3PhysicsParamSetTimeStep(struct SharedMemoryCommand* command, double timeStep)
|
||||
{
|
||||
b3Assert(command->m_type == CMD_SEND_PHYSICS_SIMULATION_PARAMETERS);
|
||||
command->m_physSimParamArgs.m_deltaTime = timeStep;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b3InitStepSimulationCommand(struct SharedMemoryCommand* command)
|
||||
{
|
||||
b3Assert(command);
|
||||
command->m_type = CMD_STEP_FORWARD_SIMULATION;
|
||||
command->m_updateFlags = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
b3PhysicsClientHandle b3ConnectSharedMemory( int allowSharedMemoryInitialization)
|
||||
{
|
||||
PhysicsClientSharedMemory* cl = new PhysicsClientSharedMemory();
|
||||
cl->connect(allowSharedMemoryInitialization);
|
||||
return (b3PhysicsClientHandle ) cl;
|
||||
}
|
||||
|
||||
void b3DisconnectSharedMemory(b3PhysicsClientHandle physClient)
|
||||
{
|
||||
PhysicsClientSharedMemory* cl = (PhysicsClientSharedMemory* ) physClient;
|
||||
delete cl;
|
||||
}
|
||||
|
||||
int b3ProcessServerStatus(b3PhysicsClientHandle physClient, struct SharedMemoryStatus* status)
|
||||
{
|
||||
PhysicsClientSharedMemory* cl = (PhysicsClientSharedMemory* ) physClient;
|
||||
return (int)cl->processServerStatus(*status);
|
||||
}
|
||||
|
||||
int b3CanSubmitCommand(b3PhysicsClientHandle physClient)
|
||||
{
|
||||
PhysicsClientSharedMemory* cl = (PhysicsClientSharedMemory* ) physClient;
|
||||
return (int)cl->canSubmitCommand();
|
||||
}
|
||||
|
||||
int b3SubmitClientCommand(b3PhysicsClientHandle physClient, struct SharedMemoryCommand* command)
|
||||
{
|
||||
PhysicsClientSharedMemory* cl = (PhysicsClientSharedMemory* ) physClient;
|
||||
return (int)cl->submitClientCommand(*command);
|
||||
}
|
||||
|
||||
int b3GetNumJoints(b3PhysicsClientHandle physClient)
|
||||
{
|
||||
PhysicsClientSharedMemory* cl = (PhysicsClientSharedMemory* ) physClient;
|
||||
return cl->getNumPoweredJoints();
|
||||
}
|
||||
|
||||
void b3GetPoweredJointInfo(b3PhysicsClientHandle physClient, int linkIndex, struct PoweredJointInfo* info)
|
||||
{
|
||||
PhysicsClientSharedMemory* cl = (PhysicsClientSharedMemory* ) physClient;
|
||||
cl->getPoweredJointInfo(linkIndex,*info);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
#include "SharedMemoryBlock.h"
|
||||
|
||||
Reference in New Issue
Block a user