Add Flex component.
PiperOrigin-RevId: 572830650 Change-Id: I6908228087b7b9683be3506c8d9cdc725ed5dcd5
This commit is contained in:
committed by
Saran Tunyasuvunakool
parent
649a474788
commit
5a70ad08ab
+21
-12
@@ -97,7 +97,7 @@ typedef enum mjtTimer_ { // internal timers
|
||||
//---------------------------------- mjContact -----------------------------------------------------
|
||||
|
||||
struct mjContact_ { // result of collision detection functions
|
||||
// contact parameters set by geom-specific collision detector
|
||||
// contact parameters set by near-phase collision function
|
||||
mjtNum dist; // distance between nearest points; neg: penetration
|
||||
mjtNum pos[3]; // position of contact point: midpoint between geoms
|
||||
mjtNum frame[9]; // normal is in [0-2]
|
||||
@@ -113,12 +113,16 @@ struct mjContact_ { // result of collision detection functions
|
||||
mjtNum mu; // friction of regularized cone, set by mj_makeConstraint
|
||||
mjtNum H[36]; // cone Hessian, set by mj_updateConstraint
|
||||
|
||||
// contact descriptors set by mj_collideGeoms
|
||||
// contact descriptors set by mj_collideXXX
|
||||
int dim; // contact space dimensionality: 1, 3, 4 or 6
|
||||
int geom1; // id of geom 1
|
||||
int geom2; // id of geom 2
|
||||
int geom[2]; // geom ids; -1 for flex
|
||||
int flex[2]; // flex ids; -1 for geom
|
||||
int elem[2]; // element ids; -1 for geom or flex vertex
|
||||
int vert[2]; // vertex ids; -1 for geom or flex element
|
||||
|
||||
// flag set by mj_instantianteEquality
|
||||
// flag set by mj_setContact or mj_instantiateContact
|
||||
int exclude; // 0: include, 1: in gap, 2: fused, 3: no dofs
|
||||
|
||||
// address computed by mj_instantiateContact
|
||||
@@ -188,12 +192,6 @@ struct mjData_ {
|
||||
int solver_nnz[mjNISLAND]; // number of non-zeros in Hessian or efc_AR, per island
|
||||
mjtNum solver_fwdinv[2]; // forward-inverse comparison: qfrc, efc
|
||||
|
||||
// collision statistics
|
||||
int nbodypair_broad; // number of body pairs in collision according to the broad-phase
|
||||
int nbodypair_narrow; // number of body pairs actually in collision in the narrow-phase
|
||||
int ngeompair_mid; // number of geom pairs in collision according to the mid-phase
|
||||
int ngeompair_narrow; // number of geom pairs actually in collision in the narrow-phase
|
||||
|
||||
// variable sizes
|
||||
int ne; // number of equality constraints
|
||||
int nf; // number of friction constraints
|
||||
@@ -270,14 +268,23 @@ struct mjData_ {
|
||||
mjtNum* cdof; // com-based motion axis of each dof (nv x 6)
|
||||
mjtNum* cinert; // com-based body inertia and mass (nbody x 10)
|
||||
|
||||
// computed by mj_fwdPosition/mj_flex
|
||||
mjtNum* flexvert_xpos; // Cartesian flex vertex positions (nflexvert x 3)
|
||||
mjtNum* flexelem_aabb; // flex element bounding boxes (center, size) (nflexelem x 6)
|
||||
int* flexedge_J_rownnz; // number of non-zeros in Jacobian row (nflexedge x 1)
|
||||
int* flexedge_J_rowadr; // row start address in colind array (nflexedge x 1)
|
||||
int* flexedge_J_colind; // column indices in sparse Jacobian (nflexedge x nv)
|
||||
mjtNum* flexedge_J; // flex edge Jacobian (nflexedge x nv)
|
||||
mjtNum* flexedge_length; // flex edge lengths (nflexedge x 1)
|
||||
|
||||
// computed by mj_fwdPosition/mj_tendon
|
||||
int* ten_wrapadr; // start address of tendon's path (ntendon x 1)
|
||||
int* ten_wrapnum; // number of wrap points in path (ntendon x 1)
|
||||
int* ten_J_rownnz; // number of non-zeros in Jacobian row (ntendon x 1)
|
||||
int* ten_J_rowadr; // row start address in colind array (ntendon x 1)
|
||||
int* ten_J_colind; // column indices in sparse Jacobian (ntendon x nv)
|
||||
mjtNum* ten_length; // tendon lengths (ntendon x 1)
|
||||
mjtNum* ten_J; // tendon Jacobian (ntendon x nv)
|
||||
mjtNum* ten_length; // tendon lengths (ntendon x 1)
|
||||
int* wrap_obj; // geom id; -1: site; -2: pulley (nwrap*2 x 1)
|
||||
mjtNum* wrap_xpos; // Cartesian 3D points in all path (nwrap*2 x 3)
|
||||
|
||||
@@ -295,11 +302,13 @@ struct mjData_ {
|
||||
mjtNum* qLDiagSqrtInv; // 1/sqrt(diag(D)) (nv x 1)
|
||||
|
||||
// computed by mj_collisionTree
|
||||
mjtNum* bvh_aabb_dyn; // global bounding box (center, size) (nbvhdynamic x 6)
|
||||
mjtByte* bvh_active; // volume has been added to collisions (nbvh x 1)
|
||||
|
||||
//-------------------- POSITION, VELOCITY dependent
|
||||
|
||||
// computed by mj_fwdVelocity
|
||||
mjtNum* flexedge_velocity; // flex edge velocities (nflexedge x 1)
|
||||
mjtNum* ten_velocity; // tendon velocities (ntendon x 1)
|
||||
mjtNum* actuator_velocity; // actuator velocities (nu x 1)
|
||||
|
||||
@@ -318,8 +327,8 @@ struct mjData_ {
|
||||
mjtNum* subtree_angmom; // angular momentum about subtree com (nbody x 3)
|
||||
|
||||
// computed by mj_Euler or mj_implicit
|
||||
mjtNum* qH; // L'*D*L factorization of modified M (nM x 1)
|
||||
mjtNum* qHDiagInv; // 1/diag(D) of modified M (nv x 1)
|
||||
mjtNum* qH; // L'*D*L factorization of modified M (nM x 1)
|
||||
mjtNum* qHDiagInv; // 1/diag(D) of modified M (nv x 1)
|
||||
|
||||
// computed by mj_resetData
|
||||
int* D_rownnz; // non-zeros in each row (nv x 1)
|
||||
|
||||
@@ -109,6 +109,7 @@ typedef enum mjtGeom_ { // type of geometric shape
|
||||
mjGEOM_ARROW1, // arrow without wedges
|
||||
mjGEOM_ARROW2, // arrow in both directions
|
||||
mjGEOM_LINE, // line
|
||||
mjGEOM_FLEX, // flex
|
||||
mjGEOM_SKIN, // skin
|
||||
mjGEOM_LABEL, // text label
|
||||
mjGEOM_TRIANGLE, // triangle connecting a frame
|
||||
@@ -166,6 +167,7 @@ typedef enum mjtEq_ { // type of equality constraint
|
||||
mjEQ_WELD, // fix relative position and orientation of two bodies
|
||||
mjEQ_JOINT, // couple the values of two scalar joints with cubic
|
||||
mjEQ_TENDON, // couple the lengths of two tendons with cubic
|
||||
mjEQ_FLEX, // fix all edge lengths of a flex
|
||||
mjEQ_DISTANCE // unsupported, will cause an error if used
|
||||
} mjtEq;
|
||||
|
||||
@@ -228,6 +230,7 @@ typedef enum mjtObj_ { // type of MujoCo object
|
||||
mjOBJ_SITE, // site
|
||||
mjOBJ_CAMERA, // camera
|
||||
mjOBJ_LIGHT, // light
|
||||
mjOBJ_FLEX, // flex
|
||||
mjOBJ_MESH, // mesh
|
||||
mjOBJ_SKIN, // skin
|
||||
mjOBJ_HFIELD, // heightfield
|
||||
@@ -353,6 +356,15 @@ typedef enum mjtLRMode_ { // mode for actuator length range computation
|
||||
} mjtLRMode;
|
||||
|
||||
|
||||
typedef enum mjtFlexSelf_ { // mode for flex selfcollide
|
||||
mjFLEXSELF_NONE = 0, // no self-collisions
|
||||
mjFLEXSELF_NARROW, // skip midphase, go directly to narrowphase
|
||||
mjFLEXSELF_BVH, // use BVH in midphase (if midphase enabled)
|
||||
mjFLEXSELF_SAP, // use SAP in midphase
|
||||
mjFLEXSELF_AUTO // choose between BVH and SAP automatically
|
||||
} mjtFlexSelf;
|
||||
|
||||
|
||||
//---------------------------------- mjLROpt -------------------------------------------------------
|
||||
|
||||
struct mjLROpt_ { // options for mj_setLengthRange()
|
||||
@@ -408,6 +420,7 @@ struct mjOption_ { // physics options
|
||||
mjtNum o_margin; // margin
|
||||
mjtNum o_solref[mjNREF]; // solref
|
||||
mjtNum o_solimp[mjNIMP]; // solimp
|
||||
mjtNum o_friction[5]; // friction
|
||||
|
||||
// discrete settings
|
||||
int integrator; // integration mode (mjtIntegrator)
|
||||
@@ -439,9 +452,9 @@ struct mjVisual_ { // visualization options
|
||||
float linewidth; // line width for wireframe and ray rendering
|
||||
float glow; // glow coefficient for selected body
|
||||
float realtime; // initial real-time factor (1: real time)
|
||||
int offwidth; // width of offscreen buffer
|
||||
int offheight; // height of offscreen buffer
|
||||
int ellipsoidinertia; // geom for inertia visualization (0: box, 1: ellipsoid)
|
||||
int offwidth; // width of offscreen buffer
|
||||
int offheight; // height of offscreen buffer
|
||||
int ellipsoidinertia; // geom for inertia visualization (0: box, 1: ellipsoid)
|
||||
} global;
|
||||
|
||||
struct { // rendering quality
|
||||
@@ -545,12 +558,22 @@ struct mjModel_ {
|
||||
int nu; // number of actuators/controls = dim(ctrl)
|
||||
int na; // number of activation states = dim(act)
|
||||
int nbody; // number of bodies
|
||||
int nbvh; // number of bounding volumes in all bodies
|
||||
int nbvh; // number of total bounding volumes in all bodies
|
||||
int nbvhstatic; // number of static bounding volumes (aabb stored in mjModel)
|
||||
int nbvhdynamic; // number of dynamic bounding volumes (aabb stored in mjData)
|
||||
int njnt; // number of joints
|
||||
int ngeom; // number of geoms
|
||||
int nsite; // number of sites
|
||||
int ncam; // number of cameras
|
||||
int nlight; // number of lights
|
||||
int nflex; // number of flexes
|
||||
int nflexvert; // number of vertices in all flexes
|
||||
int nflexedge; // number of edges in all flexes
|
||||
int nflexelem; // number of elements in all flexes
|
||||
int nflexelemdata; // number of element vertex ids in all flexes
|
||||
int nflexshelldata; // number of shell fragment vertex ids in all flexes
|
||||
int nflexevpair; // number of element-vertex pairs in all flexes
|
||||
int nflextexcoord; // number of vertices with texture coordinates
|
||||
int nmesh; // number of meshes
|
||||
int nmeshvert; // number of vertices in all meshes
|
||||
int nmeshnormal; // number of normals in all meshes
|
||||
@@ -649,16 +672,19 @@ struct mjModel_ {
|
||||
mjtNum* body_inertia; // diagonal inertia in ipos/iquat frame (nbody x 3)
|
||||
mjtNum* body_invweight0; // mean inv inert in qpos0 (trn, rot) (nbody x 2)
|
||||
mjtNum* body_gravcomp; // antigravity force, units of body weight (nbody x 1)
|
||||
mjtNum* body_margin; // MAX over all geom margins (nbody x 1)
|
||||
mjtNum* body_user; // user data (nbody x nuser_body)
|
||||
int* body_plugin; // plugin instance id; -1: not in use (nbody x 1)
|
||||
int* body_contype; // OR over all geom contypes (nbody x 1)
|
||||
int* body_conaffinity; // OR over all geom conaffinities (nbody x 1)
|
||||
int* body_bvhadr; // address of bvh root (nbody x 1)
|
||||
int* body_bvhnum; // number of bounding volumes (nbody x 1)
|
||||
|
||||
// bounding volume hierarchy
|
||||
int* bvh_depth; // depth in the bounding volume hierarchy (nbvh x 1)
|
||||
int* bvh_child; // left and right children in tree (nbvh x 2)
|
||||
int* bvh_geomid; // geom id of the node; -1: non-leaf (nbvh x 1)
|
||||
mjtNum* bvh_aabb; // bounding box of node (center, size) (nbvh x 6)
|
||||
int* bvh_nodeid; // geom or elem id of node; -1: non-leaf (nbvh x 1)
|
||||
mjtNum* bvh_aabb; // local bounding box (center, size) (nbvhstatic x 6)
|
||||
|
||||
// joints
|
||||
int* jnt_type; // type of joint (mjtJoint) (njnt x 1)
|
||||
@@ -767,6 +793,59 @@ struct mjModel_ {
|
||||
float* light_diffuse; // diffuse rgb (alpha=1) (nlight x 3)
|
||||
float* light_specular; // specular rgb (alpha=1) (nlight x 3)
|
||||
|
||||
// flexes: contact properties
|
||||
int* flex_contype; // flex contact type (nflex x 1)
|
||||
int* flex_conaffinity; // flex contact affinity (nflex x 1)
|
||||
int* flex_condim; // contact dimensionality (1, 3, 4, 6) (nflex x 1)
|
||||
int* flex_priority; // flex contact priority (nflex x 1)
|
||||
mjtNum* flex_solmix; // mix coef for solref/imp in contact pair (nflex x 1)
|
||||
mjtNum* flex_solref; // constraint solver reference: contact (nflex x mjNREF)
|
||||
mjtNum* flex_solimp; // constraint solver impedance: contact (nflex x mjNIMP)
|
||||
mjtNum* flex_friction; // friction for (slide, spin, roll) (nflex x 3)
|
||||
mjtNum* flex_margin; // detect contact if dist<margin (nflex x 1)
|
||||
mjtNum* flex_gap; // include in solver if dist<margin-gap (nflex x 1)
|
||||
mjtByte* flex_internal; // internal flex collision enabled (nflex x 1)
|
||||
int* flex_selfcollide; // self collision mode (mjtFlexSelf) (nflex x 1)
|
||||
int* flex_activelayers; // number of active element layers, 3D only (nflex x 1)
|
||||
|
||||
// flexes: other properties
|
||||
int* flex_dim; // 1: lines, 2: triangles, 3: tetrahedra (nflex x 1)
|
||||
int* flex_matid; // material id for rendering (nflex x 1)
|
||||
int* flex_group; // group for visibility (nflex x 1)
|
||||
int* flex_vertadr; // first vertex address (nflex x 1)
|
||||
int* flex_vertnum; // number of vertices (nflex x 1)
|
||||
int* flex_edgeadr; // first edge address (nflex x 1)
|
||||
int* flex_edgenum; // number of edges (nflex x 1)
|
||||
int* flex_elemadr; // first element address (nflex x 1)
|
||||
int* flex_elemnum; // number of elements (nflex x 1)
|
||||
int* flex_elemdataadr; // first element vertex id address (nflex x 1)
|
||||
int* flex_shellnum; // number of shells (nflex x 1)
|
||||
int* flex_shelldataadr; // first shell data address (nflex x 1)
|
||||
int* flex_evpairadr; // first evpair address (nflex x 1)
|
||||
int* flex_evpairnum; // number of evpairs (nflex x 1)
|
||||
int* flex_texcoordadr; // address in flex_texcoord; -1: none (nflex x 1)
|
||||
int* flex_vertbodyid; // vertex body ids (nflexvert x 1)
|
||||
int* flex_edge; // edge vertex ids (2 per edge) (nflexedge x 2)
|
||||
int* flex_elem; // element vertex ids (dim+1 per elem) (nflexelemdata x 1)
|
||||
int* flex_elemlayer; // element distance from surface, 3D only (nflexelem x 1)
|
||||
int* flex_shell; // shell fragment vertex ids (dim per frag) (nflexshelldata x 1)
|
||||
int* flex_evpair; // (element, vertex) collision pairs (nflexevpair x 2)
|
||||
mjtNum* flex_vert; // vertex positions in local body frames (nflexvert x 3)
|
||||
mjtNum* flex_xvert0; // Cartesian vertex positions in qpos0 (nflexvert x 3)
|
||||
mjtNum* flexedge_length0; // edge lengths in qpos0 (nflexedge x 1)
|
||||
mjtNum* flexedge_invweight0; // edge inv. weight in qpos0 (nflexedge x 1)
|
||||
mjtNum* flex_radius; // radius around primitive element (nflex x 1)
|
||||
mjtNum* flex_edgestiffness; // edge stiffness (nflex x 1)
|
||||
mjtNum* flex_edgedamping; // edge damping (nflex x 1)
|
||||
mjtByte* flex_edgeequality; // is edge equality constraint defined (nflex x 1)
|
||||
mjtByte* flex_rigid; // are all verices in the same body (nflex x 1)
|
||||
mjtByte* flex_centered; // are all vertex coordinates (0,0,0) (nflex x 1)
|
||||
mjtByte* flex_flatskin; // render flex skin with flat shading (nflex x 1)
|
||||
int* flex_bvhadr; // address of bvh root; -1: no bvh (nflex x 1)
|
||||
int* flex_bvhnum; // number of bounding volumes (nflex x 1)
|
||||
float* flex_rgba; // rgba when material is omitted (nflex x 4)
|
||||
float* flex_texcoord; // vertex texture coordinates (nflextexcoord x 2)
|
||||
|
||||
// meshes
|
||||
int* mesh_vertadr; // first vertex address (nmesh x 1)
|
||||
int* mesh_vertnum; // number of vertices (nmesh x 1)
|
||||
@@ -841,7 +920,7 @@ struct mjModel_ {
|
||||
int* pair_dim; // contact dimensionality (npair x 1)
|
||||
int* pair_geom1; // id of geom1 (npair x 1)
|
||||
int* pair_geom2; // id of geom2 (npair x 1)
|
||||
int* pair_signature; // (body1+1) << 16 + body2+1 (npair x 1)
|
||||
int* pair_signature; // body1 << 16 + body2 (npair x 1)
|
||||
mjtNum* pair_solref; // solver reference: contact normal (npair x mjNREF)
|
||||
mjtNum* pair_solreffriction; // solver reference: contact friction (npair x mjNREF)
|
||||
mjtNum* pair_solimp; // solver impedance: contact (npair x mjNIMP)
|
||||
@@ -850,7 +929,7 @@ struct mjModel_ {
|
||||
mjtNum* pair_friction; // tangent1, 2, spin, roll1, 2 (npair x 5)
|
||||
|
||||
// excluded body pairs for collision detection
|
||||
int* exclude_signature; // (body1+1) << 16 + body2+1 (nexclude x 1)
|
||||
int* exclude_signature; // body1 << 16 + body2 (nexclude x 1)
|
||||
|
||||
// equality constraints
|
||||
int* eq_type; // constraint type (mjtEq) (neq x 1)
|
||||
@@ -970,6 +1049,7 @@ struct mjModel_ {
|
||||
int* name_siteadr; // site name pointers (nsite x 1)
|
||||
int* name_camadr; // camera name pointers (ncam x 1)
|
||||
int* name_lightadr; // light name pointers (nlight x 1)
|
||||
int* name_flexadr; // flex name pointers (nflex x 1)
|
||||
int* name_meshadr; // mesh name pointers (nmesh x 1)
|
||||
int* name_skinadr; // skin name pointers (nskin x 1)
|
||||
int* name_hfieldadr; // hfield name pointers (nhfield x 1)
|
||||
|
||||
@@ -74,6 +74,7 @@ typedef enum mjtLabel_ { // object labeling
|
||||
mjLABEL_TENDON, // tendon labels
|
||||
mjLABEL_ACTUATOR, // actuator labels
|
||||
mjLABEL_CONSTRAINT, // constraint labels
|
||||
mjLABEL_FLEX, // flex labels
|
||||
mjLABEL_SKIN, // skin labels
|
||||
mjLABEL_SELECTION, // selected object
|
||||
mjLABEL_SELPNT, // coordinates of selection point
|
||||
@@ -124,7 +125,12 @@ typedef enum mjtVisFlag_ { // flags enabling model element visualization
|
||||
mjVIS_SELECT, // selection point
|
||||
mjVIS_STATIC, // static bodies
|
||||
mjVIS_SKIN, // skin
|
||||
mjVIS_MIDPHASE, // mid-phase bounding volume hierarchy
|
||||
mjVIS_FLEXVERT, // flex vertices
|
||||
mjVIS_FLEXEDGE, // flex edges
|
||||
mjVIS_FLEXFACE, // flex element faces
|
||||
mjVIS_FLEXSKIN, // flex smooth skin (disables the rest)
|
||||
mjVIS_BODYBVH, // body bounding volume hierarchy
|
||||
mjVIS_FLEXBVH, // flex bounding volume hierarchy
|
||||
mjVIS_MESHBVH, // mesh bounding volume hierarchy
|
||||
mjVIS_SDFITER, // iterations of SDF gradient descent
|
||||
|
||||
@@ -159,6 +165,7 @@ typedef enum mjtStereo_ { // type of stereo rendering
|
||||
|
||||
struct mjvPerturb_ { // object selection and perturbation
|
||||
int select; // selected body id; non-positive: none
|
||||
int flexselect; // selected flex id; negative: none
|
||||
int skinselect; // selected skin id; negative: none
|
||||
int active; // perturbation bitmask (mjtPertBit)
|
||||
int active2; // secondary perturbation bitmask (mjtPertBit)
|
||||
@@ -219,7 +226,7 @@ struct mjvGeom_ { // abstract geom
|
||||
int category; // visual category
|
||||
int texid; // texture id; -1: no texture
|
||||
int texuniform; // uniform cube mapping
|
||||
int texcoord; // mesh geom has texture coordinates
|
||||
int texcoord; // mesh or flex geom has texture coordinates
|
||||
int segid; // segmentation id; -1: not shown
|
||||
|
||||
// OpenGL info
|
||||
@@ -270,9 +277,11 @@ struct mjvOption_ { // abstract visualization options
|
||||
mjtByte jointgroup[mjNGROUP]; // joint visualization by group
|
||||
mjtByte tendongroup[mjNGROUP]; // tendon visualization by group
|
||||
mjtByte actuatorgroup[mjNGROUP]; // actuator visualization by group
|
||||
mjtByte flexgroup[mjNGROUP]; // flex visualization by group
|
||||
mjtByte skingroup[mjNGROUP]; // skin visualization by group
|
||||
mjtByte flags[mjNVISFLAG]; // visualization flags (indexed by mjtVisFlag)
|
||||
int bvh_depth; // depth of the bounding volume hierarchy to be visualized
|
||||
int bvh_depth; // depth of the bounding volume hierarchy to be visualized
|
||||
int flex_layer; // element layer to be visualized for 3D flex
|
||||
};
|
||||
typedef struct mjvOption_ mjvOption;
|
||||
|
||||
@@ -286,13 +295,32 @@ struct mjvScene_ { // abstract scene passed to OpenGL renderer
|
||||
mjvGeom* geoms; // buffer for geoms (ngeom)
|
||||
int* geomorder; // buffer for ordering geoms by distance to camera (ngeom)
|
||||
|
||||
// flex data
|
||||
int nflex; // number of flexes
|
||||
int* flexedgeadr; // address of flex edges (nflex)
|
||||
int* flexedgenum; // number of edges in flex (nflex)
|
||||
int* flexvertadr; // address of flex vertices (nflex)
|
||||
int* flexvertnum; // number of vertices in flex (nflex)
|
||||
int* flexfaceadr; // address of flex faces (nflex)
|
||||
int* flexfacenum; // number of flex faces allocated (nflex)
|
||||
int* flexfaceused; // number of flex faces currently in use (nflex)
|
||||
int* flexedge; // flex edge data (2*nflexedge)
|
||||
float* flexvert; // flex vertices (3*nflexvert)
|
||||
float* flexface; // flex faces vertices (9*sum(flexfacenum))
|
||||
float* flexnormal; // flex face normals (9*sum(flexfacenum))
|
||||
float* flextexcoord; // flex face texture coordinates (6*sum(flexfacenum))
|
||||
mjtByte flexvertopt; // copy of mjVIS_FLEXVERT mjvOption flag
|
||||
mjtByte flexedgeopt; // copy of mjVIS_FLEXEDGE mjvOption flag
|
||||
mjtByte flexfaceopt; // copy of mjVIS_FLEXFACE mjvOption flag
|
||||
mjtByte flexskinopt; // copy of mjVIS_FLEXSKIN mjvOption flag
|
||||
|
||||
// skin data
|
||||
int nskin; // number of skins
|
||||
int* skinfacenum; // number of faces in skin (nskin)
|
||||
int* skinvertadr; // address of skin vertices (nskin)
|
||||
int* skinvertnum; // number of vertices in skin (nskin)
|
||||
float* skinvert; // skin vertex data (nskin)
|
||||
float* skinnormal; // skin normal data (nskin)
|
||||
float* skinvert; // skin vertex data (3*nskinvert)
|
||||
float* skinnormal; // skin normal data (3*nskinvert)
|
||||
|
||||
// OpenGL lights
|
||||
int nlight; // number of lights currently in buffer
|
||||
@@ -384,6 +412,7 @@ struct mjvSceneState_ {
|
||||
int na;
|
||||
int nbody;
|
||||
int nbvh;
|
||||
int nbvhstatic;
|
||||
int njnt;
|
||||
int ngeom;
|
||||
int nsite;
|
||||
@@ -391,6 +420,8 @@ struct mjvSceneState_ {
|
||||
int nlight;
|
||||
int nmesh;
|
||||
int nskin;
|
||||
int nflex;
|
||||
int nflexvert;
|
||||
int nskinvert;
|
||||
int nskinface;
|
||||
int nskinbone;
|
||||
@@ -427,7 +458,7 @@ struct mjvSceneState_ {
|
||||
|
||||
int* bvh_depth;
|
||||
int* bvh_child;
|
||||
int* bvh_geomid;
|
||||
int* bvh_nodeid;
|
||||
mjtNum* bvh_aabb;
|
||||
|
||||
int* jnt_type;
|
||||
@@ -467,6 +498,24 @@ struct mjvSceneState_ {
|
||||
float* light_diffuse;
|
||||
float* light_specular;
|
||||
|
||||
mjtByte* flex_flatskin;
|
||||
int* flex_dim;
|
||||
int* flex_matid;
|
||||
int* flex_group;
|
||||
int* flex_vertadr;
|
||||
int* flex_vertnum;
|
||||
int* flex_elem;
|
||||
int* flex_elemadr;
|
||||
int* flex_elemnum;
|
||||
int* flex_elemdataadr;
|
||||
int* flex_shell;
|
||||
int* flex_shellnum;
|
||||
int* flex_shelldataadr;
|
||||
int* flex_bvhadr;
|
||||
int* flex_bvhnum;
|
||||
mjtNum* flex_radius;
|
||||
float* flex_rgba;
|
||||
|
||||
int* mesh_bvhadr;
|
||||
int* mesh_bvhnum;
|
||||
int* mesh_texcoordadr;
|
||||
@@ -598,6 +647,8 @@ struct mjvSceneState_ {
|
||||
int* efc_island;
|
||||
int* tendon_efcadr;
|
||||
|
||||
mjtNum* flexvert_xpos;
|
||||
|
||||
mjContact* contact;
|
||||
mjtNum* efc_force;
|
||||
} data;
|
||||
|
||||
@@ -58,7 +58,8 @@
|
||||
X( wind, 3 ) \
|
||||
X( magnetic, 3 ) \
|
||||
X( o_solref, mjNREF ) \
|
||||
X( o_solimp, mjNIMP )
|
||||
X( o_solimp, mjNIMP ) \
|
||||
X( o_friction, 5 )
|
||||
|
||||
|
||||
//-------------------------------- mjModel ---------------------------------------------------------
|
||||
@@ -71,11 +72,21 @@
|
||||
XMJV( na ) \
|
||||
XMJV( nbody ) \
|
||||
XMJV( nbvh ) \
|
||||
XMJV( nbvhstatic ) \
|
||||
X ( nbvhdynamic ) \
|
||||
XMJV( njnt ) \
|
||||
XMJV( ngeom ) \
|
||||
XMJV( nsite ) \
|
||||
XMJV( ncam ) \
|
||||
XMJV( nlight ) \
|
||||
XMJV( nflex ) \
|
||||
XMJV( nflexvert ) \
|
||||
X ( nflexedge ) \
|
||||
X ( nflexelem ) \
|
||||
X ( nflexelemdata ) \
|
||||
X ( nflexshelldata ) \
|
||||
X ( nflexevpair ) \
|
||||
X ( nflextexcoord ) \
|
||||
XMJV( nmesh ) \
|
||||
X ( nmeshvert ) \
|
||||
X ( nmeshnormal ) \
|
||||
@@ -185,14 +196,17 @@
|
||||
XMJV( mjtNum, body_inertia, nbody, 3 ) \
|
||||
X ( mjtNum, body_invweight0, nbody, 2 ) \
|
||||
X ( mjtNum, body_gravcomp, nbody, 1 ) \
|
||||
X ( mjtNum, body_margin, nbody, 1 ) \
|
||||
X ( mjtNum, body_user, nbody, MJ_M(nuser_body) ) \
|
||||
X ( int, body_plugin, nbody, 1 ) \
|
||||
X ( int, body_contype, nbody, 1 ) \
|
||||
X ( int, body_conaffinity, nbody, 1 ) \
|
||||
XMJV( int, body_bvhadr, nbody, 1 ) \
|
||||
XMJV( int, body_bvhnum, nbody, 1 ) \
|
||||
XMJV( int, bvh_depth, nbvh, 1 ) \
|
||||
XMJV( int, bvh_child, nbvh, 2 ) \
|
||||
XMJV( int, bvh_geomid, nbvh, 1 ) \
|
||||
XMJV( mjtNum, bvh_aabb, nbvh, 6 ) \
|
||||
XMJV( int, bvh_nodeid, nbvh, 1 ) \
|
||||
XMJV( mjtNum, bvh_aabb, nbvhstatic, 6 ) \
|
||||
XMJV( int, jnt_type, njnt, 1 ) \
|
||||
X ( int, jnt_qposadr, njnt, 1 ) \
|
||||
X ( int, jnt_dofadr, njnt, 1 ) \
|
||||
@@ -288,6 +302,55 @@
|
||||
XMJV( float, light_ambient, nlight, 3 ) \
|
||||
XMJV( float, light_diffuse, nlight, 3 ) \
|
||||
XMJV( float, light_specular, nlight, 3 ) \
|
||||
X ( int, flex_contype, nflex, 1 ) \
|
||||
X ( int, flex_conaffinity, nflex, 1 ) \
|
||||
X ( int, flex_condim, nflex, 1 ) \
|
||||
X ( int, flex_priority, nflex, 1 ) \
|
||||
X ( mjtNum, flex_solmix, nflex, 1 ) \
|
||||
X ( mjtNum, flex_solref, nflex, mjNREF ) \
|
||||
X ( mjtNum, flex_solimp, nflex, mjNIMP ) \
|
||||
X ( mjtNum, flex_friction, nflex, 3 ) \
|
||||
X ( mjtNum, flex_margin, nflex, 1 ) \
|
||||
X ( mjtNum, flex_gap, nflex, 1 ) \
|
||||
X ( mjtByte, flex_internal, nflex, 1 ) \
|
||||
X ( int, flex_selfcollide, nflex, 1 ) \
|
||||
X ( int, flex_activelayers, nflex, 1 ) \
|
||||
XMJV( int, flex_dim, nflex, 1 ) \
|
||||
XMJV( int, flex_matid, nflex, 1 ) \
|
||||
XMJV( int, flex_group, nflex, 1 ) \
|
||||
XMJV( int, flex_vertadr, nflex, 1 ) \
|
||||
XMJV( int, flex_vertnum, nflex, 1 ) \
|
||||
X ( int, flex_edgeadr, nflex, 1 ) \
|
||||
X ( int, flex_edgenum, nflex, 1 ) \
|
||||
XMJV( int, flex_elemadr, nflex, 1 ) \
|
||||
XMJV( int, flex_elemnum, nflex, 1 ) \
|
||||
XMJV( int, flex_elemdataadr, nflex, 1 ) \
|
||||
XMJV( int, flex_shellnum, nflex, 1 ) \
|
||||
XMJV( int, flex_shelldataadr, nflex, 1 ) \
|
||||
X ( int, flex_evpairadr, nflex, 1 ) \
|
||||
X ( int, flex_evpairnum, nflex, 1 ) \
|
||||
X ( int, flex_texcoordadr, nflex, 1 ) \
|
||||
X ( int, flex_vertbodyid, nflexvert, 1 ) \
|
||||
X ( int, flex_edge, nflexedge, 2 ) \
|
||||
XMJV( int, flex_elem, nflexelemdata, 1 ) \
|
||||
X ( int, flex_elemlayer, nflexelem, 1 ) \
|
||||
XMJV( int, flex_shell, nflexshelldata,1 ) \
|
||||
X ( int, flex_evpair, nflexevpair, 2 ) \
|
||||
X ( mjtNum, flex_vert, nflexvert, 3 ) \
|
||||
X ( mjtNum, flex_xvert0, nflexvert, 3 ) \
|
||||
X ( mjtNum, flexedge_length0, nflexedge, 1 ) \
|
||||
X ( mjtNum, flexedge_invweight0, nflexedge, 1 ) \
|
||||
XMJV( mjtNum, flex_radius, nflex, 1 ) \
|
||||
X ( mjtNum, flex_edgestiffness, nflex, 1 ) \
|
||||
X ( mjtNum, flex_edgedamping, nflex, 1 ) \
|
||||
X ( mjtByte, flex_edgeequality, nflex, 1 ) \
|
||||
X ( mjtByte, flex_rigid, nflex, 1 ) \
|
||||
X ( mjtByte, flex_centered, nflex, 1 ) \
|
||||
XMJV( mjtByte, flex_flatskin, nflex, 1 ) \
|
||||
XMJV( int, flex_bvhadr, nflex, 1 ) \
|
||||
XMJV( int, flex_bvhnum, nflex, 1 ) \
|
||||
XMJV( float, flex_rgba, nflex, 4 ) \
|
||||
X ( float, flex_texcoord, nflextexcoord, 2 ) \
|
||||
X ( int, mesh_vertadr, nmesh, 1 ) \
|
||||
X ( int, mesh_vertnum, nmesh, 1 ) \
|
||||
X ( int, mesh_normaladr, nmesh, 1 ) \
|
||||
@@ -456,6 +519,7 @@
|
||||
XMJV( int, name_siteadr, nsite, 1 ) \
|
||||
XMJV( int, name_camadr, ncam, 1 ) \
|
||||
XMJV( int, name_lightadr, nlight, 1 ) \
|
||||
X ( int, name_flexadr, nflex, 1 ) \
|
||||
X ( int, name_meshadr, nmesh, 1 ) \
|
||||
X ( int, name_skinadr, nskin, 1 ) \
|
||||
X ( int, name_hfieldadr, nhfield, 1 ) \
|
||||
@@ -522,6 +586,13 @@
|
||||
XMJV( mjtNum, subtree_com, nbody, 3 ) \
|
||||
X ( mjtNum, cdof, nv, 6 ) \
|
||||
X ( mjtNum, cinert, nbody, 10 ) \
|
||||
XMJV( mjtNum, flexvert_xpos, nflexvert, 3 ) \
|
||||
X ( mjtNum, flexelem_aabb, nflexelem, 6 ) \
|
||||
X ( int, flexedge_J_rownnz, nflexedge, 1 ) \
|
||||
X ( int, flexedge_J_rowadr, nflexedge, 1 ) \
|
||||
X ( int, flexedge_J_colind, nflexedge, MJ_M(nv) ) \
|
||||
X ( mjtNum, flexedge_J, nflexedge, MJ_M(nv) ) \
|
||||
X ( mjtNum, flexedge_length, nflexedge, 1 ) \
|
||||
XMJV( int, ten_wrapadr, ntendon, 1 ) \
|
||||
XMJV( int, ten_wrapnum, ntendon, 1 ) \
|
||||
X ( int, ten_J_rownnz, ntendon, 1 ) \
|
||||
@@ -538,7 +609,9 @@
|
||||
X ( mjtNum, qLD, nM, 1 ) \
|
||||
X ( mjtNum, qLDiagInv, nv, 1 ) \
|
||||
X ( mjtNum, qLDiagSqrtInv, nv, 1 ) \
|
||||
X ( mjtNum, bvh_aabb_dyn, nbvhdynamic, 6 ) \
|
||||
XMJV( mjtByte, bvh_active, nbvh, 1 ) \
|
||||
X ( mjtNum, flexedge_velocity, nflexedge, 1 ) \
|
||||
X ( mjtNum, ten_velocity, ntendon, 1 ) \
|
||||
X ( mjtNum, actuator_velocity, nu, 1 ) \
|
||||
X ( mjtNum, cvel, nbody, 6 ) \
|
||||
@@ -644,10 +717,6 @@
|
||||
X( int, maxuse_con ) \
|
||||
X( int, maxuse_efc ) \
|
||||
X( int, solver_nisland ) \
|
||||
X( int, nbodypair_broad ) \
|
||||
X( int, nbodypair_narrow ) \
|
||||
X( int, ngeompair_mid ) \
|
||||
X( int, ngeompair_narrow ) \
|
||||
X( int, ne ) \
|
||||
X( int, nf ) \
|
||||
X( int, nl ) \
|
||||
|
||||
+12
-2
@@ -312,6 +312,9 @@ MJAPI void mj_comPos(const mjModel* m, mjData* d);
|
||||
// Compute camera and light positions and orientations.
|
||||
MJAPI void mj_camlight(const mjModel* m, mjData* d);
|
||||
|
||||
// Compute flex-related quantities.
|
||||
MJAPI void mj_flex(const mjModel* m, mjData* d);
|
||||
|
||||
// Compute tendon lengths, velocities and moment arms.
|
||||
MJAPI void mj_tendon(const mjModel* m, mjData* d);
|
||||
|
||||
@@ -518,6 +521,12 @@ MJAPI mjtNum mj_rayMesh(const mjModel* m, const mjData* d, int geomid,
|
||||
MJAPI mjtNum mju_rayGeom(const mjtNum pos[3], const mjtNum mat[9], const mjtNum size[3],
|
||||
const mjtNum pnt[3], const mjtNum vec[3], int geomtype);
|
||||
|
||||
// Intersect ray with flex, return nearest distance or -1 if no intersection,
|
||||
// and also output nearest vertex id.
|
||||
MJAPI mjtNum mju_rayFlex(const mjModel* m, const mjData* d, int flex_layer, mjtByte flg_vert,
|
||||
mjtByte flg_edge, mjtByte flg_face, mjtByte flg_skin, int flexid,
|
||||
const mjtNum* pnt, const mjtNum* vec, int vertid[1]);
|
||||
|
||||
// Intersect ray with skin, return nearest distance or -1 if no intersection,
|
||||
// and also output nearest vertex id.
|
||||
MJAPI mjtNum mju_raySkin(int nface, int nvert, const int* face, const float* vert,
|
||||
@@ -593,10 +602,11 @@ MJAPI void mjv_applyPerturbForce(const mjModel* m, mjData* d, const mjvPerturb*
|
||||
// Return the average of two OpenGL cameras.
|
||||
MJAPI mjvGLCamera mjv_averageCamera(const mjvGLCamera* cam1, const mjvGLCamera* cam2);
|
||||
|
||||
// Select geom or skin with mouse, return bodyid; -1: none selected.
|
||||
// Select geom, flex or skin with mouse, return bodyid; -1: none selected.
|
||||
MJAPI int mjv_select(const mjModel* m, const mjData* d, const mjvOption* vopt,
|
||||
mjtNum aspectratio, mjtNum relx, mjtNum rely,
|
||||
const mjvScene* scn, mjtNum selpnt[3], int geomid[1], int skinid[1]);
|
||||
const mjvScene* scn, mjtNum selpnt[3],
|
||||
int geomid[1], int flexid[1], int skinid[1]);
|
||||
|
||||
|
||||
//---------------------------------- Visualization -------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user