diff --git a/.travis.yml b/.travis.yml index 53630979ef..7b33f08822 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,7 +95,7 @@ before_install: install: - mkdir ~/opensim-core-build && cd ~/opensim-core-build # Configure OpenSim. - - cmake $TRAVIS_BUILD_DIR -DBUILD_JAVA_WRAPPING=$BUILD_WRAPPING -DBUILD_PYTHON_WRAPPING=$BUILD_WRAPPING -DSWIG_EXECUTABLE=$HOME/swig/bin/swig -DSIMBODY_HOME=~/simbody-install -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_INSTALL_PREFIX=$OPENSIM_HOME + - cmake $TRAVIS_BUILD_DIR -DBUILD_JAVA_WRAPPING=$BUILD_WRAPPING -DBUILD_PYTHON_WRAPPING=$BUILD_WRAPPING -DSWIG_EXECUTABLE=$HOME/swig/bin/swig -DSIMBODY_HOME=~/simbody-install -DCMAKE_CXX_FLAGS="-Werror -Wno-error=deprecated-declarations" -DCMAKE_INSTALL_PREFIX=$OPENSIM_HOME # Build OpenSim. # Build java and python C++ wrapper separately to avoid going over the memory limit. - if [[ "$BUILD_WRAPPING" = "on" ]]; then make -j$NPROC osimTools osimJavaJNI PyWrap; fi diff --git a/OpenSim/Simulation/SimbodyEngine/Coordinate.cpp b/OpenSim/Simulation/SimbodyEngine/Coordinate.cpp index 419ca52edd..02753858ad 100644 --- a/OpenSim/Simulation/SimbodyEngine/Coordinate.cpp +++ b/OpenSim/Simulation/SimbodyEngine/Coordinate.cpp @@ -31,6 +31,8 @@ #include #include +#include + //============================================================================= // STATICS //============================================================================= @@ -170,8 +172,6 @@ void Coordinate::extendFinalizeFromProperties() cerr << "Default value = " << dv << " > max = " << get_range(1) << endl; } } - // Define the locked value for the constraint as a function - _lockFunction = new ModifiableConstant(get_default_value(), 1); _lockedWarningGiven=false; @@ -182,17 +182,27 @@ void Coordinate::extendAddToSystem(SimTK::MultibodySystem& system) const { Super::extendAddToSystem(system); - //create lock constraint automatically + // Make this modifiable temporarily so we can record information needed + // to later access our pieces of the SimTK::MultibodySystem. That info is + // const after the system has been built. + Coordinate* mutableThis = const_cast(this); + + // Define the locked value for the constraint as a function. + // The PrescribedMotion will take ownership, but we'll keep a reference + // pointer here to allow for later modification. + std::unique_ptr + funcOwner(new ModifiableConstant(get_default_value(), 1)); + mutableThis->_lockFunction = funcOwner.get(); + // The underlying SimTK constraint - SimTK::Constraint::PrescribedMotion lock(system.updMatterSubsystem(), - _lockFunction.get(), - _bodyIndex, - SimTK::MobilizerQIndex(_mobilizerQIndex)); + SimTK::Constraint::PrescribedMotion + lock(system.updMatterSubsystem(), + funcOwner.release(), // give up ownership + _bodyIndex, + SimTK::MobilizerQIndex(_mobilizerQIndex)); - // Beyond the const Component get the index so we can access the SimTK::Constraint later - Coordinate* mutableThis = const_cast(this); + // Save the index so we can access the SimTK::Constraint later mutableThis->_lockedConstraintIndex = lock.getConstraintIndex(); - //mutableThis->_model->addModelComponent(mutableThis); if(!getProperty_prescribed_function().empty()){ //create prescribed motion constraint automatically diff --git a/OpenSim/Simulation/SimbodyEngine/Coordinate.h b/OpenSim/Simulation/SimbodyEngine/Coordinate.h index 40f2052d8a..27bf9a0564 100644 --- a/OpenSim/Simulation/SimbodyEngine/Coordinate.h +++ b/OpenSim/Simulation/SimbodyEngine/Coordinate.h @@ -292,9 +292,13 @@ OpenSim_DECLARE_CONCRETE_OBJECT(Coordinate, ModelComponent); /* MobilizedBodyIndex of the body which this coordinate serves. */ SimTK::MobilizedBodyIndex _bodyIndex; - /* Mobilizer Q (i.e. genearlized coordinate) index for this Coordinate. */ + /* Mobilizer Q (i.e. generalized coordinate) index for this Coordinate. */ SimTK::MobilizerQIndex _mobilizerQIndex; + /* Keep a reference to the SimTK function owned by the PrescribedMotion + Constraint, so we can change the value at which to lock the joint. */ + SimTK::ReferencePtr _lockFunction; + /* Motion type (translational, rotational or combination). */ MotionType _motionType; @@ -305,9 +309,6 @@ OpenSim_DECLARE_CONCRETE_OBJECT(Coordinate, ModelComponent); /* The OpenSim::Joint that owns this coordinate. */ SimTK::ReferencePtr _joint; - /* SimTK function used to lock the joint at a fixed value */ - mutable SimTK::ReferencePtr _lockFunction; - mutable bool _lockedWarningGiven; // PRIVATE METHODS implementing the Component interface diff --git a/appveyor.yml b/appveyor.yml index 58eaa8a4fb..6157ae6261 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,6 +13,8 @@ # "/EHsc" is to "unwind semantics" to get error messages when using "/WX" (C4530). # However, this was causing some weird behavior. Not treating warnings # as errors for now. +# +### TEMPORARILY DISABLING WRAPPING (see lines with ###) shallow_clone: true @@ -31,10 +33,10 @@ nuget: install: ## Use Chocolatey to install SWIG. - - choco -y install swig + ###- choco -y install swig ## Install python-nose for python testing. - - pip install nose + ###- pip install nose ## Simbody. # Simbody's installation is pushed to our Appveyor NuGet account feed. @@ -51,7 +53,8 @@ build_script: - mkdir build - cd build # Configure. - - cmake .. -G"Visual Studio 12 2013 Win64" -DSIMBODY_HOME=C:\simbody -DCMAKE_INSTALL_PREFIX=%OPENSIM_HOME% -DBUILD_JAVA_WRAPPING=ON -DBUILD_PYTHON_WRAPPING=ON # TODO -DBUILD_SIMM_TRANSLATOR=ON + ###- cmake .. -G"Visual Studio 12 2013 Win64" -DSIMBODY_HOME=C:\simbody -DCMAKE_INSTALL_PREFIX=%OPENSIM_HOME% -DBUILD_JAVA_WRAPPING=ON -DBUILD_PYTHON_WRAPPING=ON # TODO -DBUILD_SIMM_TRANSLATOR=ON + - cmake .. -G"Visual Studio 12 2013 Win64" -DSIMBODY_HOME=C:\simbody -DCMAKE_INSTALL_PREFIX=%OPENSIM_HOME% -DBUILD_JAVA_WRAPPING=OFF -DBUILD_PYTHON_WRAPPING=OFF # Build. - cmake --build . --target ALL_BUILD --config Release -- /maxcpucount:4 /verbosity:quiet @@ -75,10 +78,10 @@ test_script: - copy Applications\CMC\test\gait10dof18musc_subject01.osim %OPENSIM_HOME%\Models\Gait10dof18musc\gait10dof18musc.osim # Move to the installed location of the python package. - - cd %OPENSIM_HOME%\sdk\python + ###- cd %OPENSIM_HOME%\sdk\python # Run python tests. - - nosetests -v + ###- nosetests -v after_test: - ## On master branch, create NuGet package for OpenSim.