Change MuJoCo engine source code function-spacing convention from 3 blank lines to 2
PiperOrigin-RevId: 813754244 Change-Id: I6836e41c3b021cb727e922c25c60f629b9814c93
This commit is contained in:
committed by
Copybara-Service
parent
c439628f82
commit
edbdb5195c
@@ -51,7 +51,6 @@ static mjtByte is_intersect(const mjtNum* p1, const mjtNum* p2,
|
||||
}
|
||||
|
||||
|
||||
|
||||
// curve length along circle
|
||||
static mjtNum length_circle(const mjtNum* p0, const mjtNum* p1, int ind, mjtNum radius) {
|
||||
mjtNum p0n[2] = {p0[0], p0[1]};
|
||||
@@ -72,7 +71,6 @@ static mjtNum length_circle(const mjtNum* p0, const mjtNum* p1, int ind, mjtNum
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 2D circle wrap
|
||||
// input: pair of 2D endpoints in end[4], optional 2D side point in side[2], radius
|
||||
// output: return length of circular wrap or -1
|
||||
@@ -154,7 +152,6 @@ static mjtNum wrap_circle(mjtNum pnt[4], const mjtNum end[4], const mjtNum* side
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 2D inside wrap
|
||||
// input: pair of 2D endpoints in end[4], radius
|
||||
// output: pair of 2D points in pnt[4]; return 0 if wrap, -1 if no wrap
|
||||
@@ -274,7 +271,6 @@ static mjtNum wrap_inside(mjtNum pnt[4], const mjtNum end[4], mjtNum radius) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// wrap tendons around spheres and cylinders
|
||||
// input: x0, x1: pair of 3D endpoints
|
||||
// xpos, xmat, radius: position, orientation and radius of geom
|
||||
@@ -421,7 +417,6 @@ mjtNum mju_wrap(mjtNum wpnt[6], const mjtNum x0[3], const mjtNum x1[3],
|
||||
}
|
||||
|
||||
|
||||
|
||||
// all 3 semi-axes of a geom
|
||||
void mju_geomSemiAxes(mjtNum semiaxes[3], const mjtNum size[3], mjtGeom type) {
|
||||
switch (type) {
|
||||
@@ -543,7 +538,6 @@ void mju_defGradient(mjtNum res[9], const mjtNum p[3], const mjtNum* dof, int or
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------ actuator models ---------------------------------------------------
|
||||
|
||||
// normalized muscle length-gain curve
|
||||
@@ -572,7 +566,6 @@ mjtNum mju_muscleGainLength(mjtNum length, mjtNum lmin, mjtNum lmax) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// muscle active force, prm = (range[2], force, scale, lmin, lmax, vmax, fpmax, fvmax)
|
||||
mjtNum mju_muscleGain(mjtNum len, mjtNum vel, const mjtNum lengthrange[2],
|
||||
mjtNum acc0, const mjtNum prm[9]) {
|
||||
@@ -618,7 +611,6 @@ mjtNum mju_muscleGain(mjtNum len, mjtNum vel, const mjtNum lengthrange[2],
|
||||
}
|
||||
|
||||
|
||||
|
||||
// muscle passive force, prm = (range[2], force, scale, lmin, lmax, vmax, fpmax, fvmax)
|
||||
mjtNum mju_muscleBias(mjtNum len, const mjtNum lengthrange[2],
|
||||
mjtNum acc0, const mjtNum prm[9]) {
|
||||
@@ -654,7 +646,6 @@ mjtNum mju_muscleBias(mjtNum len, const mjtNum lengthrange[2],
|
||||
}
|
||||
|
||||
|
||||
|
||||
// muscle time constant with optional smoothing
|
||||
mjtNum mju_muscleDynamicsTimescale(mjtNum dctrl, mjtNum tau_act, mjtNum tau_deact,
|
||||
mjtNum smoothing_width) {
|
||||
@@ -674,7 +665,6 @@ mjtNum mju_muscleDynamicsTimescale(mjtNum dctrl, mjtNum tau_act, mjtNum tau_deac
|
||||
}
|
||||
|
||||
|
||||
|
||||
// muscle activation dynamics, prm = (tau_act, tau_deact, smoothing_width)
|
||||
mjtNum mju_muscleDynamics(mjtNum ctrl, mjtNum act, const mjtNum prm[3]) {
|
||||
// clamp control
|
||||
@@ -696,7 +686,6 @@ mjtNum mju_muscleDynamics(mjtNum ctrl, mjtNum act, const mjtNum prm[3]) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------- Base64 --------------------------------------------------
|
||||
|
||||
// decoding function for Base64
|
||||
@@ -725,7 +714,6 @@ static uint32_t _decode(char ch) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// encode data as Base64 into buf (including padding and null char)
|
||||
// returns number of chars written in buf: 4 * [(ndata + 2) / 3] + 1
|
||||
size_t mju_encodeBase64(char* buf, const uint8_t* data, size_t ndata) {
|
||||
@@ -779,7 +767,6 @@ size_t mju_encodeBase64(char* buf, const uint8_t* data, size_t ndata) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return size in decoded bytes if s is a valid Base64 encoding
|
||||
// return 0 if s is empty or invalid Base64 encoding
|
||||
size_t mju_isValidBase64(const char* s) {
|
||||
@@ -810,7 +797,6 @@ size_t mju_isValidBase64(const char* s) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// decode valid Base64 in string s into buf, undefined behavior if s is not valid Base64
|
||||
// returns number of bytes decoded (upper limit of 3 * (strlen(s) / 4))
|
||||
size_t mju_decodeBase64(uint8_t* buf, const char* s) {
|
||||
@@ -841,7 +827,6 @@ size_t mju_decodeBase64(uint8_t* buf, const char* s) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------ miscellaneous -----------------------------------------------------
|
||||
|
||||
// convert contact force to pyramid representation
|
||||
@@ -861,7 +846,6 @@ void mju_encodePyramid(mjtNum* pyramid, const mjtNum* force, const mjtNum* mu, i
|
||||
}
|
||||
|
||||
|
||||
|
||||
// convert pyramid representation to contact force
|
||||
void mju_decodePyramid(mjtNum* force, const mjtNum* pyramid, const mjtNum* mu, int dim) {
|
||||
// special handling of frictionless contacts
|
||||
@@ -883,7 +867,6 @@ void mju_decodePyramid(mjtNum* force, const mjtNum* pyramid, const mjtNum* mu, i
|
||||
}
|
||||
|
||||
|
||||
|
||||
// integrate spring-damper analytically, return pos(t)
|
||||
mjtNum mju_springDamper(mjtNum pos0, mjtNum vel0, mjtNum k, mjtNum b, mjtNum t) {
|
||||
mjtNum det, c1, c2, r1, r2, w;
|
||||
@@ -936,7 +919,6 @@ mjtNum mju_springDamper(mjtNum pos0, mjtNum vel0, mjtNum k, mjtNum b, mjtNum t)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return 1 if point is outside box given by pos, mat, size * inflate
|
||||
// return -1 if point is inside box given by pos, mat, size / inflate
|
||||
// return 0 if point is between the inflated and deflated boxes
|
||||
@@ -982,7 +964,6 @@ int mju_outsideBox(const mjtNum point[3], const mjtNum pos[3], const mjtNum mat[
|
||||
}
|
||||
|
||||
|
||||
|
||||
// print matrix to screen
|
||||
void mju_printMat(const mjtNum* mat, int nr, int nc) {
|
||||
for (int r=0; r < nr; r++) {
|
||||
@@ -995,7 +976,6 @@ void mju_printMat(const mjtNum* mat, int nr, int nc) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// print sparse matrix to screen
|
||||
void mju_printMatSparse(const mjtNum* mat, int nr,
|
||||
const int* rownnz, const int* rowadr,
|
||||
@@ -1010,7 +990,6 @@ void mju_printMatSparse(const mjtNum* mat, int nr,
|
||||
}
|
||||
|
||||
|
||||
|
||||
// min function, avoid re-evaluation
|
||||
mjtNum mju_min(mjtNum a, mjtNum b) {
|
||||
if (a <= b) {
|
||||
@@ -1021,7 +1000,6 @@ mjtNum mju_min(mjtNum a, mjtNum b) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// max function, avoid re-evaluation
|
||||
mjtNum mju_max(mjtNum a, mjtNum b) {
|
||||
if (a >= b) {
|
||||
@@ -1032,7 +1010,6 @@ mjtNum mju_max(mjtNum a, mjtNum b) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// clip x to the range [min, max]
|
||||
mjtNum mju_clip(mjtNum x, mjtNum min, mjtNum max) {
|
||||
if (x < min) {
|
||||
@@ -1045,7 +1022,6 @@ mjtNum mju_clip(mjtNum x, mjtNum min, mjtNum max) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// sign function
|
||||
mjtNum mju_sign(mjtNum x) {
|
||||
if (x < 0) {
|
||||
@@ -1058,7 +1034,6 @@ mjtNum mju_sign(mjtNum x) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// round to nearest integer
|
||||
int mju_round(mjtNum x) {
|
||||
mjtNum lower = floor(x);
|
||||
@@ -1072,7 +1047,6 @@ int mju_round(mjtNum x) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// convert type id to type name
|
||||
const char* mju_type2Str(int type) {
|
||||
switch ((mjtObj) type) {
|
||||
@@ -1160,7 +1134,6 @@ const char* mju_type2Str(int type) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// convert type id to type name
|
||||
int mju_str2Type(const char* str) {
|
||||
if (!strcmp(str, "body")) {
|
||||
@@ -1269,7 +1242,6 @@ int mju_str2Type(const char* str) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return human readable number of bytes using standard letter suffix
|
||||
const char* mju_writeNumBytes(size_t nbytes) {
|
||||
int i;
|
||||
@@ -1290,7 +1262,6 @@ const char* mju_writeNumBytes(size_t nbytes) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// warning text
|
||||
const char* mju_warningText(int warning, size_t info) {
|
||||
static mjTHREADLOCAL char str[1000];
|
||||
@@ -1341,14 +1312,12 @@ const char* mju_warningText(int warning, size_t info) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return 1 if nan or abs(x)>mjMAXVAL, 0 otherwise
|
||||
int mju_isBad(mjtNum x) {
|
||||
return (x != x || x > mjMAXVAL || x < -mjMAXVAL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return 1 if all elements are 0
|
||||
int mju_isZero(const mjtNum* vec, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
@@ -1361,7 +1330,6 @@ int mju_isZero(const mjtNum* vec, int n) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return 1 if all elements are 0
|
||||
int mju_isZeroByte(const unsigned char* vec, int n) {
|
||||
size_t i = 0;
|
||||
@@ -1387,21 +1355,18 @@ int mju_isZeroByte(const unsigned char* vec, int n) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// set integer vector to 0
|
||||
void mju_zeroInt(int* res, int n) {
|
||||
memset(res, 0, n*sizeof(int));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// copy int vector vec into res
|
||||
void mju_copyInt(int* res, const int* vec, int n) {
|
||||
memcpy(res, vec, n*sizeof(int));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// standard normal random number generator (optional second number)
|
||||
mjtNum mju_standardNormal(mjtNum* num2) {
|
||||
const mjtNum scale = 2.0/((mjtNum)RAND_MAX);
|
||||
@@ -1422,7 +1387,6 @@ mjtNum mju_standardNormal(mjtNum* num2) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// convert from float to mjtNum
|
||||
void mju_f2n(mjtNum* res, const float* vec, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
@@ -1431,7 +1395,6 @@ void mju_f2n(mjtNum* res, const float* vec, int n) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// convert from mjtNum to float
|
||||
void mju_n2f(float* res, const mjtNum* vec, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
@@ -1448,7 +1411,6 @@ void mju_d2n(mjtNum* res, const double* vec, int n) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// convert from mjtNum to double
|
||||
void mju_n2d(double* res, const mjtNum* vec, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
@@ -1457,7 +1419,6 @@ void mju_n2d(double* res, const mjtNum* vec, int n) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// gather
|
||||
void mju_gather(mjtNum* restrict res, const mjtNum* restrict vec, const int* restrict ind, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
@@ -1466,7 +1427,6 @@ void mju_gather(mjtNum* restrict res, const mjtNum* restrict vec, const int* res
|
||||
}
|
||||
|
||||
|
||||
|
||||
// masked gather (set to 0 at negative indices)
|
||||
void mju_gatherMasked(mjtNum* restrict res, const mjtNum* restrict vec,
|
||||
const int* restrict ind, int n) {
|
||||
@@ -1476,7 +1436,6 @@ void mju_gatherMasked(mjtNum* restrict res, const mjtNum* restrict vec,
|
||||
}
|
||||
|
||||
|
||||
|
||||
// scatter
|
||||
void mju_scatter(mjtNum* restrict res, const mjtNum* restrict vec, const int* restrict ind, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
@@ -1485,7 +1444,6 @@ void mju_scatter(mjtNum* restrict res, const mjtNum* restrict vec, const int* re
|
||||
}
|
||||
|
||||
|
||||
|
||||
// gather integers
|
||||
void mju_gatherInt(int* restrict res, const int* restrict vec, const int* restrict ind, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
@@ -1494,7 +1452,6 @@ void mju_gatherInt(int* restrict res, const int* restrict vec, const int* restri
|
||||
}
|
||||
|
||||
|
||||
|
||||
// scatter integers
|
||||
void mju_scatterInt(int* restrict res, const int* restrict vec, const int* restrict ind, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
@@ -1503,7 +1460,6 @@ void mju_scatterInt(int* restrict res, const int* restrict vec, const int* restr
|
||||
}
|
||||
|
||||
|
||||
|
||||
// build gather indices mapping src to res, assumes pattern(res) \subseteq pattern(src)
|
||||
void mju_sparseMap(int* map, int nr,
|
||||
const int* res_rowadr, const int* res_rownnz, const int* res_colind,
|
||||
@@ -1527,7 +1483,6 @@ void mju_sparseMap(int* map, int nr,
|
||||
}
|
||||
|
||||
|
||||
|
||||
// build masked-gather map to copy a lower-triangular src into symmetric res
|
||||
// `cursor` is a preallocated buffer of size `nr`
|
||||
void mju_lower2SymMap(int* map, int nr,
|
||||
@@ -1594,7 +1549,6 @@ void mju_lower2SymMap(int* map, int nr,
|
||||
}
|
||||
|
||||
|
||||
|
||||
// insertion sort, increasing order
|
||||
void mju_insertionSort(mjtNum* list, int n) {
|
||||
for (int i=1; i < n; i++) {
|
||||
@@ -1609,7 +1563,6 @@ void mju_insertionSort(mjtNum* list, int n) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// integer insertion sort, increasing order
|
||||
void mju_insertionSortInt(int* list, int n) {
|
||||
for (int i=1; i < n; i++) {
|
||||
@@ -1624,7 +1577,6 @@ void mju_insertionSortInt(int* list, int n) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Halton sequence
|
||||
mjtNum mju_Halton(int index, int base) {
|
||||
int n0 = index;
|
||||
@@ -1643,7 +1595,6 @@ mjtNum mju_Halton(int index, int base) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Call strncpy, then set dst[n-1] = 0.
|
||||
char* mju_strncpy(char *dst, const char *src, int n) {
|
||||
if (dst && src && n > 0) {
|
||||
@@ -1655,7 +1606,6 @@ char* mju_strncpy(char *dst, const char *src, int n) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// sigmoid function over 0<=x<=1 using quintic polynomial
|
||||
mjtNum mju_sigmoid(mjtNum x) {
|
||||
// fast return
|
||||
|
||||
Reference in New Issue
Block a user