Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid tweaking tangent points of WrapCylinder when single object wrap… #3125

Merged
merged 50 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3fef842
minor refactor to reduce num calls to get size of Array property
aymanhab Nov 30, 2021
3c4656a
Avoid duplicate transformation to Ground frame when computing path le…
aymanhab Dec 7, 2021
2953a68
remove_unused_variable
aymanhab Dec 7, 2021
9732b16
Remove macros that are replaceable by Vec3 operators
aymanhab Dec 7, 2021
f1e5db6
Merge branch 'wrap_performance' of https://github.com/opensim-org/ope…
aymanhab Dec 7, 2021
686f7eb
Inline usage of Macro in WrapEllipsoid
aymanhab Dec 8, 2021
3de0a01
More refactoring, use det for determinant, vec operators instead of l…
aymanhab Dec 10, 2021
eb93bf7
Update continuous_integration.yml
aymanhab Dec 10, 2021
051d80e
Remove rather than comment out function that was moved to header and …
aymanhab Dec 10, 2021
c958640
Merge branch 'wrap_performance' of https://github.com/opensim-org/ope…
aymanhab Dec 10, 2021
f2806d5
Update GeometryPath.cpp
aymanhab Dec 13, 2021
d6df20a
Update continuous_integration.yml
aymanhab Dec 13, 2021
72eaef6
Use normSqr for consistency
aymanhab Dec 13, 2021
d3d3fd1
Merge branch 'wrap_performance' of https://github.com/opensim-org/ope…
aymanhab Dec 13, 2021
3101d7c
Use UnitVec3 instead of Vec3 for plane normal
aymanhab Dec 16, 2021
17fd7d1
Avoid tweaking tangent points of WrapCylinder when single object wrap…
aymanhab Jan 17, 2022
40c48be
Add MocoAngularVelocityTrackingGoal to bindings; add option for quate…
nickbianco Nov 18, 2021
1b3d46e
Complete fixes for setRotationReference(); update changelog
nickbianco Nov 18, 2021
fe4a8c7
fix load issue with scale tool (#3110)
carmichaelong Nov 30, 2021
2a7ff61
Add extendPostScale() to DeGrooteFregly2016Muscle (#3108)
nickbianco Dec 6, 2021
949e0e4
Update continuous_integration.yml (#3115)
aymanhab Dec 17, 2021
041ace9
Fix inline assemble in catch.hpp dependency for ARM Macs (#3118)
keenon Dec 21, 2021
cfda915
Avoid tweaking tangent points of WrapCylinder when single object wrap…
aymanhab Jan 17, 2022
2e6a33f
Merge branch 'wrap_min_wrap_pts' of https://github.com/opensim-org/op…
aymanhab Jan 18, 2022
d4ccfff
disableVisualization when creating MocoProblem for Model
aymanhab Jan 18, 2022
348057a
Avoid messages about missing files if visualization is off.
aymanhab Jan 20, 2022
8963d69
fix comments per PR review
aymanhab Jan 20, 2022
4e1e06a
Disable visualization for all internal models used by MccoProblem
aymanhab Jan 20, 2022
51b8f37
Fix typo/mistake in variable name
aymanhab Jan 20, 2022
a8bd62a
Couple other places to disable visualization for models internal to M…
aymanhab Jan 20, 2022
620cc83
improve comments per feedback on PR
aymanhab Jan 24, 2022
a7a67b3
Use finer grain includes per PR review
aymanhab Jan 25, 2022
4979556
Retire Mtx::CrossProduct wrapper method for Vec3 operator
aymanhab Jan 25, 2022
75323a2
Remove now unused methods for CrossProduct, Interpolation, Translatio…
aymanhab Jan 25, 2022
2bb8e58
Fix case for pathname of UnitVec.h
aymanhab Jan 25, 2022
e8b18b1
Use norm for Mtx::Magnitude
aymanhab Jan 25, 2022
b215d1c
Remove redundant call to disableVisualization
aymanhab Jan 25, 2022
64d89c4
Remove Mtx::Angle and inline references to it.
aymanhab Jan 25, 2022
fa4daa8
Replace Mtx::Normalize with Vec3.normalize
aymanhab Jan 26, 2022
ba9bef3
Update standard input for testMocoInverse
aymanhab Jan 26, 2022
130c740
Minor rearrangement per feedback on PR
aymanhab Jan 26, 2022
d14c8d0
Eliminate Mtx class, move remaining 2 functions to WrapMath
aymanhab Jan 27, 2022
6c0a90c
Inline replace DotProduct with operator, and remove from WrapMath.h, …
aymanhab Jan 27, 2022
f0d1d80
Rename Normalize to NormalizeOrZero
aymanhab Jan 28, 2022
7202922
Update WrapMath.h
aymanhab Jan 31, 2022
5457816
Remove unused methods in WrapMath class, for consistency restore all …
aymanhab Feb 1, 2022
7ccdcae
Remove unused methods in WrapMath class, for consistency restore all …
aymanhab Feb 1, 2022
5a74771
Merge branch 'wrap_min_wrap_pts' of https://github.com/opensim-org/op…
aymanhab Feb 2, 2022
6bb9844
Update std again based on latest wrapping code update
aymanhab Feb 2, 2022
d424203
Update ModelProcessor.h
aymanhab Feb 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Applications/Forward/test/testForward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void testArm26() {
for (int j = 0; j < state->getSize(); ++j) {
stringstream message;
message << "t=" << time <<" state# "<< j << " " << standard->getColumnLabels()[j+1] << " std=" << data[j] <<" computed=" << state->getData()[j] << endl;
ASSERT_EQUAL(data[j], state->getData()[j], 1.0e-3,
ASSERT_EQUAL(data[j], state->getData()[j], 5.0e-3,
__FILE__, __LINE__, "ASSERT_EQUAL FAILED " + message.str());
cout << "ASSERT_EQUAL PASSED " << message.str();
}
Expand All @@ -173,7 +173,7 @@ void testArm26() {
for (int j = 0; j < state->getSize(); ++j) {
stringstream message;
message << "t=" << time <<" state# "<< j << " " << standard->getColumnLabels()[j+1] << " std=" << data[j] <<" computed=" << state->getData()[j] << endl;
ASSERT_EQUAL(data[j], state->getData()[j], 1.0e-3,
ASSERT_EQUAL(data[j], state->getData()[j], 5.0e-3,
__FILE__, __LINE__, "ASSERT_EQUAL FAILED " + message.str());
cout << "ASSERT_EQUAL PASSED " << message.str();
}
Expand Down
1 change: 1 addition & 0 deletions OpenSim/Actuators/ModelProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class OSIMACTUATORS_API ModelProcessor : public Object {
}
Model modelFromFile(path);
model = std::move(modelFromFile);
model.updDisplayHints().disableVisualization();
model.finalizeFromProperties();
model.finalizeConnections();
}
Expand Down
10 changes: 8 additions & 2 deletions OpenSim/Common/ModelDisplayHints.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ class OSIMCOMMON_API ModelDisplayHints : public Object {
/** Default construction creates a valid display hints object with all
hints set to their default values. **/
ModelDisplayHints() { constructProperties(); }


/** Turn off visualization completely, only use for API/modeling.
Meshes will not be loaded, path-wrapping intermediate points will
not be computed, MomentArm computations are not affected however.
Intentionally there's no reverse API to turn on visualization downstream.
**/
void disableVisualization() { _visualization = false; }
bool isVisualizationEnabled() const { return _visualization; }
private:
void constructProperties() {
constructProperty_show_wrap_geometry(true);
Expand All @@ -120,6 +125,7 @@ class OSIMCOMMON_API ModelDisplayHints : public Object {
constructProperty_show_forces(true);
constructProperty_show_debug_geometry(false);
}
bool _visualization{true};
};


Expand Down
209 changes: 0 additions & 209 deletions OpenSim/Common/Mtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,191 +48,6 @@ static const double eps = std::numeric_limits<double>::epsilon();
//=============================================================================
// CONSTRUCTOR(S) AND DESTRUCTOR
//=============================================================================

//-----------------------------------------------------------------------------
// INTERPOLATION
//-----------------------------------------------------------------------------
//_____________________________________________________________________________
/**
* Linearly interpolate or extrapolate an array of data.
*/
void Mtx::
Interpolate(int aN,double aT1,double *aY1,double aT2,double *aY2,
double aT,double *aY)
{
// DETERMINE PERCENT OF INTERVAL
int i;
double pct;
double num = aT-aT1;
double den = aT2-aT1;
if(den==0.0) {
pct = 0.0;
} else {
pct = num/den;
}

// LOOP OVER ARRAY
for(i=0;i<aN;i++) {
if(pct==0.0) {
aY[i] = aY1[i];
} else {
aY[i] = aY1[i] + pct*(aY2[i]-aY1[i]);
}
}
}
//_____________________________________________________________________________
/**
* Linearly interpolate or extrapolate two data points.
*/
double Mtx::
Interpolate(double aT1,double aY1,double aT2,double aY2,double aT)
{
// DETERMINE PERCENT OF INTERVAL
double pct;
double num = aT-aT1;
double den = aT2-aT1;
if(den==0.0) {
pct = 0.0;
} else {
pct = num/den;
}

// INTERP
double y;
if(pct==0.0) {
y = aY1;
} else {
y = aY1 + pct*(aY2-aY1);
}
return(y);
}


//=============================================================================
// TRANSLATION AND ROTATION
//=============================================================================
//-----------------------------------------------------------------------------
// TRANSLATION
//-----------------------------------------------------------------------------
//_____________________________________________________________________________
/**
* Translate a point by a specified amount.
*
* @param aX Amount to translate in the X direction.
* @param aY Amount to translate in the Y direction.
* @param aZ Amount to translate in the Z direction.
* @param aP Point to translate.
* @param rP Translated point. aP and rP may coincide in memory.
*/
void Mtx::
Translate(double aX,double aY,double aZ,const double aP[3],double rP[3])
{
rP[0] = aP[0] + aX;
rP[1] = aP[1] + aY;
rP[2] = aP[2] + aZ;
}

//-----------------------------------------------------------------------------
// ROTATE BY RADIANS
//-----------------------------------------------------------------------------
//_____________________________________________________________________________
/**
* Rotate a point about the X, Y, or Z axis by a specified amount.
*
* @param aXYZ Specify whether to rotate about the X (aXYZ=0), Y (aXYZ=1),
* or Z (aXYZ=2) axes. If aXYZ is not 0, 1, or 2, no rotation is performed.
* @param aRadians Amount of rotation in radians.
* @param aP Point to rotate.
* @param rP Rotated point. aP and rP may coincide in memory.
*/
void Mtx::
Rotate(int aXYZ,double aRadians,const double aP[3],double rP[3])
{
if(aP==NULL) return;
if(rP==NULL) return;

// COPY
double p0 = aP[0];
double p1 = aP[1];
double p2 = aP[2];

// COMPUTE SIN AND COS
double c = cos(aRadians);
double s = sin(aRadians);

// X
if(aXYZ==0) {
rP[0] = p0;
rP[1] = c*p1 - s*p2;
rP[2] = s*p1 + c*p2;

// Y
} else if(aXYZ==1) {
rP[0] = c*p0 + s*p2;
rP[1] = p1;
rP[2] = -s*p0 + c*p2;

// Z
} else if(aXYZ==2) {
rP[0] = c*p0 - s*p1;
rP[1] = s*p0 + c*p1;
rP[2] = p2;
}
}
//_____________________________________________________________________________
/**
* Rotate a point about a specified axis by a specified amount.
*
* @param aAxis Axis about which to rotate. The axis is not assumed to be
* a unit vector; however, if the axis is the zero vector, no rotation
* is performed.
* @param aRadians Amount of rotation in radians.
* @param aP Point to rotate.
* @param rP Rotated point. aP and rP may coincide in memory.
*/
void Mtx::
Rotate(const double aAxis[3],double aRadians,const double aP[3],double rP[3])
{
if(aAxis==0) return;
if(aP==NULL) return;
if(rP==NULL) return;

}

//-----------------------------------------------------------------------------
// ROTATE BY DEGREES
//-----------------------------------------------------------------------------
//_____________________________________________________________________________
/**
* Rotate a point about the X axis by a specified amount.
*
* @param aXYZ Specify whether to rotate about the X (aXYZ=0), Y (aXYZ=1),
* or Z (aXYZ=2) axis. If aXYZ is not 0, 1, or 2, no rotation is performed.
* @param aDegrees Amount of rotation in degrees.
* @param aP Point to rotate.
* @param rP Rotated point. aP and rP may coincide in memory.
*/
void Mtx::
RotateDeg(int aXYZ,double aDegrees,const double aP[3],double rP[3])
{
Rotate(aXYZ,SimTK_DEGREE_TO_RADIAN*aDegrees,aP,rP);
}
//_____________________________________________________________________________
/**
* Rotate a point about a specified axis by a specified amount.
*
* @param aAxis Axis about which to rotate.
* @param aDegrees Amount of rotation in degrees.
* @param aP Point to rotate.
* @param rP Rotated point. aP and rP may coincide in memory.
*/
void Mtx::
RotateDeg(const double aAxis[3],double aDegrees,const double aP[3],double rP[3])
{
Rotate(aAxis,SimTK_DEGREE_TO_RADIAN*aDegrees,aP,rP);
}


//=============================================================================
// MATRIX ARITHMETIC
//=============================================================================
Expand Down Expand Up @@ -267,30 +82,6 @@ Identity(int aN,double *rI)
return(0);
}
//_____________________________________________________________________________
/**
* Add two matrices.
*
* If the arguments are not valid, then a -1 is returned.
* Otherwise, 0 is returned.
*
* It is permissible for aM to coincide with either aM1 or aM2.
*/
int Mtx::
Add(int aNR,int aNC,const double *aM1,const double *aM2,double *aM)
{
if(aM1==NULL) return(-1);
if(aM2==NULL) return(-1);
if(aM ==NULL) return(-1);
if(aNR<=0) return(-1);
if(aNC<=0) return(-1);

// MULTIPLY
int i,n=aNR*aNC;
for(i=0;i<n;i++,aM1++,aM2++,aM++) *aM = *aM1 + *aM2;

return(0);
}
//_____________________________________________________________________________
/**
* Subtract two matrices.
*
Expand Down
73 changes: 0 additions & 73 deletions OpenSim/Common/Mtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,11 @@ class OSIMCOMMON_API Mtx
public:
//--------------------------------------------------------------------------
// CONSTRUCTION
//--------------------------------------------------------------------------
//Mtx();
//virtual ~Mtx();

//--------------------------------------------------------------------------
// VECTOR
//--------------------------------------------------------------------------
//_____________________________________________________________________________
/**
* Find the angle between two vectors: theta = acos( aV1*aV2/(|aV1|*|aV2|)).
*
* @param aV1 Vector 1.
* @param aV2 Vector 2.
* @return Angle between two vectors in radians.
*/
inline static double Angle(const SimTK::Vec3& aV1, const SimTK::Vec3& aV2){
SimTK::Vec3 v1(aV1); v1.normalize();
SimTK::Vec3 v2(aV2); v2.normalize();
return (acos( ~v1 * v2));
}
//_____________________________________________________________________________
/**
* Normalize a vector.
Expand All @@ -101,16 +86,6 @@ class OSIMCOMMON_API Mtx
rV.setToZero();
return mag;
}
/**
* Compute the magnitude of a vector.
*
* @param aN Obsolete -- always pass as a "3".
* @param aV Vector.
* @returns Square root of the dot product aV*aV.
*/
inline static double Magnitude(int aN,const SimTK::Vec3& aV){
return aV.norm();
}
//_____________________________________________________________________________
/**
* Compute the dot product of two vectors.
Expand All @@ -121,59 +96,11 @@ class OSIMCOMMON_API Mtx
inline static double DotProduct(int aN,const SimTK::Vec3& aV1,const SimTK::Vec3& aV2){
return ~aV1 * aV2;
}
//_____________________________________________________________________________
/**
* Compute the cross product of two vectors.
*
* If the arguments are not valid (aR=aS=NULL), -1 is returned.
*/
inline static void CrossProduct(const SimTK::Vec3& aV1, const SimTK::Vec3& aV2, SimTK::Vec3& aV){
aV = aV1 % aV2;
};
/**
* Get a unit vector that is perpendicular to a specified vector. The unit
* vector is arbitrary, in the sense that it is one of an infinite number of
* vectors that are perpendicular to the original specified vector.
*
* @param aV Input vector.
* @param rV Perpendicular unit vector.
*/
static void PerpendicularUnitVector(const SimTK::Vec3& aV, SimTK::Vec3& rV)
{
SimTK::UnitVec3 unit(aV);
rV = unit.perp().asVec3();
}
static void
Interpolate(int aN,double aT1,double *aY1,double aT2,double *aY2,
double t,double *aY);
static double
Interpolate(double aT1,double aY1,double aT2,double aY2,
double t);

//--------------------------------------------------------------------------
// TRANSLATION AND ROTATION
//--------------------------------------------------------------------------
static void
Translate(double aX,double aY,double aZ,const double aP[3],double rP[3]);
static void
Rotate(int aXYZ,double aRadians,const double aP[3],double rP[3]);
static void
Rotate(const double aAxis[3],double aRadians,const double aP[3],
double rP[3]);
static void
RotateDeg(int aXYZ,double aDegrees,const double aP[3],double rP[3]);
static void
RotateDeg(const double aAxis[3],double aDegrees,const double aP[3],
double rP[3]);

//--------------------------------------------------------------------------
// MATRIX
//--------------------------------------------------------------------------
static int Identity(int aNR,double *rI);
//static int Assign(int aNR,int aNC,double aScalar,double *rM);
//static int Assign(int aNR,int aNC,const double *aM,double *rM);
//static int Add(int aNR,int aNC,const double *aM1,double aScalar,double *aM);
static int Add(int aNR,int aNC,const double *aM1,const double *aM2,double *aM);
static int Subtract(int aNR,int aNC,const double *aM1,const double *aM2,
double *aM);
static int Multiply(int aNR,int aNC,const double *aM,double aScalar,double *rM);
Expand Down
2 changes: 2 additions & 0 deletions OpenSim/Moco/MocoProblemRep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ void MocoProblemRep::initialize() {

// Clear member variables.
m_model_base = Model();
m_model_base.updDisplayHints().disableVisualization();
m_state_base.clear();
m_position_motion_base.reset();
m_model_disabled_constraints = Model();
m_model_disabled_constraints.updDisplayHints().disableVisualization();
m_position_motion_disabled_constraints.reset();
m_constraint_forces.reset();
m_acceleration_motion.reset();
Expand Down
Loading