SharedMemoryPublic.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #ifndef SHARED_MEMORY_PUBLIC_H
  2. #define SHARED_MEMORY_PUBLIC_H
  3. #define SHARED_MEMORY_KEY 12347
  4. enum EnumSharedMemoryClientCommand
  5. {
  6. CMD_LOAD_SDF,
  7. CMD_LOAD_URDF,
  8. CMD_SEND_BULLET_DATA_STREAM,
  9. CMD_CREATE_BOX_COLLISION_SHAPE,
  10. // CMD_DELETE_BOX_COLLISION_SHAPE,
  11. CMD_CREATE_RIGID_BODY,
  12. CMD_DELETE_RIGID_BODY,
  13. CMD_CREATE_SENSOR,///enable or disable joint feedback for force/torque sensors
  14. // CMD_REQUEST_SENSOR_MEASUREMENTS,//see CMD_REQUEST_ACTUAL_STATE/CMD_ACTUAL_STATE_UPDATE_COMPLETED
  15. CMD_INIT_POSE,
  16. CMD_SEND_PHYSICS_SIMULATION_PARAMETERS,
  17. CMD_SEND_DESIRED_STATE,//todo: reconsider naming, for example SET_JOINT_CONTROL_VARIABLE?
  18. CMD_REQUEST_ACTUAL_STATE,
  19. CMD_REQUEST_DEBUG_LINES,
  20. CMD_REQUEST_BODY_INFO,
  21. CMD_STEP_FORWARD_SIMULATION,
  22. CMD_RESET_SIMULATION,
  23. CMD_PICK_BODY,
  24. CMD_MOVE_PICKED_BODY,
  25. CMD_REMOVE_PICKING_CONSTRAINT_BODY,
  26. CMD_REQUEST_CAMERA_IMAGE_DATA,
  27. CMD_APPLY_EXTERNAL_FORCE,
  28. CMD_CALCULATE_INVERSE_DYNAMICS,
  29. CMD_CALCULATE_INVERSE_KINEMATICS,
  30. CMD_CALCULATE_JACOBIAN,
  31. CMD_CREATE_JOINT,
  32. CMD_REQUEST_CONTACT_POINT_INFORMATION,
  33. CMD_SAVE_WORLD,
  34. //don't go beyond this command!
  35. CMD_MAX_CLIENT_COMMANDS,
  36. };
  37. enum EnumSharedMemoryServerStatus
  38. {
  39. CMD_SHARED_MEMORY_NOT_INITIALIZED=0,
  40. CMD_WAITING_FOR_CLIENT_COMMAND,
  41. //CMD_CLIENT_COMMAND_COMPLETED is a generic 'completed' status that doesn't need special handling on the client
  42. CMD_CLIENT_COMMAND_COMPLETED,
  43. //the server will skip unknown command and report a status 'CMD_UNKNOWN_COMMAND_FLUSHED'
  44. CMD_UNKNOWN_COMMAND_FLUSHED,
  45. CMD_SDF_LOADING_COMPLETED,
  46. CMD_SDF_LOADING_FAILED,
  47. CMD_URDF_LOADING_COMPLETED,
  48. CMD_URDF_LOADING_FAILED,
  49. CMD_BULLET_DATA_STREAM_RECEIVED_COMPLETED,
  50. CMD_BULLET_DATA_STREAM_RECEIVED_FAILED,
  51. CMD_BOX_COLLISION_SHAPE_CREATION_COMPLETED,
  52. CMD_RIGID_BODY_CREATION_COMPLETED,
  53. CMD_SET_JOINT_FEEDBACK_COMPLETED,
  54. CMD_ACTUAL_STATE_UPDATE_COMPLETED,
  55. CMD_ACTUAL_STATE_UPDATE_FAILED,
  56. CMD_DEBUG_LINES_COMPLETED,
  57. CMD_DEBUG_LINES_OVERFLOW_FAILED,
  58. CMD_DESIRED_STATE_RECEIVED_COMPLETED,
  59. CMD_STEP_FORWARD_SIMULATION_COMPLETED,
  60. CMD_RESET_SIMULATION_COMPLETED,
  61. CMD_CAMERA_IMAGE_COMPLETED,
  62. CMD_CAMERA_IMAGE_FAILED,
  63. CMD_BODY_INFO_COMPLETED,
  64. CMD_BODY_INFO_FAILED,
  65. CMD_INVALID_STATUS,
  66. CMD_CALCULATED_INVERSE_DYNAMICS_COMPLETED,
  67. CMD_CALCULATED_INVERSE_DYNAMICS_FAILED,
  68. CMD_CALCULATED_JACOBIAN_COMPLETED,
  69. CMD_CALCULATED_JACOBIAN_FAILED,
  70. CMD_CONTACT_POINT_INFORMATION_COMPLETED,
  71. CMD_CONTACT_POINT_INFORMATION_FAILED,
  72. CMD_CALCULATE_INVERSE_KINEMATICS_COMPLETED,
  73. CMD_CALCULATE_INVERSE_KINEMATICS_FAILED,
  74. CMD_SAVE_WORLD_COMPLETED,
  75. CMD_SAVE_WORLD_FAILED,
  76. //don't go beyond 'CMD_MAX_SERVER_COMMANDS!
  77. CMD_MAX_SERVER_COMMANDS
  78. };
  79. enum JointInfoFlags
  80. {
  81. JOINT_HAS_MOTORIZED_POWER=1,
  82. };
  83. enum
  84. {
  85. COLLISION_SHAPE_TYPE_BOX=1,
  86. COLLISION_SHAPE_TYPE_CYLINDER_X,
  87. COLLISION_SHAPE_TYPE_CYLINDER_Y,
  88. COLLISION_SHAPE_TYPE_CYLINDER_Z,
  89. COLLISION_SHAPE_TYPE_CAPSULE_X,
  90. COLLISION_SHAPE_TYPE_CAPSULE_Y,
  91. COLLISION_SHAPE_TYPE_CAPSULE_Z,
  92. COLLISION_SHAPE_TYPE_SPHERE
  93. };
  94. // copied from btMultiBodyLink.h
  95. enum JointType {
  96. eRevoluteType = 0,
  97. ePrismaticType = 1,
  98. eFixedType = 2,
  99. ePoint2PointType = 3,
  100. };
  101. struct b3JointInfo
  102. {
  103. char* m_linkName;
  104. char* m_jointName;
  105. int m_jointType;
  106. int m_qIndex;
  107. int m_uIndex;
  108. int m_jointIndex;
  109. int m_flags;
  110. double m_jointDamping;
  111. double m_jointFriction;
  112. double m_parentFrame[7]; // position and orientation (quaternion)
  113. double m_childFrame[7]; // ^^^
  114. double m_jointAxis[3]; // joint axis in parent local frame
  115. };
  116. struct b3BodyInfo
  117. {
  118. const char* m_baseName;
  119. };
  120. struct b3JointSensorState
  121. {
  122. double m_jointPosition;
  123. double m_jointVelocity;
  124. double m_jointForceTorque[6]; /* note to roboticists: this is NOT the motor torque/force, but the spatial reaction force vector at joint */
  125. double m_jointMotorTorque;
  126. };
  127. struct b3DebugLines
  128. {
  129. int m_numDebugLines;
  130. const float* m_linesFrom;//float x,y,z times 'm_numDebugLines'.
  131. const float* m_linesTo;//float x,y,z times 'm_numDebugLines'.
  132. const float* m_linesColor;//float red,green,blue times 'm_numDebugLines'.
  133. };
  134. struct b3CameraImageData
  135. {
  136. int m_pixelWidth;
  137. int m_pixelHeight;
  138. const unsigned char* m_rgbColorData;//3*m_pixelWidth*m_pixelHeight bytes
  139. const float* m_depthValues;//m_pixelWidth*m_pixelHeight floats
  140. const int* m_segmentationMaskValues;//m_pixelWidth*m_pixelHeight ints
  141. };
  142. struct b3ContactPointData
  143. {
  144. //todo: expose some contact flags, such as telling which fields below are valid
  145. int m_contactFlags;
  146. int m_bodyUniqueIdA;
  147. int m_bodyUniqueIdB;
  148. int m_linkIndexA;
  149. int m_linkIndexB;
  150. double m_positionOnAInWS[3];//contact point location on object A, in world space coordinates
  151. double m_positionOnBInWS[3];//contact point location on object A, in world space coordinates
  152. double m_contactNormalOnBInWS[3];//the separating contact normal, pointing from object B towards object A
  153. double m_contactDistance;//negative number is penetration, positive is distance.
  154. double m_normalForce;
  155. //todo: expose the friction forces as well
  156. // double m_linearFrictionDirection0[3];
  157. // double m_linearFrictionForce0;
  158. // double m_linearFrictionDirection1[3];
  159. // double m_linearFrictionForce1;
  160. // double m_angularFrictionDirection[3];
  161. // double m_angularFrictionForce;
  162. };
  163. struct b3ContactInformation
  164. {
  165. int m_numContactPoints;
  166. struct b3ContactPointData* m_contactPointData;
  167. };
  168. ///b3LinkState provides extra information such as the Cartesian world coordinates
  169. ///center of mass (COM) of the link, relative to the world reference frame.
  170. ///Orientation is a quaternion x,y,z,w
  171. ///Note: to compute the URDF link frame (which equals the joint frame at joint position 0)
  172. ///use URDF link frame = link COM frame * inertiaFrame.inverse()
  173. struct b3LinkState
  174. {
  175. double m_worldPosition[3];
  176. double m_worldOrientation[4];
  177. double m_localInertialPosition[3];
  178. double m_localInertialOrientation[4];
  179. };
  180. //todo: discuss and decide about control mode and combinations
  181. enum {
  182. // POSITION_CONTROL=0,
  183. CONTROL_MODE_VELOCITY=0,
  184. CONTROL_MODE_TORQUE,
  185. CONTROL_MODE_POSITION_VELOCITY_PD,
  186. };
  187. ///flags for b3ApplyExternalTorque and b3ApplyExternalForce
  188. enum EnumExternalForceFlags
  189. {
  190. EF_LINK_FRAME=1,
  191. EF_WORLD_FRAME=2,
  192. };
  193. ///flags to pick the renderer for synthetic camera
  194. enum EnumRenderer
  195. {
  196. ER_TINY_RENDERER=(1<<16),
  197. ER_BULLET_HARDWARE_OPENGL=(1<<17),
  198. //ER_FIRE_RAYS=(1<<18),
  199. };
  200. #endif//SHARED_MEMORY_PUBLIC_H