Miscellaneous linting in src/engine.

PiperOrigin-RevId: 462415459
Change-Id: I6c79c592613c6b0a665af06faf945586bb6ba32d
This commit is contained in:
Saran Tunyasuvunakool
2022-07-21 10:16:08 -07:00
committed by Copybara-Service
parent eef473b1e1
commit b849023069
19 changed files with 329 additions and 416 deletions
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -183,10 +183,11 @@ void mjccd_support(const void *obj, const ccd_vec3_t *_dir, ccd_vec3_t *vec) {
}
// copy best vertex
else
else {
for (int i=0; i<3; i++) {
res[i] = (mjtNum)vertdata[3*ibest + i];
}
}
break;
default:
@@ -295,10 +296,9 @@ int mjc_Convex(const mjModel* m, const mjData* d,
int ncon = mjc_MPRIteration(&obj1, &obj2, &ccd, m, d, con, g1, g2, margin);
// look for additional contacts
if (ncon && mjENABLED(mjENBL_MULTICCD) // TODO(tassa) leave as bitflag or make geom attribute (?)
if (ncon && mjENABLED(mjENBL_MULTICCD) // TODO(tassa) leave as bitflag or make geom attribute (?)
&& m->geom_type[g1] != mjGEOM_ELLIPSOID && m->geom_type[g1] != mjGEOM_SPHERE
&& m->geom_type[g2] != mjGEOM_ELLIPSOID && m->geom_type[g2] != mjGEOM_SPHERE) {
// multiCCD parameters
const mjtNum relative_tolerance = 1e-3;
const mjtNum perturbation_angle = 1e-3;
@@ -614,10 +614,10 @@ int mjc_ConvexHField(const mjModel* m, const mjData* d,
}
// box-sphere test in: vertical direction
if (size1[2] < pos[2]-r2-margin) { // up
if (size1[2] < pos[2]-r2-margin) { // up
return 0;
}
if (-size1[3] > pos[2]+r2+margin) { // down
if (-size1[3] > pos[2]+r2+margin) { // down
return 0;
}
+2 -3
View File
@@ -34,7 +34,6 @@
// table of pair-wise collision functions
mjfCollision mjCOLLISIONFUNC[mjNGEOMTYPES][mjNGEOMTYPES] = {
/* PLANE HFIELD SPHERE CAPSULE ELLIPSOID CYLINDER BOX MESH */
/*PLANE */ {0, 0, mjc_PlaneSphere, mjc_PlaneCapsule, mjc_PlaneConvex, mjc_PlaneCylinder, mjc_PlaneBox, mjc_PlaneConvex},
/*HFIELD */ {0, 0, mjc_ConvexHField, mjc_ConvexHField, mjc_ConvexHField, mjc_ConvexHField, mjc_ConvexHField, mjc_ConvexHField},
@@ -44,7 +43,6 @@ mjfCollision mjCOLLISIONFUNC[mjNGEOMTYPES][mjNGEOMTYPES] = {
/*CYLINDER */ {0, 0, 0, 0, 0, mjc_Convex, mjc_Convex, mjc_Convex},
/*BOX */ {0, 0, 0, 0, 0, 0, mjc_BoxBox, mjc_Convex},
/*MESH */ {0, 0, 0, 0, 0, 0, 0, mjc_Convex}
};
@@ -146,10 +144,11 @@ void mj_collision(const mjModel* m, mjData* d) {
}
// finish merging predefined pairs
if (npair && m->opt.collision==mjCOL_ALL)
if (npair && m->opt.collision==mjCOL_ALL) {
while (pairadr<npair) {
mj_collideGeoms(m, d, pairadr++, -1, 0, 0);
}
}
}
mjFREESTACK;
+8 -6
View File
@@ -145,12 +145,14 @@ int mj_addConstraint(const mjModel* m, mjData* d,
// dense: copy entire Jacobian
if (!mj_isSparse(m)) {
// make sure jac is not empty
if (empty)
for (int i=0; i<size*nv; i++)
if (empty) {
for (int i=0; i<size*nv; i++) {
if (jac[i]) {
empty = 0;
break;
}
}
}
// copy if not empty
if (!empty) {
@@ -506,11 +508,11 @@ void mj_instantiateEquality(const mjModel* m, mjData* d) {
deriv = data[1] + 2*data[2]*dif + 3*data[3]*dif*dif + 4*data[4]*dif*dif*dif;
// compute Jacobian: sparse or dense
if (issparse)
if (issparse) {
NV = mju_combineSparse(jac[0], jac[1], nv, 1, -deriv,
NV, NV2, chain, chain2,
sparse_buf, buf_ind);
else {
} else {
mju_addToScl(jac[0], jac[1], -deriv, nv);
}
}
@@ -948,7 +950,7 @@ void mj_diagApprox(const mjModel* m, mjData* d) {
dA[i] = m->body_invweight0[2*b1] + m->body_invweight0[2*b2];
break;
case mjEQ_WELD: // distingush translation and rotation inertia
case mjEQ_WELD: // distingush translation and rotation inertia
// body translation or rotation depending on weldcnt
b1 = m->eq_obj1id[id];
b2 = m->eq_obj2id[id];
@@ -1117,7 +1119,7 @@ static void getposdim(const mjModel* m, const mjData* d, int i, mjtNum* pos, int
case mjCNSTR_EQUALITY:
if (m->eq_type[id]==mjEQ_WELD) {
*dim = 6;
*pos = mju_norm(d->efc_pos+i, 6); // mixes translation and rotation!
*pos = mju_norm(d->efc_pos+i, 6); // mixes translation and rotation!
} else if (m->eq_type[id]==mjEQ_CONNECT) {
*dim = 3;
*pos = mju_norm(d->efc_pos+i, 3);
+2 -2
View File
@@ -63,10 +63,10 @@ int mj_addConstraint(const mjModel* m, mjData* d,
int size, int type, int id, int NV, const int* chain);
// merge dof chains for two bodies
int mj_mergeChain(const mjModel* m, int* dofid, int b1, int b2);
int mj_mergeChain(const mjModel* m, int* chain, int b1, int b2);
// merge dof chains for two simple bodies
int mj_mergeChainSimple(const mjModel* m, int* dofid, int b1, int b2);
int mj_mergeChainSimple(const mjModel* m, int* chain, int b1, int b2);
//-------------------------- constraint instantiation ----------------------------------------------
+5 -10
View File
@@ -178,7 +178,6 @@ void mj_kinematics(const mjModel* m, mjData* d) {
// map inertias and motion dofs to global frame centered at subtree-CoM
void mj_comPos(const mjModel* m, mjData* d) {
mjtNum offset[3], axis[3];
mjMARKSTACK;
mjtNum* mass_subtree = mj_stackAlloc(d, m->nbody);
@@ -538,7 +537,7 @@ void mj_tendon(const mjModel* m, mjData* d) {
}
// accumulate moments if consequtive points are in different bodies
for (int k=0; k<(wlen<0 ? 1:3); k++) {
for (int k=0; k<(wlen<0 ? 1 : 3); k++) {
if (wbody[k]!=wbody[k+1]) {
// get 3D position difference, normalize
mju_sub3(dif, wpnt+3*k+3, wpnt+3*k);
@@ -787,7 +786,7 @@ void mj_transmission(const mjModel* m, mjData* d) {
break;
default:
mju_error_i("Unknown transmission type %d", m->actuator_trntype[i]); // SHOULD NOT OCCUR
mju_error_i("Unknown transmission type %d", m->actuator_trntype[i]); // SHOULD NOT OCCUR
}
}
@@ -1429,9 +1428,9 @@ void mj_ellipsoidFluidModel(const mjModel* m, mjData* d, int bodyid) {
mju_zero(wind, 6);
mju_copy3(wind+3, m->opt.wind);
mju_transformSpatial(lwind, wind, 0,
d->geom_xpos + 3*geomid, // Frame of ref's origin.
d->geom_xpos + 3*geomid, // Frame of ref's origin.
d->subtree_com + 3*m->body_rootid[bodyid],
d->geom_xmat + 9*geomid); // Frame of ref's orientation.
d->geom_xmat + 9*geomid); // Frame of ref's orientation.
// subtract translational component from grom velocity
mju_subFrom3(lvel+3, lwind+3);
@@ -1455,7 +1454,7 @@ void mj_ellipsoidFluidModel(const mjModel* m, mjData* d, int bodyid) {
// apply force and torque to body com
mj_applyFT(m, d, bfrc+3, bfrc,
d->geom_xpos + 3*geomid, // point where FT is generated
d->geom_xpos + 3*geomid, // point where FT is generated
bodyid, d->qfrc_passive);
}
}
@@ -1798,7 +1797,6 @@ void mj_rnePostConstraint(const mjModel* m, mjData* d) {
// body 1
if ((k = m->eq_obj1id[id])) {
// transform connect point on body1: local -> global
mju_rotVecMat(pos, eq_data, d->xmat+9*k);
mju_addTo3(pos, d->xpos+3*k);
@@ -1812,7 +1810,6 @@ void mj_rnePostConstraint(const mjModel* m, mjData* d) {
// body 2
if ((k = m->eq_obj2id[id])) {
// transform connect point on body2: local -> global
mju_rotVecMat(pos, eq_data + 3, d->xmat+9*k);
mju_addTo3(pos, d->xpos+3*k);
@@ -1836,7 +1833,6 @@ void mj_rnePostConstraint(const mjModel* m, mjData* d) {
// body 1
if ((k = m->eq_obj1id[id])) {
// transform weld point on body1: local -> global
mju_rotVecMat(pos, eq_data, d->xmat+9*k);
mju_addTo3(pos, d->xpos+3*k);
@@ -1850,7 +1846,6 @@ void mj_rnePostConstraint(const mjModel* m, mjData* d) {
// body 2
if ((k = m->eq_obj2id[id])) {
// weld force on body2 is always applied at body root
mju_copy3(pos, d->xpos+3*k);
+9 -11
View File
@@ -345,7 +345,7 @@ void mj_stepSkip(const mjModel* m, mjData* d, int skipstage, int skipsensor) {
}
// use selected integrator
switch(m->opt.integrator) {
switch (m->opt.integrator) {
case mjINT_EULER:
mj_EulerSkip(m, d, skipstage >= mjSTAGE_POS);
break;
@@ -573,7 +573,6 @@ static void addJTBJSparse(mjtNum* DfDv, const mjtNum* J, const mjtNum* B,
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
if (B[i*n+j]) {
// process non-zero elements of J(i,k)
for (int k=0; k<rownnz[offset+i]; k++) {
int ik = rowadr[offset+i] + k;
@@ -660,7 +659,7 @@ static mjtNum mjd_muscleGain_vel(mjtNum len, mjtNum vel, const mjtNum lengthrang
}
// compute FVL and scale, make it negative
return -force*FL*dFV/mjMAX(mjMINVAL,L0*vmax);
return -force*FL*dFV/mjMAX(mjMINVAL, L0*vmax);
}
@@ -758,7 +757,7 @@ static void mjd_addedMassForces(
mjtNum* restrict B, const mjtNum local_vels[6], const mjtNum fluid_density,
const mjtNum virtual_mass[3], const mjtNum virtual_inertia[3]) {
const mjtNum lin_vel[3] = {local_vels[3], local_vels[4], local_vels[5]};
const mjtNum ang_vel[3] = {local_vels[0], local_vels[1], local_vels[2]};;
const mjtNum ang_vel[3] = {local_vels[0], local_vels[1], local_vels[2]};
const mjtNum virtual_lin_mom[3] = {
fluid_density * virtual_mass[0] * lin_vel[0],
fluid_density * virtual_mass[1] * lin_vel[1],
@@ -1057,9 +1056,9 @@ void mjd_ellipsoidFluid(const mjModel* m, mjData* d, mjtNum* DfDv, int bodyid) {
mju_zero(wind, 6);
mju_copy3(wind+3, m->opt.wind);
mju_transformSpatial(lwind, wind, 0,
d->geom_xpos + 3*geomid, // Frame of ref's origin.
d->geom_xpos + 3*geomid, // Frame of ref's origin.
d->subtree_com + 3*m->body_rootid[bodyid],
d->geom_xmat + 9*geomid); // Frame of ref's orientation.
d->geom_xmat + 9*geomid); // Frame of ref's orientation.
// subtract translational component from grom velocity
mju_subFrom3(lvel+3, lwind+3);
@@ -1484,10 +1483,10 @@ void mjd_stepFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte centered,
mjMARKSTACK;
// states
mjtNum *state = mj_stackAlloc(d, nq+nv+na); // current state
mjtNum *next = mj_stackAlloc(d, nq+nv+na); // next state
mjtNum *next_plus = mj_stackAlloc(d, nq+nv+na); // forward-nudged next state
mjtNum *next_minus = mj_stackAlloc(d, nq+nv+na); // backward-nudged next state
mjtNum *state = mj_stackAlloc(d, nq+nv+na); // current state
mjtNum *next = mj_stackAlloc(d, nq+nv+na); // next state
mjtNum *next_plus = mj_stackAlloc(d, nq+nv+na); // forward-nudged next state
mjtNum *next_minus = mj_stackAlloc(d, nq+nv+na); // backward-nudged next state
// warmstart accelerations
mjtNum *warmstart = mjDISABLED(mjDSBL_WARMSTART) ? NULL : mj_stackAlloc(d, nv);
@@ -1567,7 +1566,6 @@ void mjd_stepFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte centered,
// finite-difference activations: skip=mjSTAGE_VEL
if (DyDa || DsDa) {
for (int i=0; i<na; i++) {
// nudge forward
d->act[i] += eps;
+1 -1
View File
@@ -47,4 +47,4 @@ MJAPI void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte cen
}
#endif
#endif // MUJOCO_SRC_ENGINE_ENGINE_DERIVATIVE_H_
#endif // MUJOCO_SRC_ENGINE_ENGINE_DERIVATIVE_H_
+2 -2
View File
@@ -35,7 +35,7 @@ void* mju_fileToMemory(const char* filename, int* filesize) {
}
// ensure file size fits in int
long long_filesize = ftell(fp);
long long_filesize = ftell(fp); // NOLINT(runtime/int)
if (long_filesize > INT_MAX) {
fclose(fp);
mju_warning_s("File size over 2GB is not supported. File: '%s'", filename);
@@ -62,7 +62,7 @@ void* mju_fileToMemory(const char* filename, int* filesize) {
size_t bytes_read = fread(buffer, 1, *filesize, fp);
// check that read data matches file size
if (bytes_read != *filesize) { // SHOULD NOT OCCUR
if (bytes_read != *filesize) { // SHOULD NOT OCCUR
if (ferror(fp)) {
fclose(fp);
mju_free(buffer);
+1 -2
View File
@@ -485,7 +485,6 @@ static void mj_advance(const mjModel* m, mjData* d,
// Euler integrator, semi-implicit in velocity, possibly skipping factorisation
void mj_EulerSkip(const mjModel* m, mjData* d, int skipfactor) {
int i, nv = m->nv, nM = m->nM;
mjMARKSTACK;
mjtNum* qfrc = mj_stackAlloc(d, nv);
@@ -755,7 +754,7 @@ void mj_step(const mjModel* m, mjData* d) {
}
// use selected integrator
switch(m->opt.integrator) {
switch (m->opt.integrator) {
case mjINT_EULER:
mj_Euler(m, d);
break;
-1
View File
@@ -1181,7 +1181,6 @@ static int numObjects(const mjModel* m, mjtObj objtype) {
// validate reference fields in a model; return null if valid, error message otherwise
const char* mj_validateReferences(const mjModel* m) {
// for each field in mjModel that refers to another field, call X with:
// adrarray: array containing the references
// nadrs: number of elements in refarray
+3 -3
View File
@@ -15,7 +15,7 @@
#ifndef MUJOCO_SRC_ENGINE_ENGINE_MACRO_H_
#define MUJOCO_SRC_ENGINE_ENGINE_MACRO_H_
#include "engine/engine_callback.h"
#include "engine/engine_callback.h" // IWYU pragma: export
//-------------------------------- utility macros --------------------------------------------------
@@ -28,8 +28,8 @@
#define mjENABLED(x) (m->opt.enableflags & (x))
// max and min macros
#define mjMAX(a,b) (((a) > (b)) ? (a) : (b))
#define mjMIN(a,b) (((a) < (b)) ? (a) : (b))
#define mjMAX(a, b) (((a) > (b)) ? (a) : (b))
#define mjMIN(a, b) (((a) < (b)) ? (a) : (b))
//-------------------------- timer macros ----------------------------------------------------------
+2 -2
View File
@@ -224,7 +224,7 @@ void mj_printFormattedModel(const mjModel* m, const char* filename, const char*
// sizes
#define X( name ) \
if(m->name) { \
if (m->name) { \
fprintf(fp, NAME_FORMAT, #name); \
fprintf(fp, INT_FORMAT "\n", m->name); \
}
@@ -789,7 +789,7 @@ void mj_printFormattedData(const mjModel* m, mjData* d, const char* filename,
if (active_timers) {
fprintf(fp, "TIMER\n");
for (int i=0; i<mjNTIMER; i++) {
fprintf(fp, " %d: duration = ",i);
fprintf(fp, " %d: duration = ", i);
fprintf(fp, float_format, d->timer[i].duration);
fprintf(fp, " number = %d\n", d->timer[i].number);
}
+2 -2
View File
@@ -47,7 +47,7 @@ static void add_noise(const mjModel* m, mjData* d, mjtStage stage) {
// real or positive: add noise directly, with clamp for positive
if (m->sensor_datatype[i]==mjDATATYPE_REAL ||
m->sensor_datatype[i]==mjDATATYPE_POSITIVE)
m->sensor_datatype[i]==mjDATATYPE_POSITIVE) {
for (int j=0; j<dim; j++) {
// get random numbers; use only the first one
rnd[0] = mju_standardNormal(rnd+1);
@@ -65,6 +65,7 @@ static void add_noise(const mjModel* m, mjData* d, mjtStage stage) {
d->sensordata[adr+j] += rnd[0]*noise;
}
}
}
// axis or quat: rotate around random axis by random angle
else {
@@ -114,7 +115,6 @@ static void apply_cutoff(const mjModel* m, mjData* d, mjtStage stage) {
// process all dimensions
for (int j=0; j<dim; j++) {
// real: apply on both sides
if (m->sensor_datatype[i]==mjDATATYPE_REAL) {
d->sensordata[adr+j] = mju_clip(d->sensordata[adr+j], -cutoff, cutoff);
+16 -7
View File
@@ -102,15 +102,24 @@ void _mjPRIVATE__set_tls_warning_fn(callback_fn h) {
// write datetime, type: message to MUJOCO_LOG.TXT
void mju_writeLog(const char* type, const char* msg) {
time_t rawtime;
struct tm *timeinfo;
struct tm timeinfo;
FILE* fp = fopen("MUJOCO_LOG.TXT", "a+t");
if (fp) {
// get time
time(&rawtime);
timeinfo = localtime(&rawtime);
#if defined(_POSIX_C_SOURCE) || defined(__APPLE__) || defined(__STDC_VERSION_TIME_H__)
localtime_r(&rawtime, &timeinfo);
#elif _MSC_VER
localtime_s(&timeinfo, &rawtime);
#elif __STDC_LIB_EXT1__
localtime_s(&rawtime, &timeinfo);
#else
#error "Thread-safe version of `localtime` is not present in the standard C library"
#endif
// write to log file
fprintf(fp, "%s%s: %s\n\n", asctime(timeinfo), type, msg);
fprintf(fp, "%s%s: %s\n\n", asctime(&timeinfo), type, msg);
fclose(fp);
}
}
@@ -151,7 +160,7 @@ void mju_warning(const char* msg) {
// error with int argument
void mju_error_i(const char* msg, int i) {
char errmsg[1000];
snprintf(errmsg, 1000, msg, i);
snprintf(errmsg, sizeof(errmsg), msg, i);
errmsg[999] = '\0';
mju_error(errmsg);
}
@@ -160,7 +169,7 @@ void mju_error_i(const char* msg, int i) {
// warning with int argument
void mju_warning_i(const char* msg, int i) {
char wrnmsg[1000];
snprintf(wrnmsg, 1000, msg, i);
snprintf(wrnmsg, sizeof(wrnmsg), msg, i);
wrnmsg[999] = '\0';
mju_warning(wrnmsg);
}
@@ -169,7 +178,7 @@ void mju_warning_i(const char* msg, int i) {
// error string argument
void mju_error_s(const char* msg, const char* text) {
char errmsg[1000];
snprintf(errmsg, 1000, msg, text);
snprintf(errmsg, sizeof(errmsg), msg, text);
errmsg[999] = '\0';
mju_error(errmsg);
}
@@ -178,7 +187,7 @@ void mju_error_s(const char* msg, const char* text) {
// warning string argument
void mju_warning_s(const char* msg, const char* text) {
char wrnmsg[1000];
snprintf(wrnmsg, 1000, msg, text);
snprintf(wrnmsg, sizeof(wrnmsg), msg, text);
wrnmsg[999] = '\0';
mju_warning(wrnmsg);
}
+4 -3
View File
@@ -18,7 +18,6 @@
#include <string.h>
#include <mujoco/mjdata.h>
#include <mujoco/mjmodel.h>
#include "engine/engine_io.h"
#include "engine/engine_macro.h"
#include "engine/engine_util_blas.h"
@@ -116,13 +115,15 @@ int mju_cholUpdate(mjtNum* mat, mjtNum* x, int n, int flg_plus) {
mat[k*(n+1)] = r;
// update mat
if (flg_plus)
if (flg_plus) {
for (int i=k+1; i<n; i++) {
mat[i*n+k] = (mat[i*n+k] + s*x[i])*cinv;
} else
}
} else {
for (int i=k+1; i<n; i++) {
mat[i*n+k] = (mat[i*n+k] - s*x[i])*cinv;
}
}
// update x
for (int i=k+1; i<n; i++) {
+5 -2
View File
@@ -262,16 +262,19 @@ void mju_mulMatVecSparse(mjtNum* res, const mjtNum* mat, const mjtNum* vec,
const int* colind, const int* rowsuper) {
// no supernodes, or no AVX
#ifdef mjUSEAVX
if (!rowsuper)
if (!rowsuper) {
#endif
{
// regular sparse dot-product
for (int r=0; r<nr; r++) {
res[r] = mju_dotSparse(mat+rowadr[r], vec, rownnz[r], colind+rowadr[r]);
}
return;
#ifdef mjUSEAVX
}
#endif
// regular or supernode
for (int r=0; r<nr; r++) {
+39 -34
View File
@@ -32,7 +32,9 @@
//----------------------------- utility functions and macros ---------------------------------------
static const mjtNum IDENTITY[9] = {1,0,0, 0,1,0, 0,0,1};
static const mjtNum IDENTITY[9] = {1, 0, 0,
0, 1, 0,
0, 0, 1};
// copy float array
@@ -64,16 +66,18 @@ static void makeLabel(const mjModel* m, mjtObj type, int id, char* label) {
// return if there is no space in buffer
#define START \
if( scn->ngeom>=scn->maxgeom ) \
{ mj_warning(d, mjWARN_VGEOMFULL, scn->maxgeom); \
return; } \
else { thisgeom = scn->geoms + scn->ngeom; \
mjv_initGeom(thisgeom, mjGEOM_NONE, NULL, NULL, NULL, NULL); \
thisgeom->objtype = objtype; \
thisgeom->objid = i; \
thisgeom->category = category; \
thisgeom->segid = scn->ngeom; }
#define START \
if ( scn->ngeom>=scn->maxgeom ) { \
mj_warning(d, mjWARN_VGEOMFULL, scn->maxgeom); \
return; \
} else { \
thisgeom = scn->geoms + scn->ngeom; \
mjv_initGeom(thisgeom, mjGEOM_NONE, NULL, NULL, NULL, NULL); \
thisgeom->objtype = objtype; \
thisgeom->objid = i; \
thisgeom->category = category; \
thisgeom->segid = scn->ngeom; \
}
// advance counter
@@ -327,29 +331,30 @@ void mjv_initGeom(mjvGeom* geom, int type, const mjtNum* size,
geom->type = type;
// set size (for XYZ scaling)
if (size)
if (size) {
switch (type) {
case mjGEOM_SPHERE:
geom->size[0] = (float)size[0];
geom->size[1] = (float)size[0];
geom->size[2] = (float)size[0];
break;
case mjGEOM_SPHERE:
geom->size[0] = (float)size[0];
geom->size[1] = (float)size[0];
geom->size[2] = (float)size[0];
break;
case mjGEOM_CAPSULE:
geom->size[0] = (float)size[0];
geom->size[1] = (float)size[0];
geom->size[2] = (float)size[1];
break;
case mjGEOM_CAPSULE:
geom->size[0] = (float)size[0];
geom->size[1] = (float)size[0];
geom->size[2] = (float)size[1];
break;
case mjGEOM_CYLINDER:
geom->size[0] = (float)size[0];
geom->size[1] = (float)size[0];
geom->size[2] = (float)size[1];
break;
case mjGEOM_CYLINDER:
geom->size[0] = (float)size[0];
geom->size[1] = (float)size[0];
geom->size[2] = (float)size[1];
break;
default:
mju_n2f(geom->size, size, 3);
} else {
default:
mju_n2f(geom->size, size, 3);
}
} else {
geom->size[0] = 0.1f;
geom->size[1] = 0.1f;
geom->size[2] = 0.1f;
@@ -838,7 +843,6 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
if (m->actuator_trntype[i]==mjTRN_JOINT ||
m->actuator_trntype[i]==mjTRN_JOINTINPARENT ||
m->actuator_trntype[i]==mjTRN_SITE) {
START
// site actuators
@@ -1355,8 +1359,8 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
// slider-crank
objtype = mjOBJ_ACTUATOR;
category = mjCAT_DYNAMIC;
if ((category & catmask))
for (int i=0; i<m->nu; i++)
if ((category & catmask)) {
for (int i=0; i<m->nu; i++) {
if (m->actuator_trntype[i]==mjTRN_SLIDERCRANK) {
// get data
int j = m->actuator_trnid[2*i]; // crank
@@ -1404,6 +1408,8 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
}
FINISH
}
}
}
// center of mass for root bodies
objtype = mjOBJ_UNKNOWN;
@@ -1778,7 +1784,6 @@ void mjv_updateSkin(const mjModel* m, mjData* d, mjvScene* scn) {
// update visible skins only
void mjv_updateActiveSkin(const mjModel* m, mjData* d, mjvScene* scn, const mjvOption* opt) {
// process skins
for (int i=0; i<m->nskin; i++) {
// get info
+1
View File
@@ -20,6 +20,7 @@
#include <limits>
#include <string>
#include <mujoco/mjtnum.h>
#include "engine/engine_macro.h"
using std::isnan;