2016-07-11 07:26:40 +00:00
|
|
|
#ifndef B3_ROBOT_SIM_API_H
|
|
|
|
#define B3_ROBOT_SIM_API_H
|
|
|
|
|
|
|
|
///todo: remove those includes from this header
|
|
|
|
#include "../SharedMemory/PhysicsClientC_API.h"
|
|
|
|
#include "../SharedMemory/SharedMemoryPublic.h"
|
|
|
|
#include "Bullet3Common/b3Vector3.h"
|
|
|
|
#include "Bullet3Common/b3Quaternion.h"
|
2016-07-14 07:05:57 +00:00
|
|
|
#include "Bullet3Common/b3AlignedObjectArray.h"
|
|
|
|
|
2016-07-11 07:26:40 +00:00
|
|
|
#include <string>
|
|
|
|
|
2016-07-14 07:05:57 +00:00
|
|
|
enum b3RigidSimFileType
|
|
|
|
{
|
|
|
|
B3_URDF_FILE=1,
|
|
|
|
B3_SDF_FILE,
|
|
|
|
B3_AUTO_DETECT_FILE//todo based on extension
|
|
|
|
};
|
2016-07-11 07:26:40 +00:00
|
|
|
|
2016-07-14 07:05:57 +00:00
|
|
|
struct b3RobotSimLoadFileArgs
|
2016-07-11 07:26:40 +00:00
|
|
|
{
|
2016-07-14 07:05:57 +00:00
|
|
|
std::string m_fileName;
|
2016-07-11 07:26:40 +00:00
|
|
|
b3Vector3 m_startPosition;
|
|
|
|
b3Quaternion m_startOrientation;
|
|
|
|
bool m_forceOverrideFixedBase;
|
2016-08-16 23:57:48 +00:00
|
|
|
bool m_useMultiBody;
|
2016-07-14 07:05:57 +00:00
|
|
|
int m_fileType;
|
2016-07-11 07:26:40 +00:00
|
|
|
|
|
|
|
|
2016-07-14 07:05:57 +00:00
|
|
|
b3RobotSimLoadFileArgs(const std::string& fileName)
|
|
|
|
:m_fileName(fileName),
|
2016-07-11 07:26:40 +00:00
|
|
|
m_startPosition(b3MakeVector3(0,0,0)),
|
|
|
|
m_startOrientation(b3Quaternion(0,0,0,1)),
|
2016-07-14 07:05:57 +00:00
|
|
|
m_forceOverrideFixedBase(false),
|
2016-08-29 19:35:02 +00:00
|
|
|
m_useMultiBody(true),
|
2016-07-14 07:05:57 +00:00
|
|
|
m_fileType(B3_URDF_FILE)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct b3RobotSimLoadFileResults
|
|
|
|
{
|
|
|
|
b3AlignedObjectArray<int> m_uniqueObjectIds;
|
|
|
|
b3RobotSimLoadFileResults()
|
2016-07-11 07:26:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct b3JointMotorArgs
|
|
|
|
{
|
|
|
|
int m_controlMode;
|
|
|
|
|
|
|
|
double m_targetPosition;
|
|
|
|
double m_kp;
|
|
|
|
|
|
|
|
double m_targetVelocity;
|
|
|
|
double m_kd;
|
|
|
|
|
|
|
|
double m_maxTorqueValue;
|
|
|
|
|
|
|
|
b3JointMotorArgs(int controlMode)
|
|
|
|
:m_controlMode(controlMode),
|
|
|
|
m_targetPosition(0),
|
|
|
|
m_kp(0.1),
|
|
|
|
m_targetVelocity(0),
|
2016-07-25 18:48:44 +00:00
|
|
|
m_kd(0.9),
|
2016-07-11 07:26:40 +00:00
|
|
|
m_maxTorqueValue(1000)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class b3RobotSimAPI
|
|
|
|
{
|
|
|
|
struct b3RobotSimAPI_InternalData* m_data;
|
|
|
|
void processMultiThreadedGraphicsRequests();
|
|
|
|
b3SharedMemoryStatusHandle submitClientCommandAndWaitStatusMultiThreaded(b3PhysicsClientHandle physClient, b3SharedMemoryCommandHandle commandHandle);
|
|
|
|
|
|
|
|
public:
|
|
|
|
b3RobotSimAPI();
|
|
|
|
virtual ~b3RobotSimAPI();
|
|
|
|
|
|
|
|
bool connect(struct GUIHelperInterface* guiHelper);
|
|
|
|
void disconnect();
|
|
|
|
|
2016-07-14 16:49:49 +00:00
|
|
|
bool loadFile(const struct b3RobotSimLoadFileArgs& args, b3RobotSimLoadFileResults& results);
|
2016-07-11 07:26:40 +00:00
|
|
|
|
|
|
|
int getNumJoints(int bodyUniqueId) const;
|
|
|
|
|
|
|
|
bool getJointInfo(int bodyUniqueId, int jointIndex, b3JointInfo* jointInfo);
|
2016-08-23 01:14:29 +00:00
|
|
|
|
2016-08-24 19:44:24 +00:00
|
|
|
void createJoint(int parentBodyIndex, int parentJointIndex, int childBodyIndex, int childJointIndex, b3JointInfo* jointInfo);
|
2016-07-11 07:26:40 +00:00
|
|
|
|
|
|
|
void setJointMotorControl(int bodyUniqueId, int jointIndex, const struct b3JointMotorArgs& args);
|
|
|
|
|
|
|
|
void stepSimulation();
|
|
|
|
|
|
|
|
void setGravity(const b3Vector3& gravityAcceleration);
|
2016-08-24 21:25:06 +00:00
|
|
|
|
|
|
|
void setNumSimulationSubSteps(int numSubSteps);
|
2016-07-11 07:26:40 +00:00
|
|
|
|
|
|
|
void renderScene();
|
2016-08-19 17:30:02 +00:00
|
|
|
void debugDraw(int debugDrawMode);
|
2016-07-11 07:26:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //B3_ROBOT_SIM_API_H
|