2015-06-21 20:24:36 +00:00
# ifndef SHARED_MEMORY_COMMANDS_H
# define SHARED_MEMORY_COMMANDS_H
//this is a very experimental draft of commands. We will iterate on this API (commands, arguments etc)
2015-09-17 06:09:10 +00:00
# include "SharedMemoryPublic.h"
2015-07-15 22:23:40 +00:00
# ifdef __GNUC__
# include <stdint.h>
typedef int32_t smInt32_t ;
typedef int64_t smInt64_t ;
typedef uint32_t smUint32_t ;
typedef uint64_t smUint64_t ;
# elif defined(_MSC_VER)
typedef __int32 smInt32_t ;
typedef __int64 smInt64_t ;
typedef unsigned __int32 smUint32_t ;
typedef unsigned __int64 smUint64_t ;
# else
typedef int smInt32_t ;
typedef long long int smInt64_t ;
typedef unsigned int smUint32_t ;
typedef unsigned long long int smUint64_t ;
# endif
2015-06-21 20:24:36 +00:00
# define SHARED_MEMORY_SERVER_TEST_C
2015-08-02 21:00:43 +00:00
# define MAX_DEGREE_OF_FREEDOM 256
# define MAX_NUM_SENSORS 256
2015-06-21 20:24:36 +00:00
# define MAX_URDF_FILENAME_LENGTH 1024
2015-08-20 05:51:16 +00:00
# define MAX_FILENAME_LENGTH MAX_URDF_FILENAME_LENGTH
2015-06-21 20:24:36 +00:00
2015-07-31 06:22:44 +00:00
enum EnumUrdfArgsUpdateFlags
{
URDF_ARGS_FILE_NAME = 1 ,
URDF_ARGS_INITIAL_POSITION = 2 ,
URDF_ARGS_INITIAL_ORIENTATION = 4 ,
URDF_ARGS_USE_MULTIBODY = 8 ,
URDF_ARGS_USE_FIXED_BASE = 16 ,
} ;
2015-06-21 20:24:36 +00:00
struct UrdfArgs
{
2015-07-23 18:51:25 +00:00
char m_urdfFileName [ MAX_URDF_FILENAME_LENGTH ] ;
double m_initialPosition [ 3 ] ;
double m_initialOrientation [ 4 ] ;
int m_useMultiBody ;
int m_useFixedBase ;
2015-06-21 20:24:36 +00:00
} ;
2015-07-09 21:04:58 +00:00
struct BulletDataStreamArgs
{
2015-08-20 05:51:16 +00:00
char m_bulletFileName [ MAX_FILENAME_LENGTH ] ;
2015-07-09 21:04:58 +00:00
int m_streamChunkLength ;
2015-07-21 06:35:29 +00:00
int m_bodyUniqueId ;
2015-07-09 21:04:58 +00:00
} ;
2015-06-22 22:30:57 +00:00
struct SetJointFeedbackArgs
{
int m_bodyUniqueId ;
int m_linkId ;
2015-07-23 18:51:25 +00:00
int m_isEnabled ;
2015-06-22 22:30:57 +00:00
} ;
2015-10-14 05:23:28 +00:00
enum EnumInitPoseFlags
{
INIT_POSE_HAS_INITIAL_POSITION = 1 ,
INIT_POSE_HAS_INITIAL_ORIENTATION = 2 ,
INIT_POSE_HAS_JOINT_STATE = 4
} ;
2015-09-17 06:09:10 +00:00
2015-07-14 15:34:02 +00:00
2015-07-22 04:46:28 +00:00
///InitPoseArgs is mainly to initialize (teleport) the robot in a particular position
///No motors or controls are needed to initialize the pose. It is similar to
///moving a robot to a starting place, while it is switched off. It is only called
///at the start of a robot control session. All velocities and control forces are cleared to zero.
struct InitPoseArgs
{
int m_bodyUniqueId ;
double m_initialStateQ [ MAX_DEGREE_OF_FREEDOM ] ;
} ;
2015-08-20 05:51:16 +00:00
struct RequestDebugLinesArgs
{
int m_debugMode ;
2015-09-03 21:18:22 +00:00
int m_startingLineIndex ;
2015-08-20 05:51:16 +00:00
} ;
struct SendDebugLinesArgs
{
2015-09-03 21:18:22 +00:00
int m_startingLineIndex ;
2015-08-20 05:51:16 +00:00
int m_numDebugLines ;
2015-09-03 21:18:22 +00:00
int m_numRemainingDebugLines ;
2015-08-20 05:51:16 +00:00
} ;
2015-09-25 05:42:22 +00:00
struct PickBodyArgs
{
double m_rayFromWorld [ 3 ] ;
double m_rayToWorld [ 3 ] ;
} ;
2015-08-20 05:51:16 +00:00
2015-07-22 04:46:28 +00:00
///Controlling a robot involves sending the desired state to its joint motor controllers.
///The control mode determines the state variables used for motor control.
2015-06-21 20:24:36 +00:00
struct SendDesiredStateArgs
{
int m_bodyUniqueId ;
2015-07-14 15:34:02 +00:00
int m_controlMode ;
2015-07-15 22:23:40 +00:00
2015-08-20 05:51:16 +00:00
//PD parameters in case m_controlMode == CONTROL_MODE_POSITION_VELOCITY_PD
double m_Kp [ MAX_DEGREE_OF_FREEDOM ] ; //indexed by degree of freedom, 6 for base, and then the dofs for each link
double m_Kd [ MAX_DEGREE_OF_FREEDOM ] ; //indexed by degree of freedom, 6 for base, and then the dofs for each link
2015-07-15 22:23:40 +00:00
//desired state is only written by the client, read-only access by server is expected
2015-08-20 05:51:16 +00:00
//m_desiredStateQ is indexed by position variables,
//starting with 3 base position variables, 4 base orientation variables (quaternion), then link position variables
2015-07-15 22:23:40 +00:00
double m_desiredStateQ [ MAX_DEGREE_OF_FREEDOM ] ;
2015-08-20 05:51:16 +00:00
//m_desiredStateQdot is index by velocity degrees of freedom, 3 linear and 3 angular variables for the base and then link velocity variables
2015-07-15 22:23:40 +00:00
double m_desiredStateQdot [ MAX_DEGREE_OF_FREEDOM ] ;
//m_desiredStateForceTorque is either the actual applied force/torque (in CONTROL_MODE_TORQUE) or
2015-08-20 05:51:16 +00:00
//or the maximum applied force/torque for the PD/motor/constraint to reach the desired velocity in CONTROL_MODE_VELOCITY and CONTROL_MODE_POSITION_VELOCITY_PD mode
//indexed by degree of freedom, 6 dof base, and then dofs for each link
2015-07-15 22:23:40 +00:00
double m_desiredStateForceTorque [ MAX_DEGREE_OF_FREEDOM ] ;
2015-06-21 20:24:36 +00:00
} ;
2015-07-22 04:46:28 +00:00
2015-07-31 06:22:44 +00:00
enum EnumSimParamUpdateFlags
2015-07-22 04:46:28 +00:00
{
SIM_PARAM_UPDATE_DELTA_TIME = 1 ,
SIM_PARAM_UPDATE_GRAVITY = 2 ,
SIM_PARAM_UPDATE_NUM_SOLVER_ITERATIONS = 4 ,
SIM_PARAM_UPDATE_NUM_SIMULATION_SUB_STEPS = 8 ,
} ;
///Controlling a robot involves sending the desired state to its joint motor controllers.
///The control mode determines the state variables used for motor control.
struct SendPhysicsSimulationParameters
{
double m_deltaTime ;
double m_gravityAcceleration [ 3 ] ;
int m_numSimulationSubSteps ;
int m_numSolverIterations ;
} ;
2015-06-21 20:24:36 +00:00
struct RequestActualStateArgs
{
int m_bodyUniqueId ;
} ;
2015-06-22 22:30:57 +00:00
2015-06-21 20:24:36 +00:00
struct SendActualStateArgs
{
int m_bodyUniqueId ;
int m_numDegreeOfFreedomQ ;
int m_numDegreeOfFreedomU ;
2015-07-15 22:23:40 +00:00
2015-09-03 21:18:22 +00:00
double m_rootLocalInertialFrame [ 7 ] ;
2015-07-15 22:23:40 +00:00
//actual state is only written by the server, read-only access by client is expected
double m_actualStateQ [ MAX_DEGREE_OF_FREEDOM ] ;
double m_actualStateQdot [ MAX_DEGREE_OF_FREEDOM ] ;
2015-08-02 21:00:43 +00:00
//measured 6DOF force/torque sensors: force[x,y,z] and torque[x,y,z]
double m_jointReactionForces [ 6 * MAX_DEGREE_OF_FREEDOM ] ;
2015-07-15 22:23:40 +00:00
2015-06-21 20:24:36 +00:00
} ;
2015-09-03 21:18:22 +00:00
enum EnumSensorTypes
{
SENSOR_FORCE_TORQUE = 1 ,
SENSOR_IMU = 1 ,
} ;
2015-08-02 21:00:43 +00:00
struct CreateSensorArgs
{
int m_bodyUniqueId ;
int m_numJointSensorChanges ;
2015-09-03 21:18:22 +00:00
int m_sensorType [ MAX_DEGREE_OF_FREEDOM ] ;
///todo: clean up the duplication, make sure no-one else is using those members directly (use C-API header instead)
2015-08-02 21:00:43 +00:00
int m_jointIndex [ MAX_DEGREE_OF_FREEDOM ] ;
int m_enableJointForceSensor [ MAX_DEGREE_OF_FREEDOM ] ;
2015-09-03 21:18:22 +00:00
int m_linkIndex [ MAX_DEGREE_OF_FREEDOM ] ;
int m_enableSensor [ MAX_DEGREE_OF_FREEDOM ] ;
2015-08-02 21:00:43 +00:00
} ;
2015-06-21 20:24:36 +00:00
2015-07-23 18:51:25 +00:00
typedef struct SharedMemoryCommand SharedMemoryCommand_t ;
2015-06-22 22:30:57 +00:00
2015-08-02 21:00:43 +00:00
enum EnumBoxShapeFlags
{
BOX_SHAPE_HAS_INITIAL_POSITION = 1 ,
BOX_SHAPE_HAS_INITIAL_ORIENTATION = 2 ,
BOX_SHAPE_HAS_HALF_EXTENTS = 4
} ;
///This command will be replaced to allow arbitrary collision shape types
struct CreateBoxShapeArgs
{
double m_halfExtentsX ;
double m_halfExtentsY ;
double m_halfExtentsZ ;
double m_initialPosition [ 3 ] ;
double m_initialOrientation [ 4 ] ;
} ;
2015-06-21 20:24:36 +00:00
struct SharedMemoryCommand
{
2015-07-23 18:51:25 +00:00
int m_type ;
smUint64_t m_timeStamp ;
2015-07-15 22:23:40 +00:00
int m_sequenceNumber ;
2015-07-31 06:22:44 +00:00
//m_updateFlags is a bit fields to tell which parameters need updating
//for example m_updateFlags = SIM_PARAM_UPDATE_DELTA_TIME | SIM_PARAM_UPDATE_NUM_SOLVER_ITERATIONS;
int m_updateFlags ;
2015-07-15 22:23:40 +00:00
2015-06-21 20:24:36 +00:00
union
{
2015-07-23 18:51:25 +00:00
struct UrdfArgs m_urdfArguments ;
2015-07-31 06:22:44 +00:00
struct InitPoseArgs m_initPoseArgs ;
struct SendPhysicsSimulationParameters m_physSimParamArgs ;
struct BulletDataStreamArgs m_dataStreamArguments ;
struct SendDesiredStateArgs m_sendDesiredStateCommandArgument ;
struct RequestActualStateArgs m_requestActualStateInformationCommandArgument ;
2015-08-02 21:00:43 +00:00
struct CreateSensorArgs m_createSensorArguments ;
struct CreateBoxShapeArgs m_createBoxShapeArguments ;
2015-08-20 05:51:16 +00:00
struct RequestDebugLinesArgs m_requestDebugLinesArguments ;
2015-09-25 05:42:22 +00:00
struct PickBodyArgs m_pickBodyArguments ;
2015-06-21 20:24:36 +00:00
} ;
} ;
2015-07-22 04:46:28 +00:00
struct SharedMemoryStatus
{
int m_type ;
smUint64_t m_timeStamp ;
int m_sequenceNumber ;
union
{
2015-07-23 18:51:25 +00:00
struct BulletDataStreamArgs m_dataStreamArguments ;
struct SendActualStateArgs m_sendActualStateArgs ;
2015-08-20 05:51:16 +00:00
struct SendDebugLinesArgs m_sendDebugLinesArgs ;
2015-07-22 04:46:28 +00:00
} ;
} ;
2015-07-31 06:22:44 +00:00
typedef struct SharedMemoryStatus SharedMemoryStatus_t ;
2015-06-21 20:24:36 +00:00
2015-08-02 21:00:43 +00:00
2015-06-21 20:24:36 +00:00
# endif //SHARED_MEMORY_COMMANDS_H