├── contrib ├── tclap-1.2.1 │ ├── include │ │ ├── Makefile.am │ │ └── tclap │ │ │ └── Makefile.am │ ├── config │ │ ├── Makefile.am │ │ ├── ac_cxx_have_long_long.m4 │ │ ├── bb_enable_doxygen.m4 │ │ ├── ac_cxx_namespaces.m4 │ │ ├── ac_cxx_have_sstream.m4 │ │ ├── mkinstalldirs │ │ ├── ac_cxx_have_strstream.m4 │ │ └── ac_cxx_warn_effective_cxx.m4 │ ├── tclap.pc.in │ ├── msc │ │ ├── Makefile.am │ │ ├── examples │ │ │ └── Makefile.am │ │ └── README │ ├── AUTHORS │ ├── Makefile.am │ ├── README │ ├── configure.in │ └── COPYING └── lua-5.3.5 │ ├── doc │ ├── logo.gif │ ├── osi-certified-72x60.png │ ├── index.css │ └── manual.css │ ├── README │ ├── src │ ├── lua.hpp │ ├── lapi.h │ ├── lundump.h │ └── lprefix.h │ └── CMakeLists.txt ├── tools ├── .updateversion.bat ├── .updateversion.sh ├── unix_2b_build-simbody ├── mac_e2e_build ├── unix_2_build ├── mac_4_create-dmg ├── unix_2c_build-opensim3 ├── unix_2d_build-scone ├── mac_1_get-dependencies └── linux_4_package ├── src ├── sconestudio │ ├── studio.rc │ ├── studio.ico │ ├── scone_icon.ico │ ├── scone_icon.png │ ├── scone_icon_glow.ico │ ├── scone_icon_no_text.ico │ ├── SconeStudio.qrc │ ├── model_conversion.h │ ├── help_tools.h │ ├── SettingsEditor.h │ ├── resource.h │ ├── studio_config.h │ ├── GaitAnalysis.h │ ├── OptimizerTaskExternal.h │ ├── OptimizerTask.cpp │ ├── OptimizerTaskThreaded.h │ ├── ParTableModel.h │ ├── StudioSettings.h │ ├── OptimizerTask.h │ ├── file_tools.h │ ├── help_tools.cpp │ ├── ResultsFileSystemModel.h │ ├── GaitPlot.h │ └── SconeStorageDataModel.h ├── sconelib │ ├── sconelua │ │ ├── sol_config.h │ │ ├── sconelua.h │ │ ├── platform.h │ │ ├── sconelua.cpp │ │ └── lua_script.h │ ├── sconeopensim3 │ │ ├── sconeopensim3.h │ │ ├── platform.h │ │ ├── sconeopensim3.cpp │ │ ├── simbody_tools.h │ │ └── JointOpenSim3.h │ ├── scone │ │ ├── model │ │ │ ├── ModelFeatures.h │ │ │ ├── ForceValue.h │ │ │ ├── memory_tools.h │ │ │ ├── muscle_tools.h │ │ │ ├── Sensor.h │ │ │ ├── DisplayGeometry.h │ │ │ ├── Dof.cpp │ │ │ ├── model_tools.h │ │ │ ├── Simulation.cpp │ │ │ ├── Location.cpp │ │ │ ├── Actuator.cpp │ │ │ ├── MuscleId.h │ │ │ ├── Simulation.h │ │ │ ├── SensorDelayAdapter.h │ │ │ ├── ContactForce.cpp │ │ │ ├── ContactForce.h │ │ │ ├── ContactGeometry.h │ │ │ ├── deprecated │ │ │ │ └── Link.cpp │ │ │ ├── Actuator.h │ │ │ ├── State.cpp │ │ │ └── Joint.h │ │ ├── core │ │ │ ├── CachedVar.h │ │ │ ├── Propertyable.cpp │ │ │ ├── doxygen.h │ │ │ ├── storage_tools.h │ │ │ ├── version.h │ │ │ ├── PropNode.h │ │ │ ├── Quat.h │ │ │ ├── FactoryProps.h │ │ │ ├── Vec3.h │ │ │ ├── Angle.h │ │ │ ├── Settings.h │ │ │ ├── Benchmark.h │ │ │ ├── Event.h │ │ │ ├── Function.h │ │ │ ├── TimedValue.h │ │ │ ├── HasExternalResources.cpp │ │ │ ├── SineWave.cpp │ │ │ ├── HasExternalResources.h │ │ │ ├── system_tools.h │ │ │ ├── string_tools.h │ │ │ ├── Result.h │ │ │ ├── GaitCycle.h │ │ │ ├── SineWave.h │ │ │ ├── platform.h │ │ │ ├── RaisedCosine.cpp │ │ │ ├── profiler_config.h │ │ │ ├── HasData.h │ │ │ ├── RaisedCosine.h │ │ │ ├── HasSignature.h │ │ │ ├── version.cpp │ │ │ ├── memory_tools.h │ │ │ ├── ResourceCache.h │ │ │ ├── PieceWiseConstantFunction.h │ │ │ ├── PieceWiseLinearFunction.h │ │ │ └── Polynomial.h │ │ ├── controllers │ │ │ ├── deprecated │ │ │ │ ├── MetaReflexPose.cpp │ │ │ │ ├── MetaReflexPose.h │ │ │ │ ├── MetaReflexParams.h │ │ │ │ ├── SimpleMuscleReflex.h │ │ │ │ ├── MetaReflexController.h │ │ │ │ ├── TimeStateController.h │ │ │ │ ├── MetaReflexParams.cpp │ │ │ │ └── MetaReflexVirtualMuscle.h │ │ │ ├── MotorNeuron.h │ │ │ ├── InterNeuron.h │ │ │ ├── activation_functions.h │ │ │ ├── PatternNeuron.h │ │ │ ├── SensorNeuron.h │ │ │ ├── MotorNeuron.cpp │ │ │ ├── MirrorController.h │ │ │ ├── ConditionalMuscleReflex.h │ │ │ ├── NoiseController.cpp │ │ │ ├── CompositeController.h │ │ │ ├── Controller.cpp │ │ │ └── NoiseController.h │ │ ├── optimization │ │ │ ├── deprecated │ │ │ │ ├── CmaOptimizerCCMAES.h │ │ │ │ ├── CmaOptimizerShark3.h │ │ │ │ └── CmaOptimizerShark2.h │ │ │ ├── Params.h │ │ │ ├── Objective.cpp │ │ │ ├── TestObjective.h │ │ │ ├── opt_tools.h │ │ │ ├── CMakeLists.txt │ │ │ ├── SimulationObjective.cpp │ │ │ ├── SimilarityObjective.h │ │ │ ├── TestObjective.cpp │ │ │ ├── CmaOptimizer.cpp │ │ │ └── Objective.h │ │ └── measures │ │ │ ├── BalanceMeasure.h │ │ │ ├── ReactionForceMeasure.h │ │ │ ├── GaitCycleMeasure.h │ │ │ ├── BalanceMeasure.cpp │ │ │ ├── deprecated │ │ │ └── PointMeasure.h │ │ │ └── JointLoadMeasure.h │ ├── sconeopensim4 │ │ ├── deprecated │ │ │ ├── sconeopensim4.h │ │ │ ├── sconeopensim4.cpp │ │ │ ├── platform.h │ │ │ ├── SimulationOpenSim4.h │ │ │ ├── simbody_tools.h │ │ │ ├── SimulationOpenSim4.cpp │ │ │ └── JointOpenSim4.h │ │ ├── sconeopensim4.h │ │ ├── sconeopensim4.cpp │ │ ├── platform.h │ │ ├── simbody_tools.h │ │ └── JointOpenSim4.h │ └── CMakeLists.txt ├── sconeunittests │ ├── scenario_test.h │ ├── main.cpp │ └── optimization_test.cpp ├── sconelib.licenseheader ├── test │ ├── CMakeLists.txt │ ├── Test.h │ ├── ExampleObjective.h │ └── main.cpp └── sconecmd │ └── CMakeLists.txt ├── paper └── scone_window.png ├── resources ├── ui │ ├── tile1.png │ ├── tile2.png │ ├── tile3.png │ ├── stile128.png │ ├── stile160.png │ ├── stile192.png │ ├── stile255.png │ ├── scone_hud.png │ ├── scone_icon.ico │ ├── scone_logo.png │ ├── scone_splash.png │ ├── scone_logo_notext.png │ └── scone_logo_256x256.icns ├── unittestdata │ └── optimization_test │ │ └── schwefel_5.xml └── filetemplates │ ├── controllerscript.lua │ └── measurescript.lua ├── doc └── generate.bat ├── scenarios ├── Examples │ ├── data │ │ ├── HfdConfigG2020Planar.zml │ │ ├── HfdConfigM2012Planar.zml │ │ ├── HfdConfigTJ2003Planar.zml │ │ ├── HfdConfigGH2010Planar.zml │ │ ├── InitStateJump.zml │ │ ├── HfdConfigGH2010Planar.scone │ │ ├── InitStateGait10.zml │ │ ├── MeasureGait10.scone │ │ ├── MeasureGait10Grf.scone │ │ └── MeasureGait10Grf15.scone │ ├── Gait - H0914 - OpenSim3.scone │ ├── Gait - H0918 - OpenSim3.scone │ ├── Gait - H0914 - OpenSim4.scone │ ├── Gait - H0918 - OpenSim4.scone │ ├── Gait - H0914 - Hyfydy.scone │ ├── Gait - H0918 - Hyfydy.scone │ ├── Standing High Jump - OpenSim3.scone │ ├── Standing High Jump - OpenSim4.scone │ └── Standing High Jump - Hyfydy.scone ├── Tutorials │ ├── data │ │ ├── MeasureBalance.scone │ │ ├── MeasureGait05.scone │ │ ├── MeasureGait10.scone │ │ ├── MeasureGait15.scone │ │ ├── MeasureGait20.scone │ │ ├── ScriptControllerJump.lua │ │ └── ResultStandingHighJumpFC2.par │ ├── Tutorial 3a - Standing Balance.scone │ ├── Tutorial 4a - Gait.scone │ ├── Tutorial 4b - Gait at Different Speeds.scone │ ├── Tutorial 4d - Walking on Ice.scone │ ├── Tutorial 1 - Introduction.scone │ ├── Tutorial 6a - Script - High Jump.scone │ ├── Tutorial 2a - Standing High Jump.scone │ ├── Tutorial 3b - Standing Balance - Motor Noise.scone │ ├── Tutorial 2b - Standing High Jump - Polynomial.scone │ ├── Tutorial 5b - Pathological Gait - Short Hamstrings.scone │ ├── Tutorial 5c - Pathological Gait - Hyper-reflexia.scone │ ├── Tutorial 5a - Pathological Gait - Weak Plantarflexors.scone │ ├── Tutorial 6b - Script - Balance Device.scone │ ├── Tutorial 2c - Standing High Jump - Straight Pose.scone │ └── Tutorial 2d - Standing High Jump - Knees Up.scone └── UnitTests │ └── OpenSim3 │ ├── Gait - Slope.scone │ ├── Gait - Fixed Knee Model.scone │ ├── Jump - Imitation.scone │ ├── data │ ├── ScriptGeomTest.lua │ ├── MeasureGait05.scone │ ├── MeasureGait10.scone │ ├── Jump - Custom Parameters.par │ ├── f0914m.FC2.HighJump.D2.par │ └── neural_delays_FEA.pn │ ├── Jump - CustomParameters.scone │ ├── Jump - SequentialController.scone │ └── Jump - Model Properties.scone ├── .gitignore ├── .gitmodules ├── CMakeModules ├── FindSpot.cmake ├── FindXo.cmake └── PrecompiledHeaders.cmake ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── README.md └── .clang-format /contrib/tclap-1.2.1/include/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = tclap 2 | -------------------------------------------------------------------------------- /tools/.updateversion.bat: -------------------------------------------------------------------------------- 1 | git rev-list --count HEAD > "%~dp0\..\.version" -------------------------------------------------------------------------------- /tools/.updateversion.sh: -------------------------------------------------------------------------------- 1 | git rev-list --count HEAD > "../.version" 2 | -------------------------------------------------------------------------------- /src/sconestudio/studio.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "scone_icon.ico" 2 | 3 | -------------------------------------------------------------------------------- /paper/scone_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/paper/scone_window.png -------------------------------------------------------------------------------- /resources/ui/tile1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/tile1.png -------------------------------------------------------------------------------- /resources/ui/tile2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/tile2.png -------------------------------------------------------------------------------- /resources/ui/tile3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/tile3.png -------------------------------------------------------------------------------- /resources/ui/stile128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/stile128.png -------------------------------------------------------------------------------- /resources/ui/stile160.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/stile160.png -------------------------------------------------------------------------------- /resources/ui/stile192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/stile192.png -------------------------------------------------------------------------------- /resources/ui/stile255.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/stile255.png -------------------------------------------------------------------------------- /resources/ui/scone_hud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/scone_hud.png -------------------------------------------------------------------------------- /resources/ui/scone_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/scone_icon.ico -------------------------------------------------------------------------------- /resources/ui/scone_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/scone_logo.png -------------------------------------------------------------------------------- /src/sconestudio/studio.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/src/sconestudio/studio.ico -------------------------------------------------------------------------------- /contrib/lua-5.3.5/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/contrib/lua-5.3.5/doc/logo.gif -------------------------------------------------------------------------------- /resources/ui/scone_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/scone_splash.png -------------------------------------------------------------------------------- /src/sconestudio/scone_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/src/sconestudio/scone_icon.ico -------------------------------------------------------------------------------- /src/sconestudio/scone_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/src/sconestudio/scone_icon.png -------------------------------------------------------------------------------- /resources/ui/scone_logo_notext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/scone_logo_notext.png -------------------------------------------------------------------------------- /src/sconestudio/scone_icon_glow.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/src/sconestudio/scone_icon_glow.ico -------------------------------------------------------------------------------- /resources/ui/scone_logo_256x256.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/resources/ui/scone_logo_256x256.icns -------------------------------------------------------------------------------- /src/sconestudio/scone_icon_no_text.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/src/sconestudio/scone_icon_no_text.ico -------------------------------------------------------------------------------- /contrib/lua-5.3.5/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensim-org/SCONE/HEAD/contrib/lua-5.3.5/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /src/sconelib/sconelua/sol_config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define SOL_SAFE_USERTYPE 1 4 | #define SOL_SAFE_FUNCTION_CALLS 1 5 | 6 | #include 7 | -------------------------------------------------------------------------------- /src/sconelib/sconelua/sconelua.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "platform.h" 4 | 5 | namespace scone 6 | { 7 | SCONE_LUA_API void RegisterSconeLua(); 8 | } 9 | -------------------------------------------------------------------------------- /src/sconestudio/SconeStudio.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | ../../resources/ui/scone_splash.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/sconestudio/model_conversion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class QWidget; 4 | 5 | namespace scone 6 | { 7 | void ShowModelConversionDialog( QWidget* parent ); 8 | } 9 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim3/sconeopensim3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "platform.h" 4 | 5 | namespace scone 6 | { 7 | SCONE_OPENSIM_3_API void RegisterSconeOpenSim3(); 8 | } 9 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/ModelFeatures.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace scone 4 | { 5 | struct ModelFeatures 6 | { 7 | bool allow_external_forces = false; 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /src/sconestudio/help_tools.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace scone 7 | { 8 | QUrl GetHelpUrl( const QString& keyword ); 9 | } 10 | -------------------------------------------------------------------------------- /src/sconeunittests/scenario_test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "xo/filesystem/path.h" 4 | 5 | namespace scone 6 | { 7 | void add_scenario_tests( const xo::path& scenarios ); 8 | } 9 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/deprecated/sconeopensim4.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "platform.h" 4 | 5 | namespace scone 6 | { 7 | SCONE_OPENSIM_4_API void RegisterSconeOpenSim4(); 8 | } 9 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/config/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | EXTRA_DIST = ac_cxx_have_sstream.m4\ 3 | ac_cxx_have_strstream.m4\ 4 | ac_cxx_namespaces.m4\ 5 | bb_enable_doxygen.m4 6 | 7 | 8 | -------------------------------------------------------------------------------- /contrib/lua-5.3.5/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.3.5, released on 26 Jun 2018. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/tclap.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | includedir=@includedir@ 3 | 4 | Name: tclap 5 | Description: Templatized C++ Command Line Parser 6 | Version: @VERSION@ 7 | Cflags: -I${includedir} 8 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/msc/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = examples 2 | 3 | EXTRA_DIST = README\ 4 | tclap-beta.ncb\ 5 | tclap-beta.sln\ 6 | tclap-beta.suo\ 7 | tclap-beta.vcproj 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/ForceValue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/core/Vec3.h" 4 | 5 | namespace scone 6 | { 7 | struct ForceValue 8 | { 9 | Vec3 force; 10 | Vec3 point; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | original author: Michael E. Smoot 3 | invaluable contributions: Daniel Aarno 4 | more contributions: Erik Zeek 5 | more contributions: Fabien Carmagnac (Tinbergen-AM) 6 | outstanding editing: Carol Smoot 7 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/CachedVar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | #include "xo/utility/cached_var.h" 5 | 6 | namespace scone 7 | { 8 | template< typename T > 9 | using CachedVar = xo::cached_var< T, TimeInSeconds >; 10 | } 11 | -------------------------------------------------------------------------------- /doc/generate.bat: -------------------------------------------------------------------------------- 1 | del xml\*.* /Q 2 | del ref\*.* /Q 3 | "C:\Program Files\doxygen\bin\doxygen.exe" Doxyfile 4 | "..\..\dokugen\bin\vc2019-x64\Release\dokugen.exe" xml ref -r classscone_1_1_ -r structscone_1_1_ 5 | dir /b ref\*.txt > "..\resources\help\keywords.txt" -------------------------------------------------------------------------------- /src/sconelib/scone/core/Propertyable.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Propertyable.h" 3 | 4 | namespace scone 5 | { 6 | Propertyable::Propertyable() 7 | { 8 | } 9 | 10 | Propertyable::~Propertyable() 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contrib/lua-5.3.5/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /src/sconelib.licenseheader: -------------------------------------------------------------------------------- 1 | extensions: .cpp .h 2 | /* 3 | ** %FILENAME% 4 | ** 5 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 6 | ** 7 | ** This file is part of SCONE. For more information, see http://scone.software. 8 | */ 9 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | ACLOCAL_AMFLAGS = -I config 3 | 4 | SUBDIRS = include examples docs tests msc config 5 | 6 | pkgconfigdir = $(libdir)/pkgconfig 7 | pkgconfig_DATA = $(PACKAGE).pc 8 | EXTRA_DIST = $(PACKAGE).pc.in 9 | 10 | DISTCLEANFILES = $(PACKAGE).pc 11 | -------------------------------------------------------------------------------- /src/sconelib/sconelua/platform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(_MSC_VER) 4 | # ifdef SCONE_LUA_EXPORTS 5 | # define SCONE_LUA_API __declspec(dllexport) 6 | # else 7 | # define SCONE_LUA_API __declspec(dllimport) 8 | # endif 9 | #else 10 | # define SCONE_LUA_API 11 | #endif 12 | -------------------------------------------------------------------------------- /src/sconelib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(scone) 2 | 3 | if (SCONE_OPENSIM_3) 4 | add_subdirectory(sconeopensim3) 5 | endif() 6 | 7 | if (SCONE_OPENSIM_4) 8 | add_subdirectory(sconeopensim4) 9 | endif() 10 | 11 | if (SCONE_LUA) 12 | add_subdirectory(sconelua) 13 | endif() 14 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/doxygen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace scone 4 | { 5 | /* \mainpage 6 | \section welcome_sec Welcome to the SCONE documentation 7 | \subsection controllers_sec Controllers 8 | Controller 9 | \subsection measures_sec Measures 10 | Measure 11 | */ 12 | } 13 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/memory_tools.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace scone 4 | { 5 | /// Link enum 6 | // TODO: move to elsewhere 7 | enum LinkType { UnknownLink = 0, RootLink, UpperLegLink, LowerLegLink, FootLink, UpperArmLink, LowerArmLink, HandLink, SpineLink, HeadLink, LinkTypeCount }; 8 | } 9 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/msc/examples/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | EXTRA_DIST = test1.vcproj\ 3 | test2.vcproj\ 4 | test3.vcproj\ 5 | test4.vcproj\ 6 | test5.vcproj\ 7 | test6.vcproj\ 8 | test7.vcproj\ 9 | test8.vcproj 10 | 11 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/sconeopensim4.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "platform.h" 4 | #include "scone/core/types.h" 5 | 6 | namespace scone 7 | { 8 | SCONE_OPENSIM_4_API void RegisterSconeOpenSim4(); 9 | SCONE_OPENSIM_4_API void ConvertModelOpenSim4( const xo::path& inputFile, const xo::path& outputFile ); 10 | } 11 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/deprecated/MetaReflexPose.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "MetaReflexPose.h" 3 | 4 | namespace scone 5 | { 6 | namespace cs 7 | { 8 | MetaReflexPose::MetaReflexPose( const PropNode& props, opt::ParamSet& par, sim::Model& model, const sim::Area& area ) 9 | { 10 | 11 | } 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /src/sconelib/scone/model/muscle_tools.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/core/platform.h" 4 | #include "scone/core/types.h" 5 | #include 6 | #include 7 | #include "scone/core/Angle.h" 8 | #include "xo/filesystem/path.h" 9 | 10 | namespace scone 11 | { 12 | SCONE_API void WriteMuscleInfo( Model& model ); 13 | } 14 | -------------------------------------------------------------------------------- /scenarios/Examples/data/HfdConfigG2020Planar.zml: -------------------------------------------------------------------------------- 1 | composite_force { 2 | planar_joint_force_pnld {} 3 | simple_collision_detection {} 4 | contact_force_hunt_crossley { viscosity = 1e3 } 5 | muscle_activation { activation_rate = 100 deactivation_rate = 25 } 6 | muscle_force_g2020d { xi = 0.1 } 7 | } 8 | error_control_integrator_pse { accuracy = 0.01 } -------------------------------------------------------------------------------- /scenarios/Examples/data/HfdConfigM2012Planar.zml: -------------------------------------------------------------------------------- 1 | composite_force { 2 | planar_joint_force_pnld {} 3 | simple_collision_detection {} 4 | contact_force_hunt_crossley { viscosity = 1e3 } 5 | muscle_activation { activation_rate = 100 deactivation_rate = 25 } 6 | muscle_force_m2012fast { xi = 0.1 } 7 | } 8 | error_control_integrator_pse { accuracy = 0.01 } -------------------------------------------------------------------------------- /scenarios/Examples/data/HfdConfigTJ2003Planar.zml: -------------------------------------------------------------------------------- 1 | composite_force { 2 | planar_joint_force_pnld {} 3 | simple_collision_detection {} 4 | contact_force_hunt_crossley { viscosity = 1e3 } 5 | muscle_activation { activation_rate = 100 deactivation_rate = 25 } 6 | muscle_force_tj2003 { xi = 0.1 } 7 | } 8 | error_control_integrator_pse { accuracy = 0.01 } -------------------------------------------------------------------------------- /contrib/lua-5.3.5/doc/index.css: -------------------------------------------------------------------------------- 1 | ul { 2 | list-style-type: none ; 3 | } 4 | 5 | ul.contents { 6 | padding: 0 ; 7 | } 8 | 9 | table { 10 | border: none ; 11 | border-spacing: 0 ; 12 | border-collapse: collapse ; 13 | } 14 | 15 | td { 16 | vertical-align: top ; 17 | padding: 0 ; 18 | text-align: left ; 19 | line-height: 1.25 ; 20 | width: 15% ; 21 | } 22 | -------------------------------------------------------------------------------- /scenarios/Examples/data/HfdConfigGH2010Planar.zml: -------------------------------------------------------------------------------- 1 | composite_force { 2 | planar_joint_force_pnld = "" 3 | simple_collision_detection = "" 4 | contact_force_hunt_crossley { viscosity = 1e3 } 5 | muscle_activation { 6 | activation_rate = 100 7 | deactivation_rate = 25 8 | } 9 | muscle_force_gh2010 {} 10 | } 11 | error_control_integrator_pse { accuracy = 0.01 } 12 | -------------------------------------------------------------------------------- /src/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(FILES 2 | ExampleObjective.cpp 3 | ExampleObjective.h 4 | main.cpp 5 | Test.cpp 6 | Test.h 7 | ) 8 | 9 | add_executable(scone-test ${FILES}) 10 | set_target_properties(scone-test PROPERTIES 11 | PROJECT_LABEL "test" 12 | OUTPUT_NAME test) 13 | 14 | target_link_libraries(scone-test sconelib) 15 | -------------------------------------------------------------------------------- /scenarios/Examples/data/InitStateJump.zml: -------------------------------------------------------------------------------- 1 | values { 2 | pelvis_ty = 0.75 3 | pelvis_tilt = -0.610865238198015 4 | hip_flexion_l = 1.39626340159546 5 | hip_flexion_r = 1.39626340159546 6 | knee_angle_l = -1.22173047639603 7 | knee_angle_r = -1.22173047639603 8 | ankle_angle_l = 0.436332312998582 9 | ankle_angle_r = 0.436332312998582 10 | } 11 | velocities { 12 | } 13 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/deprecated/CmaOptimizerCCMAES.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CmaOptimizer.h" 4 | 5 | namespace scone 6 | { 7 | class SCONE_API CmaOptimizerCCMAES : public CmaOptimizer 8 | { 9 | public: 10 | CmaOptimizerCCMAES( const PropNode& props ); 11 | virtual ~CmaOptimizerCCMAES() {} 12 | 13 | virtual void Run() override; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/deprecated/CmaOptimizerShark3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CmaOptimizer.h" 4 | 5 | namespace scone 6 | { 7 | class SCONE_API CmaOptimizerShark3 : public CmaOptimizer 8 | { 9 | public: 10 | CmaOptimizerShark3( const PropNode& props ); 11 | virtual ~CmaOptimizerShark3() {} 12 | 13 | virtual void Run() override; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /contrib/lua-5.3.5/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | color: gray ; 12 | float: right ; 13 | font-family: inherit ; 14 | font-style: normal ; 15 | font-size: small ; 16 | } 17 | 18 | h2:before { 19 | content: "" ; 20 | padding-right: 0em ; 21 | } 22 | -------------------------------------------------------------------------------- /scenarios/Examples/data/HfdConfigGH2010Planar.scone: -------------------------------------------------------------------------------- 1 | composite_force { 2 | planar_joint_force_pnld = "" 3 | simple_collision_detection = "" 4 | contact_force_hunt_crossley { viscosity = 1e3 } 5 | muscle_activation { 6 | activation_rate = 100 7 | deactivation_rate = 25 8 | } 9 | muscle_force_gh2010 { xi = 0.1 } 10 | } 11 | error_control_integrator_pse { accuracy = 0.01 } 12 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/storage_tools.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Storage.h" 4 | #include "scone/model/Side.h" 5 | 6 | namespace scone 7 | { 8 | SCONE_API Storage<> ExtractNormalized( const Storage<>& sto, TimeInSeconds begin, TimeInSeconds end ); 9 | SCONE_API Storage<> ExtractGaitCycle( const Storage<>& sto, const String& force_channel, const Real threshold ); 10 | } 11 | -------------------------------------------------------------------------------- /src/test/Test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/core/core.h" 4 | #include "scone/core/memory_tools.h" 5 | #include "xo/filesystem/path.h" 6 | 7 | namespace scone 8 | { 9 | void OptimizationTest(); 10 | void DelayTest(); 11 | void ModelTest(); 12 | void PlaybackTest( const xo::path& filename ); 13 | void MuscleLengthTest(); 14 | void DofAxisTest(); 15 | } 16 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/deprecated/sconeopensim4.cpp: -------------------------------------------------------------------------------- 1 | #include "sconeopensim4.h" 2 | 3 | #include "scone/core/Factories.h" 4 | #include "ModelOpenSim4.h" 5 | 6 | namespace scone 7 | { 8 | void RegisterSconeOpenSim4() 9 | { 10 | GetModelFactory().register_type< ModelOpenSim4 >( "OpenSim4Model" ); 11 | GetModelFactory().register_type< ModelOpenSim4 >( "ModelOpenSim4" ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/deprecated/MetaReflexPose.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cs.h" 4 | 5 | namespace scone 6 | { 7 | namespace cs 8 | { 9 | class CS_API MetaReflexPose 10 | { 11 | public: 12 | MetaReflexPose( const PropNode& props, opt::ParamSet& par, sim::Model& model, const sim::Area& area ); 13 | virtual ~MetaReflexPose() {} 14 | 15 | private: 16 | }; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /_output/ 2 | /bin/ 3 | /doc/ref/ 4 | /doc/html/ 5 | /doc/xml/ 6 | /doc/config/NaturalDocs/Working Data/ 7 | /scenarios/Tutorials/*.sto 8 | /scenarios/UnitTests/*.sto 9 | /scenarios/UnitTests/Hyfydy 10 | /resources/unittestdata/ 11 | /install 12 | /.version 13 | /doc/upload.bat 14 | /install/*.exe 15 | /*.bat 16 | *.log 17 | .cquery_cached_index/ 18 | /.vs/ 19 | /.dir-locals.el 20 | *~ 21 | build/ 22 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/deprecated/CmaOptimizerShark2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef USE_SHARK_2 4 | 5 | #include "CmaOptimizer.h" 6 | 7 | namespace scone 8 | { 9 | class SCONE_API CmaOptimizerShark2 : public CmaOptimizer 10 | { 11 | public: 12 | CmaOptimizerShark2( const PropNode& props ); 13 | virtual ~CmaOptimizerShark2() {} 14 | 15 | virtual void Run() override; 16 | }; 17 | } 18 | 19 | #endif -------------------------------------------------------------------------------- /src/sconelib/scone/core/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** version.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "xo/system/version.h" 12 | #include "platform.h" 13 | 14 | namespace scone 15 | { 16 | using xo::version; 17 | SCONE_API const version& GetSconeVersion(); 18 | } 19 | -------------------------------------------------------------------------------- /src/test/ExampleObjective.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/optimization/Objective.h" 4 | 5 | namespace scone 6 | { 7 | class ExampleObjective : public Objective 8 | { 9 | public: 10 | ExampleObjective( const PropNode& props ); 11 | 12 | protected: 13 | virtual double evaluate( const ParamInstance& values ) const override; 14 | 15 | private: 16 | int num_params; 17 | mutable bool is_evaluating; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /src/sconelib/sconelua/sconelua.cpp: -------------------------------------------------------------------------------- 1 | #include "sconelua.h" 2 | 3 | #include "scone/core/Factories.h" 4 | #include "lua_script.h" 5 | #include "ScriptController.h" 6 | #include "ScriptMeasure.h" 7 | 8 | namespace scone 9 | { 10 | SCONE_LUA_API void RegisterSconeLua() 11 | { 12 | GetControllerFactory().register_type< ScriptController >( "ScriptController" ); 13 | GetMeasureFactory().register_type< ScriptMeasure >( "ScriptMeasure" ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /resources/unittestdata/optimization_test/schwefel_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 4 | -2 5 | 0 6 | 0 7 | 1 8 | 10000 9 | DATE_TIME_EXACT 10 | 11 | 5 12 | 13 | 14 | -------------------------------------------------------------------------------- /scenarios/Tutorials/data/MeasureBalance.scone: -------------------------------------------------------------------------------- 1 | # Measure for standing balance 2 | CompositeMeasure { 3 | # Penalize falling 4 | BalanceMeasure { 5 | termination_height = 0.8 6 | weight = 100 7 | } 8 | 9 | # Minimize effort 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.01 13 | measure_type = Wang2012 14 | } 15 | 16 | # Penalize locked knees 17 | DofMeasure { 18 | dof = knee_angle_r 19 | position { min = -30 max = 0 abs_penalty = 10 } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/PropNode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** PropNode.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | 13 | #include "xo/container/prop_node.h" 14 | #include "xo/container/prop_node_tools.h" 15 | 16 | namespace scone 17 | { 18 | using PropNode = xo::prop_node; 19 | } 20 | -------------------------------------------------------------------------------- /tools/unix_2b_build-simbody: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | source ./tools/build_config 5 | 6 | echo "${0}: building simbody" 7 | 8 | mkdir -p "${SIMBODY_INSTALL_PATH}" 9 | mkdir -p simbody/build 10 | cd simbody/build 11 | cmake .. \ 12 | -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \ 13 | -DCMAKE_VERBOSE_MAKEFILE="${CMAKE_VERBOSE_MAKEFILE}" \ 14 | -DCMAKE_INSTALL_PREFIX="${SIMBODY_INSTALL_PATH}" 15 | cmake --build . --parallel ${NUM_BUILD_JOBS} --target install 16 | cd - 17 | -------------------------------------------------------------------------------- /src/sconestudio/SettingsEditor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** SettingsEditor.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | namespace scone 14 | { 15 | class SettingsEditor 16 | { 17 | public: 18 | SettingsEditor() {} 19 | virtual ~SettingsEditor() {} 20 | 21 | int showDialog( QWidget* parent ); 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/Quat.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Quat.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "xo/geometry/quat.h" 13 | 14 | namespace scone 15 | { 16 | // import Quat from xo 17 | using Quat = xo::quat_< Real >; 18 | using Quatf = xo::quat_< float >; 19 | using Quatd = xo::quat_< double >; 20 | } 21 | -------------------------------------------------------------------------------- /src/sconestudio/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by studio.rc 4 | // 5 | #define IDI_ICON1 103 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 104 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1000 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/FactoryProps.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Exception.h" 4 | #include "PropNode.h" 5 | #include "types.h" 6 | 7 | namespace scone 8 | { 9 | struct FactoryProps { 10 | const PropNode& props() const { SCONE_THROW_IF( !props_, "Invalid Factory Properties" ); return *props_; } 11 | const String& type() const { SCONE_THROW_IF( !props_, "Invalid Factory Properties" ); return type_; } 12 | operator bool() const { return props_; } 13 | String type_; 14 | const PropNode* props_ = nullptr; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/sconeopensim4.cpp: -------------------------------------------------------------------------------- 1 | #include "sconeopensim4.h" 2 | 3 | #include "scone/core/Factories.h" 4 | #include "ModelOpenSim4.h" 5 | #include "xo/filesystem/path.h" 6 | 7 | namespace scone 8 | { 9 | void RegisterSconeOpenSim4() 10 | { 11 | GetModelFactory().register_type< ModelOpenSim4 >( "ModelOpenSim4" ); 12 | } 13 | 14 | void ConvertModelOpenSim4( const xo::path& inputFile, const xo::path& outputFile ) 15 | { 16 | OpenSim::Model m( inputFile.str() ); 17 | m.print( outputFile.str() ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/Vec3.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Vec3.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "types.h" 13 | #include "xo/geometry/vec3.h" 14 | 15 | namespace scone 16 | { 17 | // import Vec3 from xo 18 | typedef xo::vec3_< Real > Vec3; 19 | typedef xo::vec3_< float > Vec3f; 20 | typedef xo::vec3_< double > Vec3d; 21 | } 22 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/Angle.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Angle.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "xo/geometry/angle.h" 13 | #include "types.h" 14 | 15 | namespace scone 16 | { 17 | // import Radian and Degree from xo 18 | using Degree = xo::degree_< Real >; 19 | using Radian = xo::radian_< Real >; 20 | } 21 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim3/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** platform.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #if defined(_MSC_VER) 12 | # ifdef SCONE_MODEL_OPENSIM_3_EXPORTS 13 | # define SCONE_OPENSIM_3_API __declspec(dllexport) 14 | # else 15 | # define SCONE_OPENSIM_3_API __declspec(dllimport) 16 | # endif 17 | #else 18 | # define SCONE_OPENSIM_3_API 19 | #endif 20 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** platform.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #if defined(_MSC_VER) 12 | # ifdef SCONE_MODEL_OPENSIM_4_EXPORTS 13 | # define SCONE_OPENSIM_4_API __declspec(dllexport) 14 | # else 15 | # define SCONE_OPENSIM_4_API __declspec(dllimport) 16 | # endif 17 | #else 18 | # define SCONE_OPENSIM_4_API 19 | #endif 20 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "submodules/qtfx"] 2 | path = submodules/qtfx 3 | url = https://github.com/tgeijten/qtfx.git 4 | [submodule "submodules/spot"] 5 | path = submodules/spot 6 | url = https://github.com/tgeijten/spot.git 7 | [submodule "submodules/xo"] 8 | path = submodules/xo 9 | url = https://github.com/tgeijten/xo.git 10 | [submodule "submodules/vis"] 11 | path = submodules/vis 12 | url = https://github.com/tgeijten/vis.git 13 | [submodule "submodules/sol2"] 14 | path = submodules/sol2 15 | url = https://github.com/ThePhD/sol2.git 16 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 3a - Standing Balance.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 30 6 | 7 | # Model used in simulation 8 | ModelOpenSim3 { 9 | model_file = data/Human0916.osim 10 | state_init_file = data/InitStateStand.sto 11 | } 12 | 13 | # Controller for reflex based balance (different file) 14 | << data/ControllerReflexBalance.scone >> 15 | 16 | # Measure for standing balance (different file) 17 | << data/MeasureBalance.scone >> 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/Sensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Sensor.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/core/types.h" 12 | #include "scone/core/platform.h" 13 | 14 | namespace scone 15 | { 16 | struct Sensor 17 | { 18 | Sensor() {} 19 | virtual ~Sensor() {} 20 | virtual String GetName() const = 0; 21 | virtual Real GetValue() const = 0; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/deprecated/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** platform.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #if defined(_MSC_VER) 12 | # ifdef SCONE_MODEL_OPENSIM_4_EXPORTS 13 | # define SCONE_OPENSIM_4_API __declspec(dllexport) 14 | # else 15 | # define SCONE_OPENSIM_4_API __declspec(dllimport) 16 | # endif 17 | #else 18 | # define SCONE_OPENSIM_4_API 19 | #endif 20 | -------------------------------------------------------------------------------- /src/sconestudio/studio_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** studio_config.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | namespace scone 12 | { 13 | #ifdef _MSC_VER 14 | # define SCONE_SCONECMD_EXECUTABLE "sconecmd.exe" 15 | # define SCONE_FFMPEG_EXECUTABLE "ffmpeg.exe" 16 | #else 17 | # define SCONE_SCONECMD_EXECUTABLE "sconecmd" 18 | # define SCONE_FFMPEG_EXECUTABLE "ffmpeg" 19 | #endif 20 | } 21 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim3/sconeopensim3.cpp: -------------------------------------------------------------------------------- 1 | #include "sconeopensim3.h" 2 | 3 | #include "scone/core/Factories.h" 4 | #include "ModelOpenSim3.h" 5 | 6 | namespace scone 7 | { 8 | SCONE_OPENSIM_3_API void RegisterSconeOpenSim3() 9 | { 10 | GetModelFactory().register_type< ModelOpenSim3 >( "Simbody" ); // backwards compatibility 11 | GetModelFactory().register_type< ModelOpenSim3 >( "OpenSim3Model" ); 12 | GetModelFactory().register_type< ModelOpenSim3 >( "OpenSimModel" ); 13 | GetModelFactory().register_type< ModelOpenSim3 >( "ModelOpenSim3" ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/sconestudio/GaitAnalysis.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "scone/core/Storage.h" 5 | #include 6 | 7 | namespace scone 8 | { 9 | class GaitAnalysis : public QWidget 10 | { 11 | public: 12 | GaitAnalysis( QWidget* parent = nullptr ); 13 | void reset(); 14 | void update( const Storage<>& sto, const path& filename ); 15 | 16 | const QString& info() const { return info_; } 17 | 18 | private: 19 | Storage<> sto_; 20 | QGridLayout* grid_; 21 | QString info_; 22 | std::vector< class GaitPlot* > plots_; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /tools/mac_e2e_build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Top-level script for building SCONE from scratch on a fresh machine 4 | # this assumes the caller *also* wants to install dependencies, package SCONE, 5 | # etc., ("the works") 6 | 7 | echo "${0}: getting build dependencies" 8 | ./tools/mac_1_get-dependencies 9 | 10 | echo "${0}: building binaries" 11 | ./tools/unix_2_build 12 | 13 | echo "${0}: packaging binaries + assets into a directory" 14 | ./tools/mac_3_create-install-dirtree 15 | 16 | echo "${0}: packaging directory into a DMG" 17 | ./tools/mac_4_create-dmg 18 | 19 | -------------------------------------------------------------------------------- /CMakeModules/FindSpot.cmake: -------------------------------------------------------------------------------- 1 | # Find spot headers 2 | # TODO: use a better path estimate! 3 | find_path(SPOT_INCLUDE_DIR 4 | NAMES "spot/optimizer.h" 5 | PATHS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/submodules/spot 6 | ) 7 | 8 | # This CMake-supplied script provides standard error handling. 9 | include(FindPackageHandleStandardArgs) 10 | find_package_handle_standard_args(SPOT 11 | FAIL_MESSAGE "Could NOT find SPOT. Set SPOT_INCLUDE_DIR manually." 12 | REQUIRED_VARS SPOT_INCLUDE_DIR 13 | ) 14 | 15 | # SPOT_FOUND is set automatically for us by find_package(). 16 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/README: -------------------------------------------------------------------------------- 1 | 2 | TCLAP - Templatized Command Line Argument Parser 3 | 4 | This is a simple C++ library that facilitates parsing command line 5 | arguments in a type independent manner. It doesn't conform exactly 6 | to either the GNU or POSIX standards, although it is close. See 7 | docs/manual.html for descriptions of how things work or look at the 8 | simple examples in the examples dir. 9 | 10 | To find out what the latest changes are read the NEWS file in this directory. 11 | 12 | 13 | Any and all feedback is welcome to: Mike Smoot 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /scenarios/Examples/data/InitStateGait10.zml: -------------------------------------------------------------------------------- 1 | values { 2 | pelvis_tilt = -0.0336387 3 | pelvis_tx = 0 4 | pelvis_ty = 0.95 5 | hip_flexion_r = 0.165239 6 | knee_angle_r = -0.0888009 7 | ankle_angle_r = 0.0197104 8 | hip_flexion_l = 0.232604 9 | knee_angle_l = -1.22703 10 | ankle_angle_l = -0.167279 11 | } 12 | velocities { 13 | pelvis_tilt = -0.572135 14 | pelvis_tx = 1 15 | pelvis_ty = 0.0545873 16 | hip_flexion_r = -0.576377 17 | knee_angle_r = 0.175894 18 | ankle_angle_r = 0.988937 19 | hip_flexion_l = 4.90666 20 | knee_angle_l = -3.59786 21 | ankle_angle_l = 0.633253 22 | } 23 | -------------------------------------------------------------------------------- /src/sconelib/sconelua/lua_script.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "platform.h" 4 | #include "scone/optimization/Params.h" 5 | #include "scone/model/Model.h" 6 | 7 | #include "sol_config.h" 8 | 9 | namespace scone 10 | { 11 | class lua_script 12 | { 13 | public: 14 | lua_script( const path& script_file, const PropNode& props, Params& par, Model& model ); 15 | ~lua_script(); 16 | 17 | sol::function find_function( const String& name ); 18 | sol::function try_find_function( const String& name ); 19 | xo::path script_file_; 20 | 21 | private: 22 | sol::state lua_; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/MotorNeuron.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** MotorNeuron.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "InterNeuron.h" 12 | 13 | namespace scone 14 | { 15 | struct MotorNeuron : public Neuron 16 | { 17 | MotorNeuron( const PropNode& pn, Params& par, NeuralController& nc, const string& muscle, index_t idx, Side side, const string& act_func = "rectifier" ); 18 | void UpdateActuator(); 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/DisplayGeometry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/core/Vec3.h" 4 | #include "scone/core/Quat.h" 5 | #include "scone/core/types.h" 6 | #include "xo/filesystem/path.h" 7 | 8 | namespace scone 9 | { 10 | struct DisplayGeometry 11 | { 12 | DisplayGeometry() = default; 13 | DisplayGeometry( const path& file, const Vec3& p, const Quat& q = Quat(), const Vec3& s = Vec3::diagonal( 1 ) ) : 14 | filename( file ), 15 | pos( p ), 16 | ori( q ), 17 | scale( s ) 18 | {} 19 | 20 | xo::path filename; 21 | Vec3 pos; 22 | Quat ori; 23 | Vec3 scale; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /CMakeModules/FindXo.cmake: -------------------------------------------------------------------------------- 1 | # Find XO headers 2 | # TODO: use a better path estimate! 3 | find_path(XO_INCLUDE_DIR 4 | NAMES xo/system/xo_config.h 5 | PATHS ${CMAKE_SOURCE_DIR}/submodules/xo 6 | ) 7 | 8 | # This CMake-supplied script provides standard error handling. 9 | include(FindPackageHandleStandardArgs) 10 | find_package_handle_standard_args(XO 11 | FAIL_MESSAGE "Could NOT find XO. Set XO_INCLUDE_DIR to the XO directory." 12 | REQUIRED_VARS XO_INCLUDE_DIR 13 | ) 14 | 15 | # XO_FOUND is set automatically for us by find_package(). 16 | if(XO_FOUND) 17 | set(XO_INCLUDE_DIRS ${XO_INCLUDE_DIR}) 18 | endif() 19 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/config/ac_cxx_have_long_long.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_CXX_HAVE_LONG_LONG 2 | dnl 3 | dnl If the C++ implementation have a long long type 4 | dnl 5 | AC_DEFUN([AC_CXX_HAVE_LONG_LONG], 6 | [AC_LANG_SAVE 7 | AC_LANG_CPLUSPLUS 8 | AC_TRY_COMPILE([],[long long x = 1; return 0;], 9 | ac_cv_cxx_have_long_long=yes, ac_cv_cxx_have_long_long=no) 10 | 11 | if test "$ac_cv_cxx_have_long_long" = yes; then 12 | AC_DEFINE(HAVE_LONG_LONG, 1, 13 | [define if the C++ implementation have long long]) 14 | else 15 | AC_DEFINE(HAVE_LONG_LONG, 0, 16 | [define if the C++ implementation have long long]) 17 | fi 18 | AC_LANG_RESTORE 19 | ]) 20 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/InterNeuron.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** InterNeuron.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Neuron.h" 12 | 13 | namespace scone 14 | { 15 | struct InterNeuron : public Neuron 16 | { 17 | InterNeuron( const PropNode& pn, Params& par, const string& layer, index_t idx, Side side, const string& act_func ); 18 | double GetOutput( double offset = 0.0 ) const override; 19 | 20 | double width_; 21 | bool use_distance_; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 4a - Gait.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 10 6 | 7 | # Model used in simulation 8 | ModelOpenSim3 { 9 | model_file = data/Human0914.osim 10 | 11 | # Optimize initial state parameters 12 | state_init_file = data/InitStateGait10.sto 13 | initial_state_offset = 0~0.01<-0.5,0.5> 14 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 15 | } 16 | 17 | # Controller for gait, based on [Geyer & Herr 2010] 18 | << data/ControllerGH2010.scone >> 19 | 20 | # Measure for gait 21 | << data/MeasureGait10.scone >> 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/sconestudio/OptimizerTaskExternal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "OptimizerTask.h" 5 | #include "xo/filesystem/path.h" 6 | #include "scone/core/types.h" 7 | 8 | namespace scone 9 | { 10 | class OptimizerTaskExternal : public OptimizerTask 11 | { 12 | public: 13 | OptimizerTaskExternal( const QString& scenario, const QStringList& options = QStringList() ); 14 | virtual ~OptimizerTaskExternal(); 15 | 16 | bool interrupt() override; 17 | void finish() override; 18 | std::deque getMessages() override; 19 | 20 | protected: 21 | QProcess* process_; 22 | bool send_process_closed_mesage_; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/config/bb_enable_doxygen.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([BB_ENABLE_DOXYGEN], 2 | [ 3 | AC_ARG_ENABLE(doxygen, [--enable-doxygen enable documentation generation with doxygen (auto)]) 4 | if test "x$enable_doxygen" = xno; then 5 | enable_doc=no 6 | else 7 | AC_PATH_PROG(DOXYGEN, doxygen, , $PATH) 8 | if test x$DOXYGEN = x; then 9 | if test "x$enable_doxygen" = xyes; then 10 | AC_MSG_ERROR([could not find doxygen]) 11 | fi 12 | enable_doc=no 13 | else 14 | enable_doc=yes 15 | fi 16 | fi 17 | AM_CONDITIONAL(DOC, test x$enable_doc = xyes) 18 | ]) 19 | -------------------------------------------------------------------------------- /contrib/lua-5.3.5/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 4b - Gait at Different Speeds.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 10 6 | 7 | # Model used in simulation 8 | ModelOpenSim3 { 9 | model_file = data/Human0914.osim 10 | 11 | # Optimize initial state parameters 12 | state_init_file = data/InitStateGait15.sto 13 | initial_state_offset = 0~0.01<-0.5,0.5> 14 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 15 | } 16 | 17 | # Controller for gait, based on [Geyer & Herr 2010] 18 | << data/ControllerGH2010.scone >> 19 | 20 | # Measure for gait 21 | << data/MeasureGait15.scone >> 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/Gait - Slope.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 10 6 | 7 | # Model used in simulation 8 | OpenSimModel { 9 | model_file = data/Human0914Slope5down.osim 10 | 11 | # Optimize initial state parameters 12 | state_init_file = data/InitStateGait10.sto 13 | initial_state_offset = 0~0.01<-0.5,0.5> 14 | 15 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 16 | } 17 | 18 | # Controller for gait, based on [Geyer & Herr 2010] 19 | << data/ControllerGH2010.scone >> 20 | 21 | # Measure for gait 22 | << data/MeasureGait05.scone >> 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/Gait - Fixed Knee Model.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 10 6 | 7 | # Model used in simulation 8 | OpenSimModel { 9 | model_file = data/Human0914FixedKnee.osim 10 | 11 | # Optimize initial state parameters 12 | state_init_file = data/InitStateGait10.sto 13 | initial_state_offset = 0~0.01<-0.5,0.5> 14 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 15 | } 16 | 17 | # Controller for gait, based on [Geyer & Herr 2010] 18 | << data/ControllerGH2010.scone >> 19 | 20 | # Measure for gait 21 | << data/MeasureGait10.scone >> 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/Params.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Params.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "spot/search_point.h" 12 | #include "spot/objective_info.h" 13 | #include "spot/par_tools.h" 14 | #include "spot/par_info.h" 15 | 16 | namespace scone 17 | { 18 | using Params = spot::par_io; 19 | using SearchPoint = spot::search_point; 20 | using ObjectiveInfo = spot::objective_info; 21 | using ParInfo = spot::par_info; 22 | using ScopedParamSetPrefixer = spot::scoped_prefix; 23 | } 24 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/deprecated/SimulationOpenSim4.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** SimulationOpenSim4.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "scone/model/Simulation.h" 13 | 14 | namespace scone 15 | { 16 | class SCONE_OPENSIM_4_API SimulationOpenSim4 : public Simulation 17 | { 18 | public: 19 | SimulationOpenSim4( const PropNode& props ); 20 | virtual ~SimulationOpenSim4() { }; 21 | 22 | virtual void AdvanceSimulationTo( double time ) override; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 4d - Walking on Ice.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 10 6 | signature_postfix = ice 7 | 8 | # Model used in simulation 9 | ModelOpenSim3 { 10 | model_file = data/Human0914Ice.osim 11 | 12 | # Optimize initial state parameters 13 | state_init_file = data/InitStateGait10.sto 14 | initial_state_offset = 0~0.01<-0.5,0.5> 15 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 16 | } 17 | 18 | # Controller for gait, based on [Geyer & Herr 2010] 19 | << data/ControllerGH2010.scone >> 20 | 21 | # Measure for gait 22 | << data/MeasureGait05.scone >> 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim3/simbody_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** simbody_tools.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/core/math.h" 12 | #include "scone/core/Vec3.h" 13 | 14 | namespace scone 15 | { 16 | inline Vec3 from_osim( const SimTK::Vec3& vec ) { return Vec3( vec[ 0 ], vec[ 1 ], vec[ 2 ] ); } 17 | inline Quat from_osim( const SimTK::Quaternion& q ) { return Quat( q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] ); } 18 | 19 | inline SimTK::Vec3 to_osim( const Vec3& v ) { return SimTK::Vec3( v.x, v.y, v.z ); } 20 | } 21 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/simbody_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** simbody_tools.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/core/math.h" 12 | #include "scone/core/Vec3.h" 13 | 14 | namespace scone 15 | { 16 | inline Vec3 from_osim( const SimTK::Vec3& vec ) { return Vec3( vec[ 0 ], vec[ 1 ], vec[ 2 ] ); } 17 | inline Quat from_osim( const SimTK::Quaternion& q ) { return Quat( q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] ); } 18 | 19 | inline SimTK::Vec3 to_osim( const Vec3& v ) { return SimTK::Vec3( v.x, v.y, v.z ); } 20 | } 21 | -------------------------------------------------------------------------------- /tools/unix_2_build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | source ./tools/build_config 5 | 6 | echo "${0}: starting OpenSceneGraph build" 7 | ./tools/unix_2a_build-osg 8 | 9 | echo "${0}: starting simbody build" 10 | ./tools/unix_2b_build-simbody 11 | 12 | echo "${0}: starting opensim3 build" 13 | ./tools/unix_2c_build-opensim3 14 | 15 | echo "${0}: dependency build complete: the following directories were created:" 16 | find "${OSG_INSTALL_PATH}" -maxdepth 2 -mindepth 1 17 | find "${SIMBODY_INSTALL_PATH}" -maxdepth 2 -mindepth 1 18 | find "${OPENSIM3_INSTALL_PATH}" -maxdepth 2 -mindepth 1 19 | 20 | echo "${0}: all dependencies built: building SCONE" 21 | ./tools/unix_2d_build-scone 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for SCONE 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/Jump - Imitation.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | ImitationObjective { 5 | file = data/f0914m.FC2.HighJump.D2.sto 6 | frame_delta = 5 7 | 8 | # Model used in simulation 9 | OpenSimModel { 10 | model_file = data/Human0914.osim 11 | } 12 | 13 | # Controller for the Model 14 | FeedForwardController { 15 | symmetric = 1 16 | 17 | # Function for feed-forward pattern 18 | PieceWiseConstant { 19 | control_points = 2 20 | control_point_y = 0.3~0.01<0,1> # Initial y value of control points 21 | control_point_dt = 0.2~0.01<0.001,1> # Initial delta time between control points 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 1 - Introduction.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 2 6 | 7 | # Model used in simulation 8 | ModelOpenSim3 { 9 | model_file = data/Human0914.osim 10 | } 11 | 12 | # Controller for the Model 13 | FeedForwardController { 14 | symmetric = 1 15 | 16 | # Function for feed-forward pattern 17 | PieceWiseConstant { 18 | control_points = 2 19 | control_point_y = 0.3~0.01<0,1> 20 | control_point_dt = 0.2~0.01<0,1> 21 | } 22 | } 23 | 24 | # Fitness measure for jumping 25 | JumpMeasure { 26 | termination_height = 0.75 27 | prepare_time = 0.2 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SCONE has moved! 2 | ![.github/workflows/continuous-integration-workflow.yml](https://github.com/opensim-org/SCONE/workflows/.github/workflows/continuous-integration-workflow.yml/badge.svg) 3 | 4 | SCONE has been split up into two new repositories: 5 | 6 | * [scone-core](https://github.com/tgeijten/scone-core) contains the core SCONE functionality, licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0). 7 | * [scone-studio](https://github.com/tgeijten/scone-studio) contains the Graphical User Interface for SCONE, licensed under [GNU GPL 3](http://www.gnu.org/licenses/gpl-3.0.en.html) or later. 8 | 9 | This repository is no longer maintained. Please do not post any issues or pull requests. 10 | -------------------------------------------------------------------------------- /scenarios/Examples/Gait - H0914 - OpenSim3.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | min_progress = 1e-4 4 | 5 | SimulationObjective { 6 | max_duration = 10 7 | 8 | # Model used in simulation 9 | ModelOpenSim3 { 10 | model_file = data/H0914M_osim3.osim 11 | signature_postfix = OS3 12 | 13 | # Optimize initial state parameters 14 | state_init_file = data/InitStateGait10.sto 15 | initial_state_offset = 0~0.01<-0.5,0.5> 16 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 17 | } 18 | 19 | # Controller for gait, based on [Geyer & Herr 2010] 20 | << data/ControllerGH2010.scone >> 21 | 22 | # Measure for gait 23 | << data/MeasureGait10Grf.scone >> 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /scenarios/Examples/Gait - H0918 - OpenSim3.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | min_progress = 1e-4 4 | 5 | SimulationObjective { 6 | max_duration = 10 7 | 8 | # Model used in simulation 9 | ModelOpenSim3 { 10 | model_file = data/H0918M_osim3.osim 11 | signature_postfix = OS3 12 | 13 | # Optimize initial state parameters 14 | state_init_file = data/InitStateGait10.sto 15 | initial_state_offset = 0~0.01<-0.5,0.5> 16 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 17 | } 18 | 19 | # Controller for gait, based on [Geyer & Herr 2010] 20 | << data/ControllerGH2010M18.scone >> 21 | 22 | # Measure for gait 23 | << data/MeasureGait10Grf.scone >> 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/Settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Settings.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "xo/system/settings.h" 13 | #include "types.h" 14 | 15 | namespace scone 16 | { 17 | SCONE_API xo::settings& GetSconeSettings(); 18 | SCONE_API void SaveSconeSettings(); 19 | 20 | template< typename T > T GetSconeSetting( const String& key ) { return GetSconeSettings().get( key ); } 21 | 22 | constexpr bool GetExperimentalFeaturesEnabled() { return SCONE_EXPERIMENTAL_FEATURES_ENABLED == 1; } 23 | } 24 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/msc/README: -------------------------------------------------------------------------------- 1 | 2 | Disclaimer! 3 | =========== 4 | 5 | The various files included in the subdirectory for provided as a courtesy 6 | to Microsoft Visual Studio users. The files were contributed by a thoughtful 7 | user and were not created by the authors of this project. Moreover, the 8 | (current) authors have no way of maintaining, improving or even using the 9 | files. 10 | 11 | ** This means we can't answer any questions about the files! ** 12 | 13 | That said, we have several reports of people successfully using the TCLAP 14 | library on various Windows platforms. As long as you use a reasonably modern 15 | compiler (and Visual C++ apparently is), you shouldn't have any trouble. 16 | 17 | Good luck! 18 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/Dof.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Dof.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "Dof.h" 10 | #include "Model.h" 11 | #include "Muscle.h" 12 | 13 | #pragma warning( disable: 4355 ) 14 | 15 | namespace scone 16 | { 17 | Dof::Dof( const Joint* j ) : m_Joint( j ) {} 18 | Dof::~Dof() {} 19 | 20 | Real Dof::GetMuscleMoment() const 21 | { 22 | Real mom = 0.0; 23 | for ( const auto& mus : GetModel().GetMuscles() ) 24 | { 25 | if ( mus->HasMomentArm( *this ) ) 26 | mom += mus->GetMoment( *this ); 27 | } 28 | return mom; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/model_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** model_tools.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "scone/core/platform.h" 13 | #include "scone/core/Vec3.h" 14 | #include "scone/core/math.h" 15 | 16 | namespace scone 17 | { 18 | class Muscle; 19 | SCONE_API Vec3 GetGroundCop( const Vec3& force, const Vec3& moment, Real min_force = REAL_WIDE_EPSILON ); 20 | SCONE_API Vec3 GetPlaneCop( const Vec3& normal, const Vec3& location, const Vec3& force, const Vec3& moment, Real min_force = REAL_WIDE_EPSILON ); 21 | } 22 | -------------------------------------------------------------------------------- /scenarios/Examples/Gait - H0914 - OpenSim4.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | min_progress = 1e-4 4 | 5 | SimulationObjective { 6 | max_duration = 10 7 | 8 | # Model used in simulation 9 | ModelOpenSim4 { 10 | model_file = data/H0914M_osim4.osim 11 | signature_postfix = OS4 12 | 13 | # Optimize initial state parameters 14 | state_init_file = data/InitStateGait10.sto 15 | initial_state_offset = 0~0.01<-0.5,0.5> 16 | initial_state_offset_exclude = "*_tx*;*_ty*;*_u;*/speed" 17 | } 18 | 19 | # Controller for gait, based on [Geyer & Herr 2010] 20 | << data/ControllerGH2010.scone >> 21 | 22 | # Measure for gait 23 | << data/MeasureGait10Grf.scone >> 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /scenarios/Examples/Gait - H0918 - OpenSim4.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | min_progress = 1e-4 4 | 5 | SimulationObjective { 6 | max_duration = 10 7 | 8 | # Model used in simulation 9 | ModelOpenSim4 { 10 | model_file = data/H0918M_osim4.osim 11 | signature_postfix = OS4 12 | 13 | # Optimize initial state parameters 14 | state_init_file = data/InitStateGait10.sto 15 | initial_state_offset = 0~0.01<-0.5,0.5> 16 | initial_state_offset_exclude = "*_tx*;*_ty*;*_u;*/speed" 17 | } 18 | 19 | # Controller for gait, based on [Geyer & Herr 2010] 20 | << data/ControllerGH2010M18.scone >> 21 | 22 | # Measure for gait 23 | << data/MeasureGait10Grf.scone >> 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/include/tclap/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | libtclapincludedir = $(includedir)/tclap 3 | 4 | libtclapinclude_HEADERS = \ 5 | CmdLineInterface.h \ 6 | ArgException.h \ 7 | CmdLine.h \ 8 | XorHandler.h \ 9 | MultiArg.h \ 10 | UnlabeledMultiArg.h \ 11 | ValueArg.h \ 12 | UnlabeledValueArg.h \ 13 | Visitor.h Arg.h \ 14 | HelpVisitor.h \ 15 | SwitchArg.h \ 16 | MultiSwitchArg.h \ 17 | VersionVisitor.h \ 18 | IgnoreRestVisitor.h \ 19 | CmdLineOutput.h \ 20 | StdOutput.h \ 21 | DocBookOutput.h \ 22 | ZshCompletionOutput.h \ 23 | OptionalUnlabeledTracker.h \ 24 | Constraint.h \ 25 | ValuesConstraint.h \ 26 | ArgTraits.h \ 27 | StandardTraits.h 28 | 29 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/data/ScriptGeomTest.lua: -------------------------------------------------------------------------------- 1 | function init( model, par ) 2 | for i = 1, model:body_count() do 3 | b = model:body( i ) 4 | p = b:com_pos() 5 | p2 = 0.1 * p + vec3:new( 1, 0, 0 ) 6 | p3 = -p / 100 7 | p3:normalize() 8 | unitx = vec3:new( 1, 0, 0 ) 9 | cross = vec3.cross_product( p, unitx ) 10 | dot = p:dot_product( unitx ) 11 | p2:clear() 12 | l = p:length() 13 | sl = p:squared_length() 14 | scone.info( b:name() .. ": " .. 15 | tostring(p) .. 16 | " cross=" .. tostring(cross) .. 17 | " dot=" .. tostring(dot) .. 18 | " p3=" .. tostring(p3) 19 | ) 20 | end 21 | end 22 | 23 | function update( model ) 24 | -- get the current simulation time 25 | local t = model:time() 26 | end 27 | -------------------------------------------------------------------------------- /scenarios/Examples/data/MeasureGait10.scone: -------------------------------------------------------------------------------- 1 | # Measure for gait, minimum speed = 1.0 m/s 2 | CompositeMeasure { 3 | GaitMeasure { 4 | name = Gait 5 | weight = 100 6 | threshold = 0.05 7 | termination_height = 0.85 8 | min_velocity = 1.0 9 | } 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.1 13 | measure_type = Wang2012 14 | use_cost_of_transport = 1 15 | } 16 | CompositeMeasure { 17 | name = DofLimits 18 | symmetric = 1 19 | DofMeasure { 20 | weight = 0.1 21 | dof = ankle_angle 22 | position { min = -60 max = 60 squared_penalty = 1 } 23 | } 24 | DofMeasure { 25 | weight = 0.01 26 | threshold = 5 27 | dof = knee_angle 28 | force { min = 0 max = 0 abs_penalty = 1 } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /scenarios/Tutorials/data/MeasureGait05.scone: -------------------------------------------------------------------------------- 1 | # Measure for gait, minimum speed = 1.0 m/s 2 | CompositeMeasure { 3 | GaitMeasure { 4 | name = Gait 5 | weight = 100 6 | threshold = 0.05 7 | termination_height = 0.85 8 | min_velocity = 0.5 9 | } 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.1 13 | measure_type = Wang2012 14 | use_cost_of_transport = 1 15 | } 16 | CompositeMeasure { 17 | name = DofLimits 18 | symmetric = 1 19 | DofMeasure { 20 | weight = 0.1 21 | dof = ankle_angle 22 | position { min = -60 max = 60 squared_penalty = 1 } 23 | } 24 | DofMeasure { 25 | weight = 0.01 26 | threshold = 5 27 | dof = knee_angle 28 | force { min = 0 max = 0 abs_penalty = 1 } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /scenarios/Tutorials/data/MeasureGait10.scone: -------------------------------------------------------------------------------- 1 | # Measure for gait, minimum speed = 1.0 m/s 2 | CompositeMeasure { 3 | GaitMeasure { 4 | name = Gait 5 | weight = 100 6 | threshold = 0.05 7 | termination_height = 0.85 8 | min_velocity = 1.0 9 | } 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.1 13 | measure_type = Wang2012 14 | use_cost_of_transport = 1 15 | } 16 | CompositeMeasure { 17 | name = DofLimits 18 | symmetric = 1 19 | DofMeasure { 20 | weight = 0.1 21 | dof = ankle_angle 22 | position { min = -60 max = 60 squared_penalty = 1 } 23 | } 24 | DofMeasure { 25 | weight = 0.01 26 | threshold = 5 27 | dof = knee_angle 28 | force { min = 0 max = 0 abs_penalty = 1 } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /scenarios/Tutorials/data/MeasureGait15.scone: -------------------------------------------------------------------------------- 1 | # Measure for gait, minimum speed = 1.5 m/s 2 | CompositeMeasure { 3 | GaitMeasure { 4 | name = Gait 5 | weight = 100 6 | threshold = 0.05 7 | termination_height = 0.85 8 | min_velocity = 1.5 9 | } 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.1 13 | measure_type = Wang2012 14 | use_cost_of_transport = 1 15 | } 16 | CompositeMeasure { 17 | name = DofLimits 18 | symmetric = 1 19 | DofMeasure { 20 | weight = 0.1 21 | dof = ankle_angle 22 | position { min = -60 max = 60 squared_penalty = 1 } 23 | } 24 | DofMeasure { 25 | weight = 0.01 26 | threshold = 5 27 | dof = knee_angle 28 | force { min = 0 max = 0 abs_penalty = 1 } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /scenarios/Tutorials/data/MeasureGait20.scone: -------------------------------------------------------------------------------- 1 | # Measure for gait, minimum speed = 1.0 m/s 2 | CompositeMeasure { 3 | GaitMeasure { 4 | name = Gait 5 | weight = 100 6 | threshold = 0.05 7 | termination_height = 0.85 8 | min_velocity = 2.0 9 | } 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.1 13 | measure_type = Wang2012 14 | use_cost_of_transport = 1 15 | } 16 | CompositeMeasure { 17 | name = DofLimits 18 | symmetric = 1 19 | DofMeasure { 20 | weight = 0.1 21 | dof = ankle_angle 22 | position { min = -60 max = 60 squared_penalty = 1 } 23 | } 24 | DofMeasure { 25 | weight = 0.01 26 | threshold = 5 27 | dof = knee_angle 28 | force { min = 0 max = 0 abs_penalty = 1 } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/data/MeasureGait05.scone: -------------------------------------------------------------------------------- 1 | # Measure for gait, minimum speed = 1.0 m/s 2 | CompositeMeasure { 3 | GaitMeasure { 4 | name = Gait 5 | weight = 100 6 | threshold = 0.05 7 | termination_height = 0.85 8 | min_velocity = 0.5 9 | } 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.1 13 | measure_type = Wang2012 14 | use_cost_of_transport = 1 15 | } 16 | CompositeMeasure { 17 | name = DofLimits 18 | symmetric = 1 19 | DofMeasure { 20 | weight = 0.1 21 | dof = ankle_angle 22 | position { min = -60 max = 60 squared_penalty = 1 } 23 | } 24 | DofMeasure { 25 | weight = 0.01 26 | threshold = 5 27 | dof = knee_angle 28 | force { min = 0 max = 0 abs_penalty = 1 } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/data/MeasureGait10.scone: -------------------------------------------------------------------------------- 1 | # Measure for gait, minimum speed = 1.0 m/s 2 | CompositeMeasure { 3 | GaitMeasure { 4 | name = Gait 5 | weight = 100 6 | threshold = 0.05 7 | termination_height = 0.85 8 | min_velocity = 1.0 9 | } 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.1 13 | measure_type = Wang2012 14 | use_cost_of_transport = 1 15 | } 16 | CompositeMeasure { 17 | name = DofLimits 18 | symmetric = 1 19 | DofMeasure { 20 | weight = 0.1 21 | dof = ankle_angle 22 | position { min = -60 max = 60 squared_penalty = 1 } 23 | } 24 | DofMeasure { 25 | weight = 0.01 26 | threshold = 5 27 | dof = knee_angle 28 | force { min = 0 max = 0 abs_penalty = 1 } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/Benchmark.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "platform.h" 4 | #include "xo/time/time.h" 5 | #include "PropNode.h" 6 | #include "xo/filesystem/path.h" 7 | #include "types.h" 8 | 9 | namespace scone 10 | { 11 | /// Creates and evaluates SimulationObjective. Logs unused properties. 12 | SCONE_API void BenchmarkScenario( const PropNode& scenario_pn, const xo::path& file, size_t evals ); 13 | 14 | struct SCONE_API Benchmark { 15 | String name_; 16 | xo::time time_; 17 | xo::time baseline_; 18 | double std_; 19 | 20 | xo::time diff() const { return time_ - baseline_; } 21 | double diff_perc() const { return 100 * ( diff() / baseline_ ); } 22 | double diff_std() const { return diff().nanosecondsd() / std_; } 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/Objective.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Objective.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "Objective.h" 10 | #include "scone/core/Exception.h" 11 | 12 | namespace scone 13 | { 14 | Objective::Objective( const PropNode& props, const path& find_file_folder ) : 15 | HasSignature( props ), 16 | external_resource_dir_( find_file_folder ) 17 | { 18 | if ( auto p = props.try_get_child( "Parameters" ) ) 19 | { 20 | for ( auto& par : *p ) 21 | info().add( ParInfo( par.first, par.second ) ); 22 | } 23 | } 24 | 25 | Objective::~Objective() 26 | {} 27 | } 28 | -------------------------------------------------------------------------------- /scenarios/Examples/Gait - H0914 - Hyfydy.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | min_progress = 1e-4 4 | 5 | SimulationObjective { 6 | max_duration = 10 7 | 8 | # Model used in simulation 9 | ModelHyfydy { 10 | model_file = data/H0914.hfd 11 | signature_postfix = HFD 12 | 13 | # Optimize initial state parameters 14 | state_init_file = data/InitStateGait10.zml 15 | initial_state_offset = 0~0.01<-0.5,0.5> 16 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 17 | 18 | << data/HfdConfigM2012Planar.zml >> 19 | } 20 | 21 | # Controller for gait, based on [Geyer & Herr 2010] 22 | << data/ControllerGH2010.scone >> 23 | 24 | # Measure for gait 25 | << data/MeasureGait10Grf.scone >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /scenarios/Examples/Gait - H0918 - Hyfydy.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | min_progress = 1e-4 4 | 5 | SimulationObjective { 6 | max_duration = 10 7 | 8 | # Model used in simulation 9 | ModelHyfydy { 10 | model_file = data/H0918.hfd 11 | signature_postfix = HFD 12 | 13 | # Optimize initial state parameters 14 | state_init_file = data/InitStateGait10.zml 15 | initial_state_offset = 0~0.01<-0.5,0.5> 16 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 17 | 18 | << data/HfdConfigM2012Planar.zml >> 19 | } 20 | 21 | # Controller for gait, based on [Geyer & Herr 2010] 22 | << data/ControllerGH2010M18.scone >> 23 | 24 | # Measure for gait 25 | << data/MeasureGait10Grf.scone >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/sconestudio/OptimizerTask.cpp: -------------------------------------------------------------------------------- 1 | #include "OptimizerTask.h" 2 | 3 | #include "StudioSettings.h" 4 | #include "OptimizerTaskExternal.h" 5 | #include "OptimizerTaskThreaded.h" 6 | 7 | namespace scone 8 | { 9 | OptimizerTask::OptimizerTask( const QString& scenario, const QStringList& options ) : 10 | scenario_file_( scenario ), 11 | options_( options ) 12 | {} 13 | 14 | OptimizerTask::~OptimizerTask() 15 | {} 16 | 17 | u_ptr createOptimizerTask( const QString& scenario, const QStringList& args ) 18 | { 19 | if ( GetStudioSetting( "optimization.use_external_process" ) ) 20 | return std::make_unique( scenario, args ); 21 | else return std::make_unique( scenario, args ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /contrib/lua-5.3.5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_path( LUA_INCLUDE_DIR NAMES lapi.h PATHS ${CMAKE_CURRENT_SOURCE_DIR}/src ) 2 | 3 | set ( SRC_CORE src/lapi.c src/lcode.c src/lctype.c src/ldebug.c src/ldo.c src/ldump.c src/lfunc.c src/lgc.c src/llex.c 4 | src/lmem.c src/lobject.c src/lopcodes.c src/lparser.c src/lstate.c src/lstring.c src/ltable.c 5 | src/ltm.c src/lundump.c src/lvm.c src/lzio.c ) 6 | set ( SRC_LIB src/lauxlib.c src/lbaselib.c src/lbitlib.c src/lcorolib.c src/ldblib.c src/liolib.c 7 | src/lmathlib.c src/loslib.c src/lstrlib.c src/ltablib.c src/lutf8lib.c src/loadlib.c src/linit.c ) 8 | 9 | # build static lua library 10 | add_library ( liblua ${SRC_CORE} ${SRC_LIB} ) 11 | set_target_properties ( liblua PROPERTIES OUTPUT_NAME lua POSITION_INDEPENDENT_CODE True ) 12 | -------------------------------------------------------------------------------- /src/sconestudio/OptimizerTaskThreaded.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OptimizerTask.h" 4 | #include 5 | 6 | namespace scone 7 | { 8 | class OptimizerTaskThreaded : public OptimizerTask 9 | { 10 | public: 11 | OptimizerTaskThreaded( const QString& scenario, const QStringList& options = QStringList() ); 12 | virtual ~OptimizerTaskThreaded(); 13 | 14 | virtual bool interrupt() override; 15 | virtual void finish() override; 16 | 17 | std::deque getMessages() override; 18 | 19 | protected: 20 | void thread_func(); 21 | 22 | PropNode scenario_pn_; 23 | OptimizerUP optimizer_; 24 | std::atomic_bool has_optimizer_; // required because unique_ptr can't be atomic 25 | std::thread thread_; 26 | std::atomic_bool active_; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 6a - Script - High Jump.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 2 6 | 7 | # Model used in simulation 8 | ModelOpenSim3 { 9 | model_file = data/Human0914.osim 10 | fixed_control_step_size = 0.005 # higher step sizes give better performance 11 | } 12 | 13 | # Controller based on lua script 14 | ScriptController { 15 | script_file = "data/ScriptControllerJump.lua" 16 | } 17 | 18 | # Measure based on lua script 19 | ScriptMeasure { 20 | minimize = 0 # let the optimizer know we want to maximize this measure 21 | target_body = "toes_r" # this parameter will be used in the script 22 | script_file = "data/ScriptMeasureJump.lua" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/deprecated/simbody_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** simbody_tools.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | 13 | #include 14 | 15 | #include "scone/core/math.h" 16 | #include "scone/core/Vec3.h" 17 | 18 | namespace scone 19 | { 20 | inline Vec3 from_osim( const SimTK::Vec3& vec ) { return Vec3( vec[ 0 ], vec[ 1 ], vec[ 2 ] ); } 21 | inline Quat from_osim( const SimTK::Quaternion& q ) { return Quat( q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] ); } 22 | 23 | inline SimTK::Vec3 to_osim( const Vec3& v ) { return SimTK::Vec3( v.x, v.y, v.z ); } 24 | } 25 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/Event.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Event.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | #include "platform.h" 11 | #include 12 | #include "Storage.h" 13 | #include "types.h" 14 | 15 | namespace scone 16 | { 17 | struct Event 18 | { 19 | enum Type 20 | { 21 | NoEvent, 22 | LeftHeelStrike, 23 | RightHeelStrike, 24 | LeftToeOff, 25 | RightToeOff 26 | }; 27 | 28 | TimeInSeconds time; 29 | Type event; 30 | }; 31 | 32 | SCONE_API std::vector< Event > DetectGrfEvents( const Storage< Real, TimeInSeconds>& s, double threshold = 0.0001, double duration_filter = 0.2 ); 33 | } 34 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/Simulation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Simulation.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "Simulation.h" 10 | 11 | namespace scone 12 | { 13 | Simulation::Simulation( const PropNode& props ) : 14 | max_simulation_time( 0.0 ), 15 | integration_accuracy( 0.0 ) 16 | { 17 | INIT_PROP( props, integration_accuracy, 0.00001 ); 18 | INIT_PROP( props, max_simulation_time, 10000.0 ); 19 | } 20 | 21 | Simulation::~Simulation() 22 | { 23 | 24 | } 25 | 26 | Model& Simulation::GetModel( size_t idx ) 27 | { 28 | SCONE_ASSERT( idx < m_Models.size() ); 29 | return *m_Models[ idx ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/deprecated/SimulationOpenSim4.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** SimulationOpenSim4.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "SimulationOpenSim4.h" 10 | #include "scone/core/Exception.h" 11 | #include "ModelOpenSim4.h" 12 | 13 | namespace scone 14 | { 15 | SimulationOpenSim4::SimulationOpenSim4( const PropNode& props ) : 16 | Simulation( props ) 17 | { 18 | } 19 | 20 | void SimulationOpenSim4::AdvanceSimulationTo( double time ) 21 | { 22 | for ( auto iter = m_Models.begin(); iter != m_Models.end(); ++iter ) 23 | dynamic_cast( **iter ).AdvanceSimulationTo( time ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/deprecated/MetaReflexParams.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/core/PropNode.h" 4 | #include "scone/core/Angle.h" 5 | 6 | #include "scone/optimization/Params.h" 7 | #include "scone/model/Model.h" 8 | 9 | namespace scone 10 | { 11 | struct MetaReflexParams 12 | { 13 | MetaReflexParams() : ref_pos( 0 ), length_gain( 0 ), force_gain( 0 ), constant( 0 ), stiffness( 0 ), symmetry( 0 ) {} 14 | MetaReflexParams( const PropNode& props, Params& par, Model& model, const String& parname_postfix = "" ); 15 | void Init( const PropNode& props, Params& par, Model& model, const String& parname_postfix = "" ); 16 | 17 | Degree ref_pos; 18 | Real length_gain; 19 | Real force_gain; 20 | Real constant; 21 | Real symmetry; 22 | Real stiffness; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 2a - Standing High Jump.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 2 6 | 7 | # Model used in simulation 8 | ModelOpenSim3 { 9 | model_file = data/Human0914.osim 10 | } 11 | 12 | # Controller for the Model 13 | FeedForwardController { 14 | symmetric = 1 15 | 16 | # Function for feed-forward pattern 17 | PieceWiseConstant { 18 | control_points = 2 19 | control_point_y = 0.3~0.01<0,1> # Initial y value of control points 20 | control_point_dt = 0.2~0.01<0.001,1> # Initial delta time between control points 21 | } 22 | } 23 | 24 | # Fitness measure for jumping 25 | JumpMeasure { 26 | termination_height = 0.75 27 | prepare_time = 0.2 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 3b - Standing Balance - Motor Noise.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 30 6 | 7 | # Model used in simulation 8 | ModelOpenSim3 { 9 | model_file = data/Human0916.osim 10 | state_init_file = data/InitStateStand.sto 11 | } 12 | 13 | # CompositeController with multiple sub-controllers 14 | CompositeController { 15 | 16 | # Controller for reflex based balance (different file) 17 | << data/ControllerReflexBalance.scone >> 18 | 19 | # Motor noise controller 20 | NoiseController { 21 | base_noise = 0.01 22 | proportional_noise = 0.1 23 | } 24 | } 25 | 26 | # Measure for standing balance (different file) 27 | << data/MeasureBalance.scone >> 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /CMakeModules/PrecompiledHeaders.cmake: -------------------------------------------------------------------------------- 1 | macro(use_precompiled_headers SOURCE_FILES STD_AFX_H STD_AFX_CPP PCH_SIZE) 2 | if(MSVC) 3 | get_filename_component(STD_AFX_H_NAME ${STD_AFX_H} NAME) 4 | set(PCH_FILE "$(IntermediateOutputPath)stdafx.pch") 5 | set_source_files_properties( ${${SOURCE_FILES}} PROPERTIES COMPILE_FLAGS "/Yu\"${STD_AFX_H}\" /FI\"${STD_AFX_H}\" /Fp\"${PCH_FILE}\"" OBJECT_DEPENDS "${PCH_FILE}" ) 6 | set_source_files_properties( ${STD_AFX_CPP} PROPERTIES COMPILE_FLAGS "/Yc\"${STD_AFX_H_NAME}\" /Fp\"${PCH_FILE}\"" OBJECT_OUTPUTS "${PCH_FILE}" ) 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Zm${PCH_SIZE}" ) 8 | set(PRECOMPILED_HEADER_FILES ${STD_AFX_H} ${STD_AFX_CPP} ) 9 | list( APPEND ${SOURCE_FILES} ${PRECOMPILED_HEADER_FILES} ) 10 | endif(MSVC) 11 | endmacro(use_precompiled_headers) 12 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/Function.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Function.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/core/Exception.h" 12 | #include "scone/core/platform.h" 13 | #include "types.h" 14 | 15 | namespace scone 16 | { 17 | /// Abstract parameterizable function, see subclasses for actual implementations. 18 | class SCONE_API Function 19 | { 20 | public: 21 | Function() { }; 22 | virtual ~Function() { }; 23 | 24 | virtual Real GetValue( Real x ) = 0; 25 | virtual Real GetDerivativeValue( Real x ) { SCONE_THROW_NOT_IMPLEMENTED }; 26 | virtual String GetSignature() { return "UnknownFunction"; } 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/Location.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Location.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "Location.h" 10 | #include "Side.h" 11 | 12 | namespace scone 13 | { 14 | String Location::GetSidedName( const String& name ) const 15 | { 16 | auto name_side = GetSideFromName( name ); 17 | auto name_no_side = GetNameNoSide( name ); 18 | 19 | if ( name_side == NoSide ) // no side in name, add location side 20 | return name_no_side + GetSideName( side_ ); 21 | else if ( name_side == OppositeSide ) 22 | return name_no_side + GetSideName( GetOppositeSide( side_ ) ); 23 | else return name; // keep original side 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/sconestudio/ParTableModel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "spot/spot_types.h" 5 | 6 | class ParTableModel : public QAbstractTableModel 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | ParTableModel( QObject* parent = nullptr ) : QAbstractTableModel( parent ), info_( nullptr ) {} 12 | void setObjectiveInfo( const spot::objective_info* info ); 13 | int rowCount( const QModelIndex& parent = QModelIndex() ) const override; 14 | int columnCount( const QModelIndex& parent = QModelIndex() ) const override; 15 | QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; 16 | QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; 17 | 18 | private: 19 | const spot::objective_info* info_; 20 | }; 21 | -------------------------------------------------------------------------------- /tools/mac_4_create-dmg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Bundles the SconeStudio.app/ directory created by the dirtree step into a 4 | # single `.dmg` file that users can download + install easily 5 | # 6 | # Requires `create-dmg` to bundle the dir up 7 | 8 | set -xeuo pipefail 9 | source ./tools/build_config 10 | 11 | # create-dmg fails if target already exists 12 | rm -f "${SCONE_BUILD_DIR}/SconeStudio.dmg" 13 | 14 | ./create-dmg/create-dmg \ 15 | --volicon "${SCONE_BUILD_DIR}/SconeStudio.app/Contents/MacOS/resources/ui/scone_logo_256x256.icns" \ 16 | --volname "sconestudio installer" \ 17 | --icon "${SCONE_BUILD_DIR}/SconeStudio.app" 0 0 \ 18 | --icon-size 100 \ 19 | --app-drop-link 200 0 \ 20 | "${SCONE_BUILD_DIR}/SconeStudio.dmg" \ 21 | "${SCONE_BUILD_DIR}/SconeStudio.app" 22 | 23 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 2b - Standing High Jump - Polynomial.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 2 6 | 7 | # Model used in simulation 8 | ModelOpenSim3 { 9 | model_file = data/Human0914.osim 10 | } 11 | 12 | # Controller for the Model 13 | FeedForwardController { 14 | symmetric = 1 15 | 16 | # 2nd degree polynomial ax^2 + bx + c 17 | Polynomial { 18 | degree = 2 19 | coefficient0 = 0.3~0.01<0,1> # initial value for c 20 | coefficient1 = 0~0.1<-10,10> # initial value for b 21 | coefficient2 = 0~0.1<-10,10> # initial value for a 22 | } 23 | } 24 | 25 | # Fitness measure for jumping 26 | JumpMeasure { 27 | termination_height = 0.75 28 | prepare_time = 0.2 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/TimedValue.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** TimedValue.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | namespace scone 12 | { 13 | template< typename T > 14 | class TimedValue 15 | { 16 | public: 17 | TimedValue( const T& value = T(0), TimeInSeconds time = 0.0 ) : m_Value( value ), m_Time( time ) { }; 18 | operator const T&() const { return m_Value; } 19 | void Set( const T& value, TimeInSeconds time ) { if ( value != m_Value ) { m_Value = value; m_Time = time; } } 20 | TimeInSeconds GetTime() { return m_Time; } 21 | 22 | private: 23 | T m_Value; 24 | TimeInSeconds m_Time; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve SCONE 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. Windows 10] 28 | - SCONE Version [e.g. 1.4.0] 29 | 30 | **Additional context** 31 | Add any other context about the problem here. 32 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/activation_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** activation_functions.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include "scone/core/platform.h" 14 | #include "scone/core/types.h" 15 | 16 | namespace scone 17 | { 18 | using activation_func_t = std::function< double( double ) >; 19 | 20 | activation_func_t GetActivationFunction( const String& name ); 21 | double rectifier( double input ); 22 | double soft_plus( double input ); 23 | double linear( double input ); 24 | double gaussian( double input ); 25 | double gaussian_width( double input, double width ); 26 | } 27 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/HasExternalResources.cpp: -------------------------------------------------------------------------------- 1 | #include "HasExternalResources.h" 2 | 3 | #include "xo/container/container_tools.h" 4 | 5 | namespace scone 6 | { 7 | HasExternalResources::HasExternalResources() {} 8 | 9 | HasExternalResources::~HasExternalResources() {} 10 | 11 | const std::vector& HasExternalResources::GetExternalResources() const 12 | { 13 | return external_resources_; 14 | } 15 | 16 | void HasExternalResources::AddExternalResource( const xo::path& p ) const 17 | { 18 | if ( find( external_resources_, p ) == external_resources_.end() ) 19 | external_resources_.emplace_back( p ); 20 | } 21 | 22 | void HasExternalResources::AddExternalResources( const HasExternalResources& other ) 23 | { 24 | xo::append( external_resources_, other.external_resources_ ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/SineWave.cpp: -------------------------------------------------------------------------------- 1 | #include "SineWave.h" 2 | 3 | #include "spot/par_tools.h" 4 | #include "xo/numerical/constants.h" 5 | #include 6 | 7 | namespace scone 8 | { 9 | SineWave::SineWave( const PropNode& pn, Params& par ) : 10 | INIT_PAR_MEMBER( pn, par, amplitude_, 0.5 ), 11 | INIT_PAR_MEMBER( pn, par, frequency_, 1.0 ), 12 | INIT_PAR_MEMBER( pn, par, phase_, 0.0 ), 13 | INIT_PAR_MEMBER( pn, par, offset_, 0.5 ) 14 | {} 15 | 16 | Real SineWave::GetValue( Real x ) 17 | { 18 | return amplitude_ * std::sin( xo::constantsd::two_pi() * frequency_ * x + phase_ ) + offset_; 19 | } 20 | 21 | Real SineWave::GetDerivativeValue( Real x ) 22 | { 23 | return -xo::constantsd::two_pi() * frequency_ * amplitude_ * std::cos( xo::constantsd::two_pi() * frequency_ * x + phase_ ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /resources/filetemplates/controllerscript.lua: -------------------------------------------------------------------------------- 1 | function init( model, par, side ) 2 | -- This function is called at the start of the simulation 3 | -- 'model' can be used to initialize the desired actuators (see LuaModel) 4 | -- 'par' can be used to define parameters for optimization (see LuaPar) 5 | -- 'side' denotes if the controller is for a specific side (-1 = left, 0 = any, 1 = right) 6 | end 7 | 8 | function update( model ) 9 | -- This function is called at each simulation timestep 10 | -- Use it to update the actuator inputs 11 | return false -- change to 'return true' to terminate the simulation early 12 | end 13 | 14 | function store_data( current_frame ) 15 | -- This function is called at each simulation timestep 16 | -- 'current_frame' can be used to store values for analysis (see LuaFrame) 17 | end 18 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/Jump - CustomParameters.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | init_file = "data/Jump - Custom Parameters.par" 4 | 5 | SimulationObjective { 6 | Parameters { 7 | controller_dt = 0.2~0.01<0,1> 8 | } 9 | 10 | max_duration = 2 11 | 12 | # Model used in simulation 13 | OpenSimModel { 14 | model_file = data/Human0914.osim 15 | } 16 | 17 | # Controller for the Model 18 | FeedForwardController { 19 | symmetric = 1 20 | 21 | # Function for feed-forward pattern 22 | PieceWiseConstant { 23 | control_points = 2 24 | control_point_y = 0.3~0.01<0,1> 25 | control_point_dt = controller_dt 26 | } 27 | } 28 | 29 | # Fitness measure for jumping 30 | JumpMeasure { 31 | termination_height = 0.75 32 | prepare_time = 0.2 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/data/Jump - Custom Parameters.par: -------------------------------------------------------------------------------- 1 | controller_dt 0.17600799 0.14548815 0.038289602 2 | hamstrings.Y0 0.28875825 0.32134279 0.043440237 3 | hamstrings.Y1 0.5592188 0.56434977 0.042988075 4 | glut_max.Y0 0.11355926 0.17234253 0.046031412 5 | glut_max.Y1 0.36097355 0.2916807 0.047984595 6 | iliopsoas.Y0 0.24375571 0.24430039 0.040737059 7 | iliopsoas.Y1 0.081968243 0.17223735 0.044228335 8 | vasti.Y0 0.47339868 0.47222325 0.044585153 9 | vasti.Y1 0.84966457 0.90380697 0.04511418 10 | gastroc.Y0 0.16593751 0.17781082 0.043243478 11 | gastroc.Y1 0.8857326 0.8773998 0.048030785 12 | soleus.Y0 0.14308158 0.18913937 0.043241829 13 | soleus.Y1 0.83728124 0.74019007 0.047953962 14 | tib_ant.Y0 0.41403508 0.40995012 0.044181411 15 | tib_ant.Y1 0.042107656 0.045584236 0.040758898 16 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/HasExternalResources.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** HasExternalResources.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include 13 | #include "xo/filesystem/path.h" 14 | 15 | namespace scone 16 | { 17 | class SCONE_API HasExternalResources 18 | { 19 | public: 20 | HasExternalResources(); 21 | virtual ~HasExternalResources(); 22 | const std::vector< xo::path >& GetExternalResources() const; 23 | void AddExternalResource( const xo::path& p ) const; 24 | void AddExternalResources( const HasExternalResources& other ); 25 | 26 | protected: 27 | mutable std::vector< xo::path > external_resources_; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | AlignTrailingComments: 'false' 3 | BreakBeforeBraces: Allman 4 | IndentWidth: '4' 5 | Language: Cpp 6 | NamespaceIndentation: Inner 7 | PointerAlignment: Left 8 | SpaceAfterLogicalNot: 'true' 9 | SpaceAfterTemplateKeyword: 'true' 10 | SpaceBeforeAssignmentOperators: 'true' 11 | SpaceBeforeCpp11BracedList: 'true' 12 | SpaceBeforeCtorInitializerColon: 'true' 13 | SpaceBeforeInheritanceColon: 'true' 14 | SpaceBeforeParens: ControlStatements 15 | SpaceBeforeRangeBasedForLoopColon: 'true' 16 | SpaceInEmptyParentheses: 'true' 17 | SpacesInAngles: 'true' 18 | SpacesInCStyleCastParentheses: 'true' 19 | SpacesInContainerLiterals: 'true' 20 | SpacesInParentheses: 'true' 21 | SpacesInSquareBrackets: 'true' 22 | FixNamespaceComments: true 23 | TabWidth: '4' 24 | UseTab: Always 25 | NamespaceIndentation: All 26 | AccessModifierOffset: -4 27 | ... 28 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/config/ac_cxx_namespaces.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_CXX_NAMESPACES 2 | dnl 3 | dnl If the compiler can prevent names clashes using namespaces, define 4 | dnl HAVE_NAMESPACES. 5 | dnl 6 | dnl @version $Id: ac_cxx_namespaces.m4,v 1.1.1.1 2003/03/19 02:40:00 mes5k Exp $ 7 | dnl @author Luc Maisonobe 8 | dnl 9 | AC_DEFUN([AC_CXX_NAMESPACES], 10 | [AC_CACHE_CHECK(whether the compiler implements namespaces, 11 | ac_cv_cxx_namespaces, 12 | [AC_LANG_SAVE 13 | AC_LANG_CPLUSPLUS 14 | AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}], 15 | [using namespace Outer::Inner; return i;], 16 | ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no) 17 | AC_LANG_RESTORE 18 | ]) 19 | if test "$ac_cv_cxx_namespaces" = yes; then 20 | AC_DEFINE(HAVE_NAMESPACES,1,[define to 1 if the compiler implements namespaces]) 21 | fi 22 | ]) 23 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/Jump - SequentialController.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 2 6 | 7 | # Model used in simulation 8 | OpenSimModel { 9 | model_file = data/Human0914.osim 10 | } 11 | 12 | # Controller for the Model 13 | SequentialController { 14 | transition_intervals = [ ~0.15<0.1,0.5> ] 15 | 16 | FeedForwardController { 17 | name = Prepare 18 | symmetric = 1 19 | Polynomial { degree = 0 coefficient0 = 0.2~0.01<0,1> } 20 | } 21 | 22 | FeedForwardController { 23 | name = Jump 24 | symmetric = 1 25 | Polynomial { degree = 0 coefficient0 = 0.5~0.1<0,1> } 26 | } 27 | } 28 | # Fitness measure for jumping 29 | JumpMeasure { 30 | termination_height = 0.75 31 | prepare_time = 0.2 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/Actuator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Actuator.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "Actuator.h" 10 | #include 11 | 12 | namespace scone 13 | { 14 | Actuator::Actuator() : 15 | m_ActuatorControlValue( 0.0 ) 16 | {} 17 | 18 | Actuator::~Actuator() 19 | {} 20 | 21 | void Actuator::ClearInput() 22 | { 23 | m_ActuatorControlValue = 0.0; 24 | } 25 | 26 | void Actuator::StoreData( Storage< Real >::Frame& frame, const StoreDataFlags& flags ) const 27 | { 28 | if ( flags( StoreDataTypes::ActuatorInput ) ) 29 | frame[ GetName() + ".input" ] = GetInput(); 30 | } 31 | 32 | PropNode Actuator::GetInfo() const 33 | { 34 | return PropNode(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /resources/filetemplates/measurescript.lua: -------------------------------------------------------------------------------- 1 | function init( model ) 2 | -- This function is called at the start of the simulation 3 | -- 'model' can be used to initialize the measure parameters (see LuaModel) 4 | end 5 | 6 | function update( model ) 7 | -- This function is called at each simulation timestep 8 | -- Use it to update the internal variables of the measure (if needed) 9 | return false -- change to 'return true' to terminate the simulation early 10 | end 11 | 12 | function result( model ) 13 | -- This function is called at the end of the simulation 14 | -- It should return the result of the measure 15 | return 0.0 16 | end 17 | 18 | function store_data( current_frame ) 19 | -- This function is called at each simulation timestep 20 | -- 'current_frame' can be used to store values for analysis (see LuaFrame) 21 | end 22 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/system_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** system_tools.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "xo/filesystem/path.h" 13 | 14 | namespace scone 15 | { 16 | using xo::path; 17 | 18 | enum SconeFolder { SCONE_ROOT_FOLDER, SCONE_RESULTS_FOLDER, SCONE_MODEL_FOLDER, SCONE_SCENARIO_FOLDER, SCONE_RESOURCE_FOLDER, SCONE_GEOMETRY_FOLDER, SCONE_UI_RESOURCE_FOLDER }; 19 | SCONE_API path GetSettingsFolder(); 20 | SCONE_API const path& GetInstallFolder(); 21 | SCONE_API path GetDataFolder(); 22 | SCONE_API path GetApplicationFolder(); 23 | SCONE_API path GetFolder( SconeFolder folder ); 24 | SCONE_API path FindFile( const path& filename ); 25 | } 26 | -------------------------------------------------------------------------------- /src/sconestudio/StudioSettings.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** StudioSettings.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/core/platform.h" 12 | #include "xo/system/settings.h" 13 | #include "scone/core/types.h" 14 | #include "scone/core/Exception.h" 15 | 16 | namespace scone 17 | { 18 | class StudioSettings : public xo::settings 19 | { 20 | public: 21 | StudioSettings(); 22 | }; 23 | 24 | xo::settings& GetStudioSettings(); 25 | template< typename T > T GetStudioSetting( const String& key ) { 26 | try { return GetStudioSettings().get< T >( key ); } 27 | catch ( const std::exception& e ) { SCONE_ERROR( "Could not read setting \"" + key + "\" (" + e.what() + ")" ); } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/sconestudio/OptimizerTask.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "scone/core/Exception.h" 7 | #include "scone/core/PropNode.h" 8 | #include "xo/system/error_code.h" 9 | #include "xo/filesystem/path.h" 10 | #include "xo/utility/optional.h" 11 | #include "scone/core/types.h" 12 | #include 13 | 14 | namespace scone 15 | { 16 | class OptimizerTask 17 | { 18 | public: 19 | OptimizerTask( const QString& scenario, const QStringList& args ); 20 | virtual ~OptimizerTask(); 21 | 22 | virtual bool interrupt() = 0; 23 | virtual void finish() = 0; 24 | virtual std::deque getMessages() = 0; 25 | 26 | const QString scenario_file_; 27 | const QStringList options_; 28 | }; 29 | 30 | u_ptr createOptimizerTask( const QString& scenario, const QStringList& args = QStringList() ); 31 | } 32 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/TestObjective.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** TestObjective.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Objective.h" 12 | 13 | namespace scone 14 | { 15 | /// Objective used for testing, evaluates a multi-dimensional Schwefel function. 16 | class SCONE_API TestObjective : public Objective 17 | { 18 | public: 19 | TestObjective( const PropNode& pn, const path& find_file_folder ); 20 | virtual ~TestObjective() {} 21 | 22 | /// Dimension of the objective function 23 | size_t dim_; 24 | 25 | virtual fitness_t evaluate( const SearchPoint& point ) const override; 26 | 27 | protected: 28 | virtual String GetClassSignature() const override; 29 | 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /src/test/main.cpp: -------------------------------------------------------------------------------- 1 | #include "scone/core/Log.h" 2 | #include "scone/core/system_tools.h" 3 | #include "Test.h" 4 | #include "scone/core/string_tools.h" 5 | #include "xo/system/system_tools.h" 6 | #include 7 | #include "xo/time/timer.h" 8 | 9 | using std::cout; 10 | using std::endl; 11 | using namespace scone; 12 | 13 | int main( int argc, const char* argv[] ) 14 | { 15 | //Ang< Degrees > a = Ang< Degrees >( 180.0 ); 16 | //Ang< Radians > b = a; 17 | 18 | try 19 | { 20 | //DofAxisTest(); 21 | cout << GetDateTimeAsString() << endl; 22 | cout << GetDateTimeExactAsString() << endl; 23 | #if defined ( _MSC_VER ) 24 | cout << _MSC_VER << endl; 25 | #endif 26 | } 27 | catch ( std::exception& e ) 28 | { 29 | log::Critical( e.what() ); 30 | } 31 | 32 | #ifdef _DEBUG 33 | xo::wait_for_key(); 34 | #endif 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /scenarios/Examples/data/MeasureGait10Grf.scone: -------------------------------------------------------------------------------- 1 | # Measure for gait, minimum speed = 1.0 m/s 2 | CompositeMeasure { 3 | GaitMeasure { 4 | name = Gait 5 | weight = 100 6 | threshold = 0.05 7 | termination_height = 0.85 8 | min_velocity = 1.0 9 | } 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.1 13 | measure_type = Wang2012 14 | use_cost_of_transport = 1 15 | } 16 | CompositeMeasure { 17 | name = DofLimits 18 | symmetric = 1 19 | DofMeasure { 20 | weight = 0.1 21 | dof = ankle_angle 22 | position { min = -60 max = 60 squared_penalty = 1 } 23 | } 24 | DofMeasure { 25 | weight = 0.01 26 | threshold = 5 27 | dof = knee_angle 28 | force { min = 0 max = 0 abs_penalty = 1 } 29 | } 30 | } 31 | ReactionForceMeasure { 32 | name = GRF 33 | start_time = 1 34 | weight = 10 35 | max = 1.4 36 | abs_penalty = 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /scenarios/Examples/data/MeasureGait10Grf15.scone: -------------------------------------------------------------------------------- 1 | # Measure for gait, minimum speed = 1.0 m/s 2 | CompositeMeasure { 3 | GaitMeasure { 4 | name = Gait 5 | weight = 100 6 | threshold = 0.05 7 | termination_height = 0.85 8 | min_velocity = 1.0 9 | } 10 | EffortMeasure { 11 | name = Effort 12 | weight = 0.1 13 | measure_type = Wang2012 14 | use_cost_of_transport = 1 15 | } 16 | CompositeMeasure { 17 | name = DofLimits 18 | symmetric = 1 19 | DofMeasure { 20 | weight = 0.1 21 | dof = ankle_angle 22 | position { min = -60 max = 60 squared_penalty = 1 } 23 | } 24 | DofMeasure { 25 | weight = 0.01 26 | threshold = 5 27 | dof = knee_angle 28 | force { min = 0 max = 0 abs_penalty = 1 } 29 | } 30 | } 31 | ReactionForceMeasure { 32 | name = GRF 33 | start_time = 1 34 | weight = 10 35 | max = 1.5 36 | abs_penalty = 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/configure.in: -------------------------------------------------------------------------------- 1 | AC_INIT(Makefile.am) 2 | #AC_PREREQ(2.50) 3 | AC_CONFIG_AUX_DIR(config) 4 | AM_CONFIG_HEADER(config/config.h) 5 | AM_INIT_AUTOMAKE(tclap,1.2.1) 6 | AC_PROG_CXX 7 | AC_CXX_HAVE_SSTREAM 8 | AC_CXX_HAVE_STRSTREAM 9 | AC_CXX_HAVE_LONG_LONG 10 | AC_CHECK_PROG(DOT,dot,YES,NO) 11 | AC_PROG_RANLIB 12 | AC_PROG_INSTALL 13 | BB_ENABLE_DOXYGEN 14 | 15 | HAVE_WARN_EFFECTIVE_CXX 16 | CXXFLAGS="$CXXFLAGS $WARN_EFFECTIVE_CXX" 17 | 18 | AM_CONDITIONAL([HAVE_GNU_COMPILERS], [test x$ac_cv_cxx_compiler_gnu = xyes]) 19 | 20 | AC_OUTPUT([ Makefile \ 21 | tclap.pc \ 22 | examples/Makefile \ 23 | include/Makefile \ 24 | include/tclap/Makefile \ 25 | config/Makefile \ 26 | docs/Makefile \ 27 | docs/Doxyfile \ 28 | msc/Makefile \ 29 | msc/examples/Makefile \ 30 | tests/Makefile], \ 31 | [chmod a+x $ac_top_srcdir/tests/*.sh]) 32 | -------------------------------------------------------------------------------- /scenarios/Examples/Standing High Jump - OpenSim3.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | max_generations = 500 4 | 5 | SimulationObjective { 6 | max_duration = 2 7 | 8 | # Model used in simulation 9 | ModelOpenSim3 { 10 | model_file = data/H0914M_osim3.osim 11 | signature_postfix = OS3 12 | fixed_control_step_size = 0.005 13 | } 14 | 15 | # Controller for the Model 16 | FeedForwardController { 17 | symmetric = 1 18 | 19 | # Function for feed-forward pattern 20 | PieceWiseConstant { 21 | control_points = 2 22 | control_point_y = 0.3~0.01<0,1> # Initial y value of control points 23 | control_point_dt = 0.2~0.01<0.001,1> # Initial delta time between control points 24 | } 25 | } 26 | 27 | # Fitness measure for jumping 28 | JumpMeasure { 29 | termination_height = 0.75 30 | prepare_time = 0.2 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /scenarios/Examples/Standing High Jump - OpenSim4.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | max_generations = 500 4 | 5 | SimulationObjective { 6 | max_duration = 2 7 | 8 | # Model used in simulation 9 | ModelOpenSim4 { 10 | model_file = data/H0914M_osim4.osim 11 | signature_postfix = OS4 12 | fixed_control_step_size = 0.005 13 | } 14 | 15 | # Controller for the Model 16 | FeedForwardController { 17 | symmetric = 1 18 | 19 | # Function for feed-forward pattern 20 | PieceWiseConstant { 21 | control_points = 2 22 | control_point_y = 0.3~0.01<0,1> # Initial y value of control points 23 | control_point_dt = 0.2~0.01<0.001,1> # Initial delta time between control points 24 | } 25 | } 26 | 27 | # Fitness measure for jumping 28 | JumpMeasure { 29 | termination_height = 0.75 30 | prepare_time = 0.2 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/config/ac_cxx_have_sstream.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_CXX_HAVE_SSTREAM 2 | dnl 3 | dnl If the C++ library has a working stringstream, define HAVE_SSTREAM. 4 | dnl 5 | dnl @author Ben Stanley 6 | dnl @version $Id: ac_cxx_have_sstream.m4,v 1.2 2006/02/22 02:10:28 zeekec Exp $ 7 | dnl 8 | AC_DEFUN([AC_CXX_HAVE_SSTREAM], 9 | [AC_REQUIRE([AC_CXX_NAMESPACES]) 10 | AC_LANG_SAVE 11 | AC_LANG_CPLUSPLUS 12 | AC_CHECK_HEADERS(sstream) 13 | AC_CACHE_CHECK([whether the STL defines stringstream], 14 | [ac_cv_cxx_have_sstream], 15 | [AC_TRY_COMPILE([#include 16 | #ifdef HAVE_NAMESPACES 17 | using namespace std; 18 | #endif],[stringstream message; message << "Hello"; return 0;], 19 | ac_cv_cxx_have_sstream=yes, ac_cv_cxx_have_sstream=no) 20 | ]) 21 | if test "$ac_cv_cxx_have_sstream" = yes; then 22 | AC_DEFINE(HAVE_SSTREAM,1,[define if the compiler has stringstream]) 23 | fi 24 | AC_LANG_RESTORE 25 | ]) 26 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 5b - Pathological Gait - Short Hamstrings.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 10 6 | signature_postfix = short_ham 7 | 8 | # Model used in simulation 9 | ModelOpenSim3 { 10 | model_file = data/Human0914.osim 11 | 12 | # Optimize initial state parameters 13 | state_init_file = data/InitStateGait10.sto 14 | initial_state_offset = 0~0.01<-0.5,0.5> 15 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 16 | 17 | # Override model properties 18 | Properties { 19 | hamstrings_l { optimal_fiber_length.factor = 0.75 } 20 | hamstrings_r { optimal_fiber_length.factor = 0.75 } 21 | } 22 | } 23 | 24 | # Controller for gait, based on [Geyer & Herr 2010] 25 | << data/ControllerGH2010.scone >> 26 | 27 | # Measure for gait 28 | << data/MeasureGait05.scone >> 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tools/unix_2c_build-opensim3: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | source ./tools/build_config 5 | 6 | # setup platform-specific build flags 7 | if [[ "$OSTYPE" == "darwin"* ]]; then 8 | PLATFORM_SPECIFIC_FLAGS=( 9 | -DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 10 | -DCMAKE_CXX_FLAGS="-stdlib=libc++" 11 | ) 12 | else 13 | PLATFORM_SPECIFIC_FLAGS=( 14 | ) 15 | fi 16 | 17 | echo "${0}: building opensim3" 18 | 19 | mkdir -p "${OPENSIM3_INSTALL_PATH}" 20 | mkdir -p opensim3-scone/build 21 | cd opensim3-scone/build 22 | cmake .. \ 23 | -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \ 24 | -DCMAKE_VERBOSE_MAKEFILE="${CMAKE_VERBOSE_MAKEFILE}" \ 25 | -DSIMBODY_HOME="${SIMBODY_INSTALL_PATH}" \ 26 | -DCMAKE_INSTALL_PREFIX="${OPENSIM3_INSTALL_PATH}" \ 27 | ${PLATFORM_SPECIFIC_FLAGS[@]} 28 | cmake --build . --parallel ${NUM_BUILD_JOBS} --target install 29 | cd - 30 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/PatternNeuron.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** PatternNeuron.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | #include "Neuron.h" 11 | 12 | namespace scone 13 | { 14 | struct PatternNeuron : public Neuron 15 | { 16 | public: 17 | PatternNeuron( const PropNode& pn, Params& par, NeuralController& nc, int index, bool mirrored ); 18 | virtual ~PatternNeuron() {} 19 | 20 | virtual activation_t GetOutput( double offset = 0.0 ) const override; 21 | virtual string GetName( bool mirrored ) const override { return name_ + ( mirrored_ ? "_r" : "_l" ); } 22 | 23 | bool mirrored_; 24 | 25 | private: 26 | const class Model& model_; 27 | double width_; 28 | double beta_; 29 | double t0_; 30 | double period_; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /src/sconestudio/file_tools.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "QDirIterator" 7 | 8 | namespace scone 9 | { 10 | std::pair extractGenBestFromParFile( const QFileInfo& parFile ) { 11 | auto s = parFile.completeBaseName().split( "_" ); 12 | if ( s.size() > 2 ) 13 | return { s[ 0 ].toInt(), s[ 2 ].toDouble() }; 14 | else return { -1, 0.0 }; 15 | } 16 | 17 | QFileInfo findBestPar( const QDir& dir ) 18 | { 19 | QFileInfo bestFile; 20 | int bestGen = -1; 21 | for ( QDirIterator it( dir ); it.hasNext(); it.next() ) 22 | { 23 | auto fi = it.fileInfo(); 24 | if ( fi.isFile() && fi.suffix() == "par" ) 25 | { 26 | auto [gen, best] = extractGenBestFromParFile( fi ); 27 | if ( gen > bestGen ) { 28 | bestFile = fi; 29 | bestGen = gen; 30 | } 31 | } 32 | } 33 | return bestFile; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/config/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | # $Id: mkinstalldirs,v 1.1 2003/04/03 18:13:41 mes5k Exp $ 8 | 9 | errstatus=0 10 | 11 | for file 12 | do 13 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 | shift 15 | 16 | pathcomp= 17 | for d 18 | do 19 | pathcomp="$pathcomp$d" 20 | case "$pathcomp" in 21 | -* ) pathcomp=./$pathcomp ;; 22 | esac 23 | 24 | if test ! -d "$pathcomp"; then 25 | echo "mkdir $pathcomp" 26 | 27 | mkdir "$pathcomp" || lasterr=$? 28 | 29 | if test ! -d "$pathcomp"; then 30 | errstatus=$lasterr 31 | fi 32 | fi 33 | 34 | pathcomp="$pathcomp/" 35 | done 36 | done 37 | 38 | exit $errstatus 39 | 40 | # mkinstalldirs ends here 41 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/string_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** string_tools.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "types.h" 13 | 14 | #include "xo/string/string_tools.h" 15 | #include "xo/string/string_cast.h" 16 | 17 | namespace scone 18 | { 19 | // import string tools from xo 20 | using xo::stringf; 21 | using xo::to_str; 22 | using xo::from_str; 23 | using xo::quoted; 24 | 25 | template< typename T > char GetSignChar( const T& v ) { return v < 0 ? '-' : '+'; } 26 | 27 | /// Get formatted date/time string 28 | String SCONE_API GetDateTimeAsString(); 29 | 30 | /// Get formatted date/time with exact fractional seconds as string 31 | String SCONE_API GetDateTimeExactAsString(); 32 | } 33 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/deprecated/SimpleMuscleReflex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** SimpleMuscleReflex.h 3 | ** 4 | ** Copyright (C) 2013-2018 Thomas Geijtenbeek. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Reflex.h" 12 | #include "scone/model/SensorDelayAdapter.h" 13 | 14 | namespace scone 15 | { 16 | class SimpleMuscleReflex : public Reflex 17 | { 18 | public: 19 | SimpleMuscleReflex( const String& target, const String& source, double mean, double stdev, TimeInSeconds delay, Model& model, Params& par, const Location& loc ); 20 | virtual ~SimpleMuscleReflex() {} 21 | 22 | virtual void ComputeControls( double timestamp ) override; 23 | virtual void StoreData( Storage::Frame& frame, const StoreDataFlags& flags ) const override {} 24 | 25 | private: 26 | SensorDelayAdapter* m_Source; 27 | double m_Gain; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /contrib/lua-5.3.5/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim3/JointOpenSim3.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** JointOpenSim3.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "scone/model/Joint.h" 13 | 14 | namespace OpenSim 15 | { 16 | class Joint; 17 | } 18 | 19 | namespace scone 20 | { 21 | class SCONE_OPENSIM_3_API JointOpenSim3 : public Joint 22 | { 23 | public: 24 | JointOpenSim3( Body& body, Body& parent, class ModelOpenSim3& model, OpenSim::Joint& osJoint ); 25 | virtual ~JointOpenSim3(); 26 | 27 | virtual const String& GetName() const; 28 | virtual Vec3 GetPos() const override; 29 | virtual Vec3 GetReactionForce() const override; 30 | virtual Real GetLimitPower() const override; 31 | 32 | private: 33 | class ModelOpenSim3& m_Model; 34 | OpenSim::Joint& m_osJoint; 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/JointOpenSim4.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** JointOpenSim4.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "scone/model/Joint.h" 13 | 14 | namespace OpenSim 15 | { 16 | class Joint; 17 | } 18 | 19 | namespace scone 20 | { 21 | class SCONE_OPENSIM_4_API JointOpenSim4 : public Joint 22 | { 23 | public: 24 | JointOpenSim4( Body& body, Body& parent, class ModelOpenSim4& model, OpenSim::Joint& osJoint ); 25 | virtual ~JointOpenSim4(); 26 | 27 | virtual const String& GetName() const; 28 | virtual Vec3 GetPos() const override; 29 | virtual Vec3 GetReactionForce() const override; 30 | virtual Real GetLimitPower() const override; 31 | 32 | private: 33 | class ModelOpenSim4& m_Model; 34 | OpenSim::Joint& m_osJoint; 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/SensorNeuron.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** SensorNeuron.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | #include "Neuron.h" 11 | 12 | namespace scone 13 | { 14 | struct SensorNeuron : public Neuron 15 | { 16 | SensorNeuron( const PropNode& pn, Params& par, NeuralController& nc, const String& name, index_t idx, Side side, const String& act_func ); 17 | double GetOutput( double offset = 0.0 ) const override; 18 | virtual string GetName( bool mirrored ) const override; 19 | virtual string GetParName() const override; 20 | 21 | SensorDelayAdapter* input_sensor_; 22 | TimeInSeconds delay_; 23 | bool use_sample_delay_; 24 | int sample_delay_frames_; 25 | int sample_delay_window_; 26 | double sensor_gain_; 27 | string source_name_; 28 | string type_; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /scenarios/Examples/Standing High Jump - Hyfydy.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | max_generations = 500 4 | 5 | SimulationObjective { 6 | max_duration = 2 7 | 8 | # Model used in simulation 9 | ModelHyfydy { 10 | model_file = data/H0914.hfd 11 | signature_postfix = HFD 12 | fixed_control_step_size = 0.005 13 | state_init_file = data/InitStateJump.zml 14 | 15 | << data/HfdConfigM2012Planar.zml >> 16 | } 17 | 18 | # Controller for the Model 19 | FeedForwardController { 20 | symmetric = 1 21 | 22 | # Function for feed-forward pattern 23 | PieceWiseConstant { 24 | control_points = 2 25 | control_point_y = 0.3~0.01<0,1> # Initial y value of control points 26 | control_point_dt = 0.2~0.01<0.001,1> # Initial delta time between control points 27 | } 28 | } 29 | 30 | # Fitness measure for jumping 31 | JumpMeasure { 32 | termination_height = 0.75 33 | prepare_time = 0.2 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/config/ac_cxx_have_strstream.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_CXX_HAVE_STRSTREAM 2 | dnl 3 | dnl If the C++ library has a working strstream, define HAVE_CLASS_STRSTREAM. 4 | dnl 5 | dnl Adapted from ac_cxx_have_sstream.m4 by Steve Robbins 6 | dnl 7 | AC_DEFUN([AC_CXX_HAVE_STRSTREAM], 8 | [AC_REQUIRE([AC_CXX_NAMESPACES]) 9 | AC_LANG_SAVE 10 | AC_LANG_CPLUSPLUS 11 | AC_CHECK_HEADERS(strstream) 12 | AC_CACHE_CHECK([whether the STL defines strstream], 13 | [ac_cv_cxx_have_class_strstream], 14 | [AC_TRY_COMPILE([#if HAVE_STRSTREAM 15 | # include 16 | #else 17 | # include 18 | #endif 19 | #ifdef HAVE_NAMESPACES 20 | using namespace std; 21 | #endif],[ostrstream message; message << "Hello"; return 0;], 22 | ac_cv_cxx_have_class_strstream=yes, ac_cv_cxx_have_class_strstream=no) 23 | ]) 24 | if test "$ac_cv_cxx_have_class_strstream" = yes; then 25 | AC_DEFINE(HAVE_CLASS_STRSTREAM,1,[define if the library defines strstream]) 26 | fi 27 | AC_LANG_RESTORE 28 | ]) 29 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 5c - Pathological Gait - Hyper-reflexia.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 10 6 | signature_postfix = spastic_gas 7 | 8 | # Model used in simulation 9 | ModelOpenSim3 { 10 | model_file = data/Human0914.osim 11 | 12 | # Optimize initial state parameters 13 | state_init_file = data/InitStateGait10.sto 14 | initial_state_offset = 0~0.01<-0.5,0.5> 15 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 16 | } 17 | 18 | CompositeController { 19 | # Controller for gait, based on [Geyer & Herr 2010] 20 | << data/ControllerGH2010.scone >> 21 | 22 | # Mimick hyper-reflexia through F+ reflex in gastroc 23 | ReflexController { 24 | name = HyperReflexia 25 | symmetric = 1 26 | MuscleReflex { target = gastroc delay = 0.020 C0 = 0.1 KF = 1 } 27 | } 28 | } 29 | 30 | # Measure for gait 31 | << data/MeasureGait05.scone >> 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/Result.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace scone 4 | { 5 | template< typename T > 6 | struct Result 7 | { 8 | virtual operator bool() const = 0; 9 | virtual const char* message() const = 0; 10 | virtual T code() const { return code_; } 11 | private: 12 | T code_; 13 | }; 14 | 15 | template< typename T > 16 | struct Success : Result< T > 17 | { 18 | Success( const T& code ) : code_( code ) {} 19 | virtual operator bool() const override { return true; } 20 | virtual const char* message() const override { return ""; } 21 | }; 22 | 23 | template< typename T > 24 | struct Failure : Result< T > 25 | { 26 | Failure( const T& code, String message = "" ) : code_( code ), msg_( message ) { } 27 | virtual operator bool() const { return false; } 28 | virtual const char* message() const override { return msg_.c_str(); } 29 | virtual CodeT code() const override { return code_; } 30 | private: 31 | String msg_; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 5a - Pathological Gait - Weak Plantarflexors.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 10 6 | signature_postfix = weak_sol_gas 7 | 8 | # Model used in simulation 9 | ModelOpenSim3 { 10 | model_file = data/Human0914.osim 11 | 12 | # Optimize initial state parameters 13 | state_init_file = data/InitStateGait10.sto 14 | initial_state_offset = 0~0.01<-0.5,0.5> 15 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 16 | 17 | # Override model properties 18 | Properties { 19 | gastroc_l { max_isometric_force.factor = 0.2 } 20 | gastroc_r { max_isometric_force.factor = 0.2 } 21 | soleus_l { max_isometric_force.factor = 0.2 } 22 | soleus_r { max_isometric_force.factor = 0.2 } 23 | } 24 | } 25 | 26 | # Controller for gait, based on [Geyer & Herr 2010] 27 | << data/ControllerGH2010.scone >> 28 | 29 | # Measure for gait 30 | << data/MeasureGait05.scone >> 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/GaitCycle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/core/platform.h" 4 | #include "scone/core/types.h" 5 | #include "scone/model/Side.h" 6 | #include "Storage.h" 7 | #include "scone/core/string_tools.h" 8 | 9 | namespace scone 10 | { 11 | struct GaitCycle 12 | { 13 | Side side_ = NoSide; 14 | TimeInSeconds begin_ = 0; 15 | TimeInSeconds swing_ = 0; 16 | TimeInSeconds end_ = 0; 17 | Vec3 begin_pos_; 18 | Vec3 end_pos_; 19 | 20 | TimeInSeconds stance_duration() const { return swing_ - begin_; } 21 | TimeInSeconds swing_duration() const { return end_ - swing_; } 22 | TimeInSeconds duration() const { return end_ - begin_; } 23 | Real length() const { return xo::length( end_pos_ - begin_pos_ ); } 24 | Real velocity() const { return length() / duration(); } 25 | }; 26 | 27 | SCONE_API std::vector ExtractGaitCycles( const Storage<>& sto, Real threshold, TimeInSeconds min_stance ); 28 | } 29 | 30 | namespace xo 31 | { 32 | SCONE_API string to_str( const scone::GaitCycle& c ); 33 | } 34 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/SineWave.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Function.h" 4 | #include "PropNode.h" 5 | #include "scone/optimization/Params.h" 6 | 7 | namespace scone 8 | { 9 | /// Parameterizable sine-wave or sinusoid function 10 | /// f(t) = amplitude * sin( 2 * Pi * frequency * t + phase ) + offset 11 | class SCONE_API SineWave : public Function 12 | { 13 | public: 14 | SineWave( const PropNode& pn, Params& par ); 15 | virtual ~SineWave() = default; 16 | 17 | /// Amplitude of the sine-wave; default = 0.5 18 | Real amplitude_; 19 | 20 | /// Frequency [Hz] of the sine-wave; default = 1.0 21 | Real frequency_; 22 | 23 | /// Phase [Rad] of the sine-wave; default = 0 24 | Real phase_; 25 | 26 | /// Offset of the sine-wave; default = 0.5 27 | Real offset_; 28 | 29 | // value 30 | virtual Real GetValue( Real x ) override; 31 | virtual Real GetDerivativeValue( Real x ) override; 32 | 33 | // a signature describing the function 34 | virtual String GetSignature() override { return "S"; } 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/MuscleId.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/core/types.h" 4 | #include "Side.h" 5 | #include "xo/string/string_cast.h" 6 | #include "scone/core/string_tools.h" 7 | 8 | namespace scone 9 | { 10 | struct MuscleId 11 | { 12 | MuscleId( const String& str ) : 13 | side_( GetSideFromName( str ) ), 14 | base_( GetNameNoSide( str ) ), 15 | line_( no_index ) 16 | { 17 | auto idx = str.find_last_of( "0123456789" ); 18 | if ( idx != String::npos && idx > 0 && base_[ idx - 1 ] != '_' ) 19 | { 20 | xo::from_str( base_.substr( idx ), line_ ); 21 | base_ = base_.substr( 0, idx ); 22 | } 23 | } 24 | 25 | String base_line_name() const { return base_ + line_name(); } 26 | String base_line_side_name() const { return base_ + line_name() + side_name(); } 27 | String side_name() const { return GetSideName( side_ ); } 28 | String line_name() const { return line_ != no_index ? stringf( "%d", line_ ) : ""; } 29 | 30 | Side side_; 31 | String base_; 32 | index_t line_; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/config/ac_cxx_warn_effective_cxx.m4: -------------------------------------------------------------------------------- 1 | dnl HAVE_WARN_EFFECTIVE_CXX 2 | dnl ---------------------- 3 | dnl 4 | dnl If the C++ compiler accepts the `-Weffc++' flag, 5 | dnl set output variable `WARN_EFFECTIVE_CXX' to `-Weffc++' and 6 | dnl `WARN_NO_EFFECTIVE_CXX' to `-Wno-effc++'. Otherwise, 7 | dnl leave both empty. 8 | dnl 9 | AC_DEFUN([HAVE_WARN_EFFECTIVE_CXX], 10 | [ 11 | AC_REQUIRE([AC_PROG_CXX]) 12 | AC_MSG_CHECKING([whether the C++ compiler (${CXX}) accepts -Weffc++]) 13 | AC_CACHE_VAL([cv_warn_effective_cxx], 14 | [ 15 | AC_LANG_SAVE 16 | AC_LANG_CPLUSPLUS 17 | save_cxxflags="$CXXFLAGS" 18 | CXXFLAGS="$CXXFLAGS -Weffc++" 19 | AC_TRY_COMPILE([],[main();], 20 | [cv_warn_effective_cxx=yes], [cv_warn_effective_cxx=no]) 21 | CXXFLAGS="$save_cxxflags" 22 | AC_LANG_RESTORE 23 | ]) 24 | AC_MSG_RESULT([$cv_warn_effective_cxx]) 25 | if test "$cv_warn_effective_cxx" = yes; then 26 | WARN_EFFECTIVE_CXX=-Weffc++ 27 | WARN_NO_EFFECTIVE_CXX=-Wno-effc++ 28 | fi 29 | AC_SUBST([WARN_EFFECTIVE_CXX]) 30 | AC_SUBST([WARN_NO_EFFECTIVE_CXX]) 31 | ]) 32 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** platform.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #if defined(_MSC_VER) 12 | # ifdef SCONE_EXPORTS 13 | # define SCONE_API __declspec(dllexport) 14 | # else 15 | # define SCONE_API __declspec(dllimport) 16 | # endif 17 | #else 18 | # define SCONE_API 19 | #endif 20 | 21 | // enable / disable profiling 22 | //#define SCONE_ENABLE_PROFILING 23 | //#define SCONE_ENABLE_XO_PROFILING 24 | 25 | #ifdef NDEBUG 26 | constexpr bool SCONE_DEBUG = false; 27 | #else 28 | constexpr bool SCONE_DEBUG = true; 29 | #endif 30 | 31 | #ifdef SCONE_EXPERIMENTAL_FEATURES 32 | # define SCONE_EXPERIMENTAL_FEATURES_ENABLED 1 33 | #else 34 | # define SCONE_EXPERIMENTAL_FEATURES_ENABLED 0 35 | #endif 36 | 37 | #if defined(_MSC_VER) 38 | # pragma warning( disable: 4251 ) // disable W4251, unfortunately there's no nice way to do this 39 | #endif 40 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/opt_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** opt_tools.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/core/platform.h" 12 | #include "scone/core/PropNode.h" 13 | #include "scone/core/string_tools.h" 14 | #include "scone/core/memory_tools.h" 15 | #include "scone/core/Log.h" 16 | #include "scone/core/types.h" 17 | #include "scone/optimization/Optimizer.h" 18 | 19 | namespace scone 20 | { 21 | /// Log unused properties 22 | SCONE_API bool LogUnusedProperties( const PropNode& pn ); 23 | 24 | /// Creates and evaluates SimulationObjective. Logs unused properties. 25 | SCONE_API PropNode EvaluateScenario( const PropNode& scenario_pn, const path& par_file, const path& output_base ); 26 | 27 | /// Returns .scone file for a given .par file, or returns argument if already .scone. 28 | SCONE_API path FindScenario( const path& scenario_or_par_file ); 29 | } 30 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/MotorNeuron.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** MotorNeuron.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "MotorNeuron.h" 10 | 11 | #include "scone/model/Actuator.h" 12 | #include "scone/model/Model.h" 13 | #include "scone/model/Muscle.h" 14 | #include "scone/core/HasName.h" 15 | #include "NeuralController.h" 16 | 17 | namespace scone 18 | { 19 | MotorNeuron::MotorNeuron( const PropNode& pn, Params& par, NeuralController& nc, const string& muscle, index_t idx, Side side, const string& act_func ) : 20 | Neuron( pn, muscle, idx, side, act_func ) 21 | { 22 | muscle_ = FindByName( nc.GetModel().GetMuscles(), muscle ).get(); 23 | 24 | ScopedParamSetPrefixer ps( par, GetParName() + "." ); 25 | offset_ = par.try_get( "C0", pn, "offset", 0.0 ); 26 | } 27 | 28 | void MotorNeuron::UpdateActuator() 29 | { 30 | auto v = GetOutput(); 31 | muscle_->AddInput( v ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/sconelib/scone/measures/BalanceMeasure.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** BalanceMeasure.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Measure.h" 12 | 13 | namespace scone 14 | { 15 | /// Measure that checks for balance, i.e. if a specific vertical COP position is maintained. 16 | class BalanceMeasure : public Measure 17 | { 18 | public: 19 | BalanceMeasure( const PropNode& props, Params& par, const Model& model, const Location& loc ); 20 | 21 | /// Relative COM height (factor of initial COM height) at which to stop the simulation; default = 0.5. 22 | double termination_height; 23 | 24 | virtual bool UpdateMeasure( const Model& model, double timestamp ) override; 25 | virtual double ComputeResult( const Model& model ) override; 26 | 27 | protected: 28 | virtual String GetClassSignature() const override; 29 | 30 | private: 31 | double m_InitialHeight; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/RaisedCosine.cpp: -------------------------------------------------------------------------------- 1 | #include "RaisedCosine.h" 2 | 3 | #include "spot/par_tools.h" 4 | #include "xo/numerical/constants.h" 5 | #include 6 | 7 | using std::cos; 8 | constexpr auto pi = xo::constantsd::pi; 9 | 10 | namespace scone 11 | { 12 | RaisedCosine::RaisedCosine( const PropNode& pn, Params& par ) : 13 | INIT_PAR_MEMBER( pn, par, amplitude, 1 ), 14 | INIT_PAR_MEMBER( pn, par, mean, 0 ), 15 | INIT_PAR_MEMBER( pn, par, half_width, 1.0 ), 16 | INIT_PAR_MEMBER( pn, par, offset, 0.0 ) 17 | {} 18 | 19 | Real RaisedCosine::GetValue( Real x ) 20 | { 21 | if (mean - half_width <= x && x <= mean + half_width) 22 | return offset + amplitude / 2 23 | * (1 + cos( ( x - mean ) * pi() / half_width )); 24 | else 25 | return offset; 26 | } 27 | 28 | Real RaisedCosine::GetDerivativeValue( Real x ) 29 | { 30 | if (mean - half_width <= x && x <= mean + half_width) 31 | return -(amplitude * pi() ) / ( 2 * half_width ) 32 | * sin( ( x - mean ) * pi() / half_width ); 33 | else 34 | return 0; 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /contrib/lua-5.3.5/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /scenarios/Tutorials/data/ScriptControllerJump.lua: -------------------------------------------------------------------------------- 1 | -- SCONE script for a simple feed-forward controller. 2 | -- See Tutorial 6a - Script - High Jump 3 | 4 | function init( model, par ) 5 | -- keep a list of offsets and slopes to compute the excitation 6 | offset = {} 7 | slope = {} 8 | 9 | -- keep a list of all actuators 10 | actuators = {} 11 | 12 | -- iterate over all actuators in the model 13 | for i = 1, model:actuator_count() do 14 | -- store the actuator in the list 15 | actuators[ i ] = model:actuator( i ) 16 | 17 | -- create parameters for both slope and offset 18 | local name = actuators[ i ]:name() 19 | offset[ i ] = par:create_from_mean_std( name .. "-offset", 0.3, 0.1, 0, 1 ) 20 | slope[ i ] = par:create_from_mean_std( name .. "-slope", 0, 1, -10, 10 ) 21 | end 22 | end 23 | 24 | function update( model ) 25 | -- get the current simulation time 26 | local t = model:time() 27 | 28 | -- iterate over all actuators 29 | for i = 1, #actuators do 30 | local excitation = offset[ i ] + t * slope[ i ] 31 | actuators[ i ]:add_input( excitation ) 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/profiler_config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma once 4 | 5 | #include "platform.h" 6 | 7 | #if defined SCONE_ENABLE_PROFILING 8 | # include "Profiler.h" 9 | # define SCONE_PROFILE_FUNCTION ScopedProfile unique_scoped_function_profile( Profiler::GetGlobalInstance(), __FUNCTION__ ) 10 | # define SCONE_PROFILE_SCOPE( scope_name_arg ) ScopedProfile unique_scoped_function_profile( Profiler::GetGlobalInstance(), scope_name_arg ) 11 | # define SCONE_PROFILE_START Profiler::GetGlobalInstance().Reset() 12 | # define SCONE_PROFILE_REPORT log::info( Profiler::GetGlobalInstance().GetReport() ) 13 | #elif defined SCONE_ENABLE_XO_PROFILING 14 | # include "PropNode.h" 15 | # include "xo/system/profiler.h" 16 | # define SCONE_PROFILE_FUNCTION( profiler ) xo::scope_profiler scoped_profile_var( __FUNCTION__, profiler ) 17 | # define SCONE_PROFILE_SCOPE( profiler, scope_name_arg ) xo::scope_profiler scoped_profile_var( scope_name_arg, profiler ) 18 | #else 19 | # define SCONE_PROFILE_FUNCTION( profiler ) void() 20 | # define SCONE_PROFILE_SCOPE( profiler, scope_name_arg ) void() 21 | #endif 22 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/MirrorController.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** MirrorController.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/controllers/Controller.h" 12 | #include "scone/core/Factories.h" 13 | 14 | namespace scone 15 | { 16 | /// Controller that automatically adds a mirrored version for each child Controller. 17 | class MirrorController : public Controller 18 | { 19 | public: 20 | MirrorController( const PropNode& props, Params& par, Model& model, const Location& loc ); 21 | virtual ~MirrorController(); 22 | 23 | virtual void StoreData( Storage::Frame& frame, const StoreDataFlags& flags ) const override; 24 | virtual bool PerformAnalysis( const Model& model, double timestamp ) override; 25 | virtual bool ComputeControls( Model& model, double timestamp ) override; 26 | 27 | protected: 28 | virtual String GetClassSignature() const override; 29 | 30 | private: 31 | ControllerUP c0, c1; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/HasData.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** HasData.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Storage.h" 12 | #include "xo/container/flag_set.h" 13 | 14 | namespace scone 15 | { 16 | enum class StoreDataTypes { 17 | Unknown, 18 | State, 19 | BodyPosition, 20 | JointReactionForce, 21 | ActuatorInput, 22 | MuscleProperties, 23 | MuscleDofMomentPower, 24 | GroundReactionForce, 25 | ContactForce, 26 | SystemPower, 27 | SensorData, 28 | ControllerData, 29 | MeasureData, 30 | SimulationStatistics, 31 | DebugData 32 | }; 33 | 34 | using StoreDataFlags = xo::flag_set< StoreDataTypes >; 35 | 36 | /// Objects derived from this class can store data for analysis 37 | class SCONE_API HasData 38 | { 39 | public: 40 | virtual void StoreData( Storage< Real >::Frame& frame, const StoreDataFlags& flags ) const = 0; 41 | inline virtual ~HasData() {} 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/Simulation.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Simulation.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Model.h" 12 | #include 13 | 14 | #include "scone/core/PropNode.h" 15 | #include "scone/core/types.h" 16 | #include "scone/optimization/Params.h" 17 | 18 | namespace scone 19 | { 20 | class SCONE_API Simulation 21 | { 22 | public: 23 | Simulation( const PropNode& props ); 24 | virtual ~Simulation(); 25 | 26 | Model& AddModel( const String& filename ); 27 | size_t GetModelCount() { return m_Models.size(); } 28 | Model& GetModel( size_t idx = 0 ); 29 | 30 | virtual void AdvanceSimulationTo( double time ) = 0; 31 | 32 | double max_simulation_time; 33 | double integration_accuracy; 34 | 35 | protected: 36 | std::vector< ModelUP > m_Models; 37 | 38 | private: // non-copyable and non-assignable 39 | Simulation( const Simulation& ); 40 | Simulation& operator=( const Simulation& ); 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(OPT_API_FILES 2 | CmaOptimizer.cpp 3 | CmaOptimizer.h 4 | Objective.cpp 5 | Objective.h 6 | Optimizer.cpp 7 | Optimizer.h 8 | ParamInfo.cpp 9 | ParamInfo.h 10 | ParamSet.cpp 11 | ParamSet.h 12 | ) 13 | set(OPT_SYSTEM_FILES 14 | Factories.cpp 15 | Factories.h 16 | opt.cpp 17 | opt.h 18 | SharkHelperClasses.h 19 | ) 20 | 21 | add_library(scone-opt # Name of the library file. 22 | SHARED # versus static. 23 | # Source code files: 24 | ${OPT_API_FILES} ${OPT_SYSTEM_FILES} 25 | ) 26 | target_link_libraries(scone-opt scone-core 27 | shark ${Boost_LIBRARIES}) 28 | 29 | set_target_properties(scone-opt PROPERTIES 30 | DEFINE_SYMBOL OPT_EXPORTS # For controlling WIN32 dllimport/export. 31 | PROJECT_LABEL opt # Name of this target in Visual Studio. 32 | FOLDER "sconelib" # Place target inside a sconelib folder in Visual Studio. 33 | ) 34 | 35 | # To create folders in Visual Studio. 36 | source_group("API" FILES ${OPT_API_FILES}) 37 | source_group("System" FILES ${OPT_SYSTEM_FILES}) 38 | -------------------------------------------------------------------------------- /src/sconelib/sconeopensim4/deprecated/JointOpenSim4.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** JointOpenSim4.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "scone/model/Joint.h" 13 | 14 | namespace OpenSim 15 | { 16 | class Joint; 17 | } 18 | 19 | namespace scone 20 | { 21 | class SCONE_OPENSIM_4_API JointOpenSim4 : public Joint 22 | { 23 | public: 24 | JointOpenSim4( Body& body, Joint* parent, class ModelOpenSim4& model, OpenSim::Joint& osJoint ); 25 | virtual ~JointOpenSim4(); 26 | 27 | virtual const String& GetName() const override; 28 | 29 | virtual Vec3 GetPos() const override; 30 | virtual size_t GetDofCount() const override; 31 | virtual Real GetDofValue( size_t index = 0 ) const override; 32 | virtual const String& GetDofName( size_t index = 0 ) const override; 33 | 34 | class ModelOpenSim4& m_Model; 35 | OpenSim::Joint& m_osJoint; 36 | 37 | virtual Vec3 GetReactionForce() const override; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /src/sconestudio/help_tools.cpp: -------------------------------------------------------------------------------- 1 | #include "help_tools.h" 2 | #include "xo/container/flat_map.h" 3 | #include "QFile" 4 | #include "xo/filesystem/filesystem.h" 5 | #include "scone/core/system_tools.h" 6 | #include "QDesktopServices" 7 | 8 | namespace scone 9 | { 10 | QUrl GetHelpUrl( const QString& keyword ) 11 | { 12 | static xo::flat_map data; 13 | if ( data.empty() ) 14 | { 15 | auto vec = xo::split_str( xo::load_string( GetFolder( SCONE_RESOURCE_FOLDER ) / "help/keywords.txt" ), "\n" ); 16 | for ( const auto& k : vec ) 17 | { 18 | QString doku = QString( k.c_str() ).remove( ".txt" ); 19 | QString keyword = QString( doku ).remove( '_' ); 20 | data[ keyword ] = doku; 21 | } 22 | } 23 | 24 | if ( !keyword.isEmpty() ) 25 | { 26 | auto k = keyword.toLower(); 27 | if ( auto it = data.find( k ); it != data.end() ) 28 | return QUrl( "https://scone.software/doku.php?id=ref:" + it->second ); 29 | else return QUrl( "https://scone.software/doku.php?do=search&q=" + keyword ); 30 | } 31 | else return QUrl( "https://scone.software/doku.php?id=start" ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tools/unix_2d_build-scone: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | source ./tools/build_config 5 | 6 | if [[ "$OSTYPE" == "darwin"* ]]; then 7 | cmake_extra_args=( 8 | -DCMAKE_PREFIX_PATH="${OSG_INSTALL_PATH}/lib64;${QT5_BREW_PATH}" 9 | -DOSGQT_INCLUDE_DIR="${OSG_INSTALL_PATH}/lib64" 10 | -DOSGQT_LIBRARY_RELEASE="${OSG_INSTALL_PATH}/lib/libosgQt.dylib" 11 | -DSCONE_SCONESTUDIO_REQUIRED=ON 12 | ) 13 | else 14 | cmake_extra_args=( 15 | -DCMAKE_PREFIX_PATH="${OSG_INSTALL_PATH}/lib64" 16 | -DSCONE_LUA=ON 17 | ) 18 | fi 19 | 20 | mkdir -p "${SCONE_BUILD_DIR}" 21 | mkdir -p "${SCONE_INSTALL_DIR}" 22 | cd "${SCONE_BUILD_DIR}" 23 | cmake ../ \ 24 | -DOSG_DIR="${OSG_INSTALL_PATH}" \ 25 | -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \ 26 | -DCMAKE_VERBOSE_MAKEFILE="${CMAKE_VERBOSE_MAKEFILE}" \ 27 | -DCMAKE_INSTALL_PREFIX="${SCONE_INSTALL_DIR}" \ 28 | -DOPENSIM_INSTALL_DIR="${OPENSIM3_INSTALL_PATH}" \ 29 | -DOPENSIM_INCLUDE_DIR="${OPENSIM3_INSTALL_PATH}/sdk/include" \ 30 | ${cmake_extra_args[@]} 31 | cmake --build . --parallel "${NUM_BUILD_JOBS}" 32 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/RaisedCosine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Function.h" 4 | #include "PropNode.h" 5 | #include "scone/optimization/Params.h" 6 | 7 | namespace scone 8 | { 9 | /// Raised cosine bell shape curve. 10 | /// 11 | /// Case function: 12 | /// 13 | /// f(x) = offset + amplitude / 2 (1 + cos((x - mean) π / half_width), 14 | /// for mean - half_width <= x <= mean + half_width 15 | /// 16 | /// f(x) = 0, otherwise 17 | class SCONE_API RaisedCosine : public Function 18 | { 19 | public: 20 | RaisedCosine( const PropNode& pn, Params& par ); 21 | virtual ~RaisedCosine() = default; 22 | 23 | /// Amplitude of the bell-shaped curve; default = 1. 24 | Real amplitude; 25 | 26 | /// Mean at which the bell-shaped curved is centered; default = 0. 27 | Real mean; 28 | 29 | /// The half width of the curve; default = 1. 30 | Real half_width; 31 | 32 | /// Offset of the curve; default = 0. 33 | Real offset; 34 | 35 | virtual Real GetValue( Real x ) override; 36 | virtual Real GetDerivativeValue( Real x ) override; 37 | virtual String GetSignature() override { return "R"; } 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/Jump - Model Properties.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | init_file = data/f0914m.FC2.HighJump.D2.par 4 | 5 | SimulationObjective { 6 | max_duration = 2 7 | 8 | # Model used in simulation 9 | OpenSimModel { 10 | model_file = data/Human0914.osim 11 | 12 | Properties { 13 | iliopsoas_l { max_isometric_force.factor = 3 } 14 | gastroc_r { max_isometric_force.factor = 2 } 15 | r_toe { location.offset { x = 0.02~0.01<-1,1> y = 0 z = 0 } } 16 | l_toe { radius = 0.03 location.offset { x = r_toe.location.offset.x y = -0.005 z = 0 } } 17 | #KneeLimit_r { upper_stiffness = 0.001 damping = 0 } 18 | } 19 | } 20 | 21 | # Controller for the Model 22 | FeedForwardController { 23 | symmetric = 1 24 | 25 | # Function for feed-forward pattern 26 | PieceWiseConstant { 27 | control_points = 2 28 | control_point_y = 0.3~0.01<0,1> 29 | control_point_dt = 0.2~0.01<0,1> 30 | } 31 | } 32 | 33 | # Fitness measure for jumping 34 | JumpMeasure { 35 | termination_height = 0.5 36 | terminate_on_peak = 1 37 | prepare_time = 0.2 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/HasSignature.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** HasSignature.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "platform.h" 12 | #include "types.h" 13 | #include "PropNode.h" 14 | 15 | namespace scone 16 | { 17 | /// Class that has a signature, used for file output. 18 | class SCONE_API HasSignature 19 | { 20 | public: 21 | HasSignature( const PropNode& pn ); 22 | virtual ~HasSignature() = default; 23 | 24 | /// Prefix signature with custom string. Special tags: DATE_TIME, DATE_TIME_EXACT, SCONE_VERSION. 25 | String signature_prefix; 26 | 27 | /// Append custom string to signature. Special tags: DATE_TIME, DATE_TIME_EXACT, SCONE_VERSION. 28 | String signature_postfix; 29 | 30 | /// Set custom signature and omit the auto-generated signature. 31 | String signature; 32 | 33 | String GetSignature() const; 34 | 35 | protected: 36 | virtual String GetClassSignature() const { return ""; } 37 | 38 | private: 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /src/sconelib/scone/measures/ReactionForceMeasure.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ReactionForceMeasure.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Measure.h" 12 | #include "RangePenalty.h" 13 | 14 | namespace scone 15 | { 16 | /// Measure that penalizes ground reaction forces above a certain threshold. 17 | /// See RangePenalty for details on how to set range, abs_penalty and squared_penalty. 18 | class ReactionForceMeasure : public Measure, public RangePenalty 19 | { 20 | public: 21 | ReactionForceMeasure( const PropNode& props, Params& par, const Model& model, const Location& loc ); 22 | 23 | /// measure force per leg instead of sum of forces; defaut = false. 24 | bool use_force_per_leg; 25 | 26 | virtual double ComputeResult( const Model& model ) override; 27 | virtual bool UpdateMeasure( const Model& model, double timestamp ) override; 28 | 29 | protected: 30 | virtual void StoreData( Storage::Frame& frame, const StoreDataFlags& flags ) const override; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 6b - Script - Balance Device.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | 4 | SimulationObjective { 5 | max_duration = 10 6 | 7 | # Model used in simulation 8 | ModelOpenSim3 { 9 | model_file = data/Human0914.osim 10 | fixed_control_step_size = 0.005 # higher step sizes give better performance 11 | enable_external_forces = 1 # Required when applying external forces 12 | 13 | # Optimize initial state parameters 14 | state_init_file = data/InitStateGait10.sto 15 | initial_state_offset = 0~0.01<-0.5,0.5> 16 | initial_state_offset_exclude = "*_tx;*_ty;*_u" 17 | } 18 | 19 | CompositeController { 20 | # Controller for gait, based on [Geyer & Herr 2010] 21 | << data/ControllerGH2010.scone >> 22 | 23 | ScriptController { 24 | name = BalanceDevice 25 | target_body = torso 26 | min_deg = -20~2 # optimize this parameter 27 | max_deg = 5~0.5 # optimize this parameter 28 | moment = 50 29 | duration = 0.2 30 | script_file = "data/ScriptControllerBalanceDevice.lua" 31 | } 32 | } 33 | 34 | # Measure for gait 35 | << data/MeasureGait05.scone >> 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tools/mac_1_get-dependencies: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | source ./tools/build_config 5 | 6 | # if root is running this script then do not use `sudo` (some distros 7 | # do not supply it) 8 | if [[ "${UID}" == 0 ]]; then 9 | sudo='' 10 | else 11 | sudo='sudo' 12 | fi 13 | 14 | echo "installing brew dependencies" 15 | brew install qt5 16 | 17 | echo "cloning non-submodule source dependencies" 18 | try_clone_checkout "https://github.com/openscenegraph/OpenSceneGraph.git" "OpenSceneGraph-3.4.1" 19 | try_clone_checkout "https://github.com/tgeijten/opensim3-scone.git" "master" 20 | try_clone_checkout "https://github.com/simbody/simbody.git" "Simbody-3.5.4" 21 | try_clone_checkout "https://github.com/create-dmg/create-dmg.git" "v1.0.8" 22 | 23 | echo "getting submodule dependencies" 24 | git submodule update --init --recursive 25 | 26 | 27 | echo "performing other hacks necessary to make SCONE compile on mac" 28 | 29 | # HACK: remove the jpeg plugin from openscenegraph, because 30 | # it doesn't compile on mac (API changed) 31 | sed -i -e 's/^[ ]*ADD_SUBDIRECTORY(jpeg)/# ADD_SUBDIRECTORY(jpeg)/' OpenSceneGraph/src/osgPlugins/CMakeLists.txt 32 | 33 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/version.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** version.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "version.h" 10 | #include "xo/filesystem/path.h" 11 | #include "xo/filesystem/filesystem.h" 12 | #include "system_tools.h" 13 | #include "xo/string/string_cast.h" 14 | #include 15 | 16 | constexpr int SCONE_VERSION_MAJOR = 2; 17 | constexpr int SCONE_VERSION_MINOR = 0; 18 | constexpr int SCONE_VERSION_PATCH = 0; 19 | constexpr const char* SCONE_VERSION_POSTFIX = "ALPHA 2"; 20 | 21 | namespace scone 22 | { 23 | int GetSconeBuildNumber() 24 | { 25 | xo::path versionpath( GetInstallFolder() / ".version" ); 26 | int build = 0; 27 | if ( xo::exists( versionpath ) ) 28 | xo::from_str( xo::load_string( versionpath ), build ); 29 | return build; 30 | } 31 | 32 | const version& GetSconeVersion() 33 | { 34 | static version scone_version = version( SCONE_VERSION_MAJOR, SCONE_VERSION_MINOR, SCONE_VERSION_PATCH, GetSconeBuildNumber(), SCONE_VERSION_POSTFIX ); 35 | return scone_version; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/SensorDelayAdapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** SensorDelayAdapter.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Sensor.h" 12 | 13 | #if defined(_MSC_VER) 14 | # pragma warning( push ) 15 | # pragma warning( disable: 4275 ) 16 | #endif 17 | 18 | namespace scone 19 | { 20 | struct SCONE_API SensorDelayAdapter : public Sensor 21 | { 22 | SensorDelayAdapter( Model& model, Sensor& source, TimeInSeconds default_delay ); 23 | virtual ~SensorDelayAdapter(); 24 | 25 | virtual Real GetValue() const override; 26 | virtual String GetName() const override; 27 | 28 | Real GetValue( Real delay ) const; 29 | Real GetAverageValue( int delay_samples, int window_size ) const; 30 | 31 | void UpdateStorage(); 32 | Sensor& GetInputSensor() { return m_InputSensor; } 33 | 34 | private: 35 | Model& m_Model; 36 | Sensor& m_InputSensor; 37 | TimeInSeconds m_Delay; 38 | index_t m_StorageIdx; 39 | }; 40 | } 41 | 42 | #if defined(_MSC_VER) 43 | # pragma warning( pop ) 44 | #endif 45 | -------------------------------------------------------------------------------- /src/sconeunittests/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** main.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "scone/sconelib_config.h" 10 | #include "xo/serialization/serialize.h" 11 | #include "xo/system/log_sink.h" 12 | #include "xo/system/test_case.h" 13 | #include "xo/serialization/prop_node_serializer_zml.h" 14 | #include "scenario_test.h" 15 | #include "xo/utility/arg_parser.h" 16 | 17 | int main( int argc, const char* argv[] ) 18 | { 19 | xo::log::console_sink sink( xo::log::level::info ); 20 | scone::Initialize(); 21 | 22 | auto args = xo::arg_parser( argc, argv ); 23 | if ( !args.has_flag( "skip-tutorials" ) ) 24 | scone::add_scenario_tests( "scenarios/Tutorials" ); 25 | #if SCONE_OPENSIM_3_ENABLED 26 | if ( !args.has_flag( "skip-opensim3" ) ) 27 | scone::add_scenario_tests( "scenarios/UnitTests/OpenSim3" ); 28 | #endif 29 | #if SCONE_HYFYDY_ENABLED 30 | if ( !args.has_flag( "skip-hyfydy" ) ) 31 | scone::add_scenario_tests( "scenarios/UnitTests/Hyfydy" ); 32 | #endif 33 | 34 | return xo::test::run_tests_async(); 35 | } 36 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/memory_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** memory_tools.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "xo/utility/pointer_types.h" 12 | 13 | // class and unique pointer type forward declaration 14 | #define SCONE_DECLARE_CLASS_AND_PTR( _class_ ) \ 15 | class _class_; \ 16 | typedef std::unique_ptr< _class_ > _class_##UP; 17 | 18 | // struct and unique pointer type forward declaration 19 | #define SCONE_DECLARE_STRUCT_AND_PTR( _class_ ) \ 20 | struct _class_; \ 21 | typedef std::unique_ptr< _class_ > _class_##UP; 22 | 23 | namespace scone 24 | { 25 | using xo::u_ptr; 26 | using xo::s_ptr; 27 | 28 | // dynamic cast a unique_ptr, throws on failure 29 | template 30 | std::unique_ptr< To > dynamic_unique_cast( std::unique_ptr< From >&& p ) 31 | { 32 | To& cast = dynamic_cast< To& >( *p ); // throws on failure, freeing p 33 | p.release(); // release ownership from p 34 | return std::unique_ptr< To >( &cast ); // return pointer with ownership 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/sconelib/scone/measures/GaitCycleMeasure.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** GaitCycleMeasure.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Measure.h" 12 | #include "scone/model/State.h" 13 | 14 | namespace scone 15 | { 16 | /// Measure how well a single gait cycle is performed. 17 | /// *work in progress*, for gait optimization, use GaitMeasure instead. 18 | class GaitCycleMeasure : public Measure 19 | { 20 | public: 21 | GaitCycleMeasure( const PropNode& props, Params& par, const Model& model, const Location& loc ); 22 | 23 | virtual double ComputeResult( const Model& model ) override; 24 | 25 | /// Use half gait cycle instead of full cycle; default = false. 26 | bool use_half_cycle; 27 | 28 | protected: 29 | virtual bool UpdateMeasure( const Model& model, double timestamp ) override { return false; } 30 | 31 | private: 32 | Real GetStateSimilarity( const State& state ); 33 | std::pair< String, int > GetMirroredStateNameAndSign( const String& str ); 34 | 35 | State m_InitState; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /contrib/tclap-1.2.1/COPYING: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright (c) 2003 Michael E. Smoot 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/sconelib/scone/measures/BalanceMeasure.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** BalanceMeasure.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "BalanceMeasure.h" 10 | #include "scone/model/Model.h" 11 | 12 | namespace scone 13 | { 14 | 15 | BalanceMeasure::BalanceMeasure( const PropNode& props, Params& par, const Model& model, const Location& loc ) : 16 | Measure( props, par, model, loc ) 17 | { 18 | INIT_PROP( props, termination_height, 0.5 ); 19 | 20 | m_InitialHeight = model.GetComHeight(); 21 | } 22 | 23 | bool BalanceMeasure::UpdateMeasure( const Model& model, double timestamp ) 24 | { 25 | double pos = model.GetComHeight(); 26 | if ( pos < termination_height * m_InitialHeight ) 27 | return true; 28 | 29 | return false; 30 | } 31 | 32 | double BalanceMeasure::ComputeResult( const Model& model ) 33 | { 34 | return std::max( 0.0, ( model.GetSimulationEndTime() - model.GetTime() ) / model.GetSimulationEndTime() ); 35 | } 36 | 37 | String BalanceMeasure::GetClassSignature() const 38 | { 39 | return "B"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/sconeunittests/optimization_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** optimization_test.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "scone/core/Factories.h" 10 | #include "scone/core/math.h" 11 | #include "scone/optimization/CmaOptimizerSpot.h" 12 | #include "scone/optimization/Objective.h" 13 | #include "scone/optimization/opt_tools.h" 14 | 15 | #include "xo/filesystem/filesystem.h" 16 | #include "xo/filesystem/path.h" 17 | #include "xo/serialization/serialize.h" 18 | #include "xo/system/test_case.h" 19 | 20 | using namespace scone; 21 | 22 | XO_TEST_CASE( optimization_test ) 23 | { 24 | auto test_folder = scone::GetFolder( scone::SCONE_ROOT_FOLDER ) / "resources/unittestdata/optimization_test"; 25 | const PropNode pn = xo::load_file( test_folder / "schwefel_5.xml" ); 26 | OptimizerUP o = CreateOptimizer( pn, test_folder ); 27 | o->output_root = xo::temp_directory_path() / "SCONE/optimization_test"; 28 | xo::log_unaccessed( pn ); 29 | o->Run(); 30 | 31 | XO_CHECK_MESSAGE( o->GetBestFitness() < 1000.0, to_str( o->GetBestFitness() ) ); 32 | } 33 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 2c - Standing High Jump - Straight Pose.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | init_file = data/ResultStandingHighJumpFC2.par # use previous result 4 | 5 | SimulationObjective { 6 | max_duration = 2 7 | 8 | # Model used in simulation 9 | ModelOpenSim3 { 10 | model_file = data/Human0914.osim 11 | } 12 | 13 | # Controller for the Model 14 | FeedForwardController { 15 | symmetric = 1 16 | 17 | # Function for feed-forward pattern 18 | PieceWiseConstant { 19 | control_points = 2 20 | control_point_y = 0.3~0.01<0,1> # Initial y value of control points 21 | control_point_dt = 0.2~0.01<0.001,1> # Initial delta time between control points 22 | } 23 | } 24 | 25 | # Composite measure for straight pose jumping 26 | CompositeMeasure { 27 | minimize = 0 # Maximize this measure 28 | 29 | # Fitness measure for jumping 30 | JumpMeasure { 31 | termination_height = 0.75 32 | prepare_time = 0.2 33 | } 34 | 35 | # Penalize backwards leaning pose 36 | DofMeasure { 37 | dof = pelvis_tilt 38 | position { min = -45 max = 0 abs_penalty = -10 } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/ContactForce.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** ContactForce.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "ContactForce.h" 10 | 11 | namespace scone 12 | { 13 | ContactForce::ContactForce() 14 | {} 15 | 16 | ContactForce::~ContactForce() 17 | {} 18 | 19 | std::tuple ContactForce::GetForceMomentPoint() const 20 | { 21 | return { GetForce(), GetMoment(), GetPoint() }; 22 | } 23 | 24 | ForceValue ContactForce::GetForceValue() const 25 | { 26 | return ForceValue{ GetForce(), GetPoint() }; 27 | } 28 | 29 | void ContactForce::StoreData( Storage::Frame& frame, const StoreDataFlags& flags ) const 30 | { 31 | const auto& [force, moment, point] = GetForceMomentPoint(); 32 | frame[ GetName() + ".force_x" ] = force.x; 33 | frame[ GetName() + ".force_y" ] = force.y; 34 | frame[ GetName() + ".force_z" ] = force.z; 35 | frame[ GetName() + ".moment_x" ] = moment.x; 36 | frame[ GetName() + ".moment_y" ] = moment.y; 37 | frame[ GetName() + ".moment_z" ] = moment.z; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /scenarios/Tutorials/Tutorial 2d - Standing High Jump - Knees Up.scone: -------------------------------------------------------------------------------- 1 | CmaOptimizer { 2 | signature_prefix = DATE_TIME 3 | init_file = data/ResultStandingHighJumpFC2.par # use previous result 4 | 5 | SimulationObjective { 6 | max_duration = 2 7 | 8 | # Model used in simulation 9 | ModelOpenSim3 { 10 | model_file = data/Human0914.osim 11 | } 12 | 13 | # Controller for the Model 14 | FeedForwardController { 15 | symmetric = 1 16 | 17 | # Function for feed-forward pattern 18 | PieceWiseConstant { 19 | control_points = 4 20 | control_point_y = 0.3~0.01<0,1> # Initial y value of control points 21 | control_point_dt = 0.2~0.01<0.001,1> # Initial delta time between control points 22 | } 23 | } 24 | 25 | # Composite measure for straight pose jumping 26 | CompositeMeasure { 27 | minimize = 0 # Maximize this measure 28 | 29 | # Fitness measure for jumping 30 | JumpMeasure { 31 | termination_height = 0.75 32 | prepare_time = 0.2 33 | body = tibia_r 34 | } 35 | 36 | # Penalize backwards leaning pose 37 | DofMeasure { 38 | dof = pelvis_tilt 39 | position { min = -45 max = 0 abs_penalty = -10 } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/ResourceCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ResourceCache.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | 14 | #include "Exception.h" 15 | #include 16 | 17 | namespace scone 18 | { 19 | template< typename T > 20 | class ResourceCache 21 | { 22 | public: 23 | ResourceCache() { }; 24 | ~ResourceCache() { }; 25 | std::unique_ptr< T > CreateCopy( const String& name ) 26 | { 27 | std::lock_guard< std::mutex > lock( m_Mutex ); 28 | 29 | auto it = m_Resources.find( name ); 30 | if ( it == m_Resources.end() ) 31 | { 32 | T* r = CreateFirst( name ); 33 | m_Resources[ name ] = std::unique_ptr< T >( r ); 34 | it = m_Resources.find( name ); 35 | } 36 | return std::make_unique( *it->second ); 37 | } 38 | 39 | private: 40 | T* CreateFirst( const String& name ) { SCONE_THROW_NOT_IMPLEMENTED; } 41 | std::mutex m_Mutex; 42 | std::map< std::string, std::unique_ptr< T > > m_Resources; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/ContactForce.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ContactForce.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/core/types.h" 12 | #include "scone/core/Vec3.h" 13 | #include "scone/core/HasName.h" 14 | #include "scone/core/HasData.h" 15 | #include "ForceValue.h" 16 | 17 | namespace scone 18 | { 19 | class SCONE_API ContactForce : public HasName, HasData 20 | { 21 | public: 22 | ContactForce(); 23 | virtual ~ContactForce(); 24 | 25 | virtual const Vec3& GetForce() const = 0; 26 | virtual const Vec3& GetMoment() const = 0; 27 | virtual const Vec3& GetPoint() const = 0; 28 | virtual std::tuple GetForceMomentPoint() const; 29 | virtual ForceValue GetForceValue() const; 30 | 31 | virtual void StoreData( Storage::Frame& frame, const StoreDataFlags& flags ) const override; 32 | 33 | const std::vector< ContactGeometry* >& GetContactGeometries() const { return m_Geometries; } 34 | 35 | protected: 36 | std::vector< ContactGeometry* > m_Geometries; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/SimulationObjective.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** SimulationObjective.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "SimulationObjective.h" 10 | 11 | #include "scone/core/Exception.h" 12 | #include "scone/model/Model.h" 13 | 14 | #include "scone/core/version.h" 15 | #include "scone/core/string_tools.h" 16 | #include "scone/core/system_tools.h" 17 | #include "scone/core/Factories.h" 18 | 19 | namespace scone 20 | { 21 | SimulationObjective::SimulationObjective( const PropNode& pn, const path& find_file_folder ) : 22 | ModelObjective( pn, find_file_folder ) 23 | { 24 | // simulation objectives must have a measure 25 | SCONE_THROW_IF( !model_->GetMeasure(), "No Measure defined in ModelObjective" ); 26 | 27 | INIT_PROP( pn, max_duration, 1e12 ); 28 | 29 | signature_ += stringf( ".D%.0f", max_duration ); 30 | } 31 | 32 | SimulationObjective::~SimulationObjective() 33 | {} 34 | 35 | void SimulationObjective::AdvanceSimulationTo( Model& m, TimeInSeconds t ) const 36 | { 37 | m.AdvanceSimulationTo( t ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /scenarios/Tutorials/data/ResultStandingHighJumpFC2.par: -------------------------------------------------------------------------------- 1 | hamstrings.Y0 0.0054163396 0.004620866 0.00085458463 2 | hamstrings.DT0 0.1998978 0.19970252 0.00035000395 3 | hamstrings.Y1 0.99830683 0.99741501 0.0013951679 4 | glut_max.Y0 0.0050722827 0.0062846923 0.00084790776 5 | glut_max.DT0 0.33451783 0.33392828 0.0014603228 6 | glut_max.Y1 0.99879348 0.99818893 0.001171873 7 | iliopsoas.Y0 0.001471421 0.0012894107 0.00090089754 8 | iliopsoas.DT0 0.75002523 0.74844616 0.0014161462 9 | iliopsoas.Y1 0.63940983 0.64060554 0.0017085782 10 | vasti.Y0 0.39501195 0.39518762 0.0012007207 11 | vasti.DT0 0.21430406 0.21397237 0.00090420068 12 | vasti.Y1 0.99902961 0.99841086 0.00054965442 13 | gastroc.Y0 0.0068476427 0.0063517231 0.00066370638 14 | gastroc.DT0 0.52445136 0.52328362 0.0016963735 15 | gastroc.Y1 0.99850526 0.99949236 0.00063579624 16 | soleus.Y0 0.012921373 0.013504209 0.00075644164 17 | soleus.DT0 0.51215227 0.5122829 0.0018047409 18 | soleus.Y1 0.99807928 0.99815805 0.00059888772 19 | tib_ant.Y0 0.90425077 0.90238454 0.0021793241 20 | tib_ant.DT0 0.46824827 0.47015825 0.002273048 21 | tib_ant.Y1 0.0034051138 0.003798562 0.0005627602 22 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/deprecated/MetaReflexController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/controllers/Controller.h" 4 | #include "scone/core/types.h" 5 | 6 | namespace scone 7 | { 8 | class MetaReflexController : public Controller 9 | { 10 | public: 11 | MetaReflexController( const PropNode& props, Params& par, Model& model, const Locality& area ); 12 | virtual ~MetaReflexController(); 13 | 14 | virtual bool ComputeControls( Model& model, double timestamp ) override; 15 | 16 | const std::vector< MetaReflexDofUP >& GetReflexDofs() const { return m_ReflexDofs; } 17 | const std::vector< MetaReflexVirtualMuscleUP >& GetVirtualMuscles() const { return m_VirtualMuscles; } 18 | 19 | private: 20 | MetaReflexController( const MetaReflexController& other ); 21 | MetaReflexController& operator=( const MetaReflexController& other ); 22 | 23 | virtual String GetClassSignature() const override; 24 | 25 | virtual void StoreData( Storage< Real >::Frame& frame, const StoreDataFlags& flags ) const override; 26 | 27 | std::vector< MetaReflexDofUP > m_ReflexDofs; 28 | std::vector< MetaReflexVirtualMuscleUP > m_VirtualMuscles; 29 | std::vector< MetaReflexMuscleUP > m_ReflexMuscles; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/deprecated/TimeStateController.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** TimeStateController.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "StateController.h" 12 | 13 | namespace scone 14 | { 15 | class TimeStateController : public StateController 16 | { 17 | public: 18 | TimeStateController( const PropNode& props, Params& par, Model& model, const Location& loc ); 19 | 20 | virtual size_t GetStateCount() const override { return m_States.size(); } 21 | virtual const String& GetStateName( StateIndex i ) const override { return m_States[ i ].name; } 22 | 23 | protected: 24 | virtual String GetClassSignature() const override; 25 | virtual StateIndex GetCurrentState( Model& model, double timestamp ) override; 26 | 27 | struct TimeState 28 | { 29 | TimeState( const PropNode& pn, Params& par ); 30 | bool operator<( const TimeState& other ) const { return start_time < other.start_time; } 31 | String name; 32 | TimeInSeconds start_time; 33 | }; 34 | 35 | std::vector< TimeState > m_States; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/ContactGeometry.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ContactGeometry.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see https://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Body.h" 12 | #include "scone/core/Vec3.h" 13 | #include "scone/core/Quat.h" 14 | #include "xo/shape/shape.h" 15 | #include "scone/core/HasName.h" 16 | 17 | namespace scone 18 | { 19 | class ContactGeometry : public HasName 20 | { 21 | public: 22 | ContactGeometry( const String& name, const Body& b, const xo::shape& s, const Vec3& p, const Quat& q ) : 23 | m_Name( name ), 24 | m_Body( b ), 25 | m_Shape( s ), 26 | m_Pos( p ), 27 | m_Ori( q ) 28 | {} 29 | 30 | virtual const String& GetName() const override { return m_Name; } 31 | 32 | const Body& GetBody() const { return m_Body; } 33 | const xo::shape& GetShape() const { return m_Shape; } 34 | const Vec3& GetPos() const { return m_Pos; } 35 | const Quat& GetOri() const { return m_Ori; } 36 | 37 | private: 38 | const String& m_Name; 39 | const Body& m_Body; 40 | xo::shape m_Shape; 41 | Vec3 m_Pos; 42 | Quat m_Ori; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/deprecated/Link.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Link.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "Link.h" 10 | 11 | #include "Body.h" 12 | #include "Joint.h" 13 | 14 | namespace scone 15 | { 16 | String Link::ToString( const String& prefix ) const 17 | { 18 | String s = prefix + GetBody().GetName() + ( HasJoint() ? ( " (" + GetJoint().GetName() + ")\n" ) : "\n" ); 19 | for ( auto it = m_Children.begin(); it != m_Children.end(); ++it ) 20 | s += ( *it )->ToString( prefix + " " ); 21 | 22 | return s; 23 | } 24 | 25 | const Link* Link::FindLink( const String& body ) const 26 | { 27 | if ( m_Body->GetName() == body ) 28 | return this; 29 | else 30 | { 31 | for ( auto it = m_Children.begin(); it != m_Children.end(); ++it ) 32 | { 33 | const Link* l = ( *it )->FindLink( body ); 34 | if ( l ) return l; 35 | } 36 | return nullptr; 37 | } 38 | } 39 | 40 | Link* Link::FindLink( const String& body ) 41 | { 42 | return const_cast( const_cast( *this ).FindLink( body ) ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/PieceWiseConstantFunction.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** PieceWiseConstantFunction.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Function.h" 12 | #include "PropNode.h" 13 | #include "scone/optimization/Params.h" 14 | 15 | namespace scone 16 | { 17 | /// Parameterizable piece-wise constant function. 18 | class SCONE_API PieceWiseConstantFunction : public Function 19 | { 20 | public: 21 | PieceWiseConstantFunction( const PropNode& props, Params& par ); 22 | virtual ~PieceWiseConstantFunction(); 23 | 24 | /// Number of control points in this function. 25 | size_t control_points; 26 | 27 | /// Parameter for the y value of each control point. 28 | const PropNode& control_point_y; 29 | 30 | /// Parameter for the dt value of each control point. 31 | const PropNode& control_point_dt; 32 | 33 | virtual Real GetValue( Real x ) override; 34 | 35 | // a signature describing the function 36 | virtual String GetSignature() override; 37 | 38 | private: 39 | struct Impl; 40 | u_ptr< Impl > m_pImpl; 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /src/sconestudio/ResultsFileSystemModel.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ResultsFileSystemModel.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | 14 | class ResultsFileSystemModel : public QFileSystemModel 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | ResultsFileSystemModel( QObject* parent ); 20 | virtual ~ResultsFileSystemModel(); 21 | 22 | enum Column { GenCol = 0, ScoreCol = 1, ColCount = 2 }; 23 | virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const override; 24 | 25 | private: 26 | struct Status { 27 | int gen; 28 | double best; 29 | QDateTime modified; 30 | }; 31 | Status getStatus( QFileInfo &fi ) const; 32 | virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; 33 | virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; 34 | virtual Qt::ItemFlags flags( const QModelIndex &index ) const override; 35 | 36 | mutable std::map< std::string, Status > m_StatusCache; 37 | }; 38 | -------------------------------------------------------------------------------- /src/sconestudio/GaitPlot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "scone/core/Storage.h" 7 | #include "scone/core/PropNode.h" 8 | #include "scone/core/types.h" 9 | #include "scone/core/GaitCycle.h" 10 | #include "xo/container/flat_map.h" 11 | #include "xo/numerical/bounds.h" 12 | #include "xo/utility/result.h" 13 | #include "xo/string/pattern_matcher.h" 14 | 15 | class QCustomPlot; 16 | class QCPPlotTitle; 17 | 18 | namespace scone 19 | { 20 | class GaitPlot : public QWidget 21 | { 22 | public: 23 | GaitPlot( const PropNode& pn, QWidget* parent = nullptr ); 24 | virtual ~GaitPlot() {} 25 | 26 | xo::error_message update( const Storage<>& sto, const std::vector& cycles ); 27 | 28 | String title_; 29 | xo::pattern_matcher left_channel_; 30 | xo::pattern_matcher right_channel_; 31 | int row_; 32 | int column_; 33 | String x_label_; 34 | String y_label_; 35 | double y_min_; 36 | double y_max_; 37 | 38 | double channel_offset_; 39 | double channel_multiply_; 40 | double norm_offset_; 41 | 42 | xo::flat_map> norm_data_; 43 | 44 | private: 45 | QCustomPlot* plot_; 46 | QCPPlotTitle* plot_title_; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/data/f0914m.FC2.HighJump.D2.par: -------------------------------------------------------------------------------- 1 | hamstrings.Y0 0.00026331596 0.00024814841 1.285294e-05 2 | hamstrings.DT0 0.19920726 0.19921452 3.8997365e-06 3 | hamstrings.Y1 0.99201547 0.9919846 1.8470549e-05 4 | glut_max.Y0 0.0063964761 0.0064053784 1.8613376e-05 5 | glut_max.DT0 0.51062041 0.51069352 5.6839939e-05 6 | glut_max.Y1 0.99990698 0.9999185 1.2282709e-05 7 | iliopsoas.Y0 0.0085382235 0.0085651855 1.605815e-05 8 | iliopsoas.DT0 0.94723735 0.94736216 6.6674134e-05 9 | iliopsoas.Y1 0.49809736 0.49792814 6.164655e-05 10 | vasti.Y0 0.38584106 0.38584025 1.2181178e-05 11 | vasti.DT0 0.23388261 0.23391267 1.4530068e-05 12 | vasti.Y1 0.99999608 0.99999325 5.9709776e-06 13 | gastroc.Y0 0.0081223631 0.0081265791 1.3552802e-05 14 | gastroc.DT0 0.70536429 0.70543955 5.8567554e-05 15 | gastroc.Y1 0.99890631 0.99891543 9.5543134e-06 16 | soleus.Y0 0.023821622 0.02381144 1.0816287e-05 17 | soleus.DT0 0.68326267 0.68334928 5.8849283e-05 18 | soleus.Y1 0.99997035 0.99997555 7.3082234e-06 19 | tib_ant.Y0 0.9997158 0.99973177 3.3766913e-05 20 | tib_ant.DT0 0.52732806 0.52732469 2.8714264e-05 21 | tib_ant.Y1 0.0093984556 0.0094135705 1.1432936e-05 22 | -------------------------------------------------------------------------------- /src/sconecmd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(sconecmd sconecmd.cpp) 2 | 3 | set_target_properties(sconecmd PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) 4 | 5 | target_include_directories(sconecmd PRIVATE ${TCLAP_DIR} ) 6 | 7 | target_link_libraries(sconecmd sconelib) 8 | 9 | if (MSVC) 10 | target_precompile_headers(sconecmd PRIVATE ) 11 | file (GLOB_RECURSE PRECOMPILED_HEADER_FILES ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cmake_pch.*) 12 | source_group("CMakePCH" FILES ${PRECOMPILED_HEADER_FILES}) 13 | source_group("" FILES sconecmd.cpp) 14 | endif() 15 | 16 | if (SCONE_OPENSIM_3) 17 | target_link_libraries(sconecmd sconeopensim3) 18 | target_compile_definitions(sconecmd PRIVATE SCONE_OPENSIM_3) 19 | endif() 20 | 21 | if (SCONE_OPENSIM_4) 22 | target_link_libraries(sconecmd sconeopensim4) 23 | target_compile_definitions(sconecmd PRIVATE SCONE_OPENSIM_4) 24 | endif() 25 | 26 | if (SCONE_HYFYDY) 27 | target_link_libraries(sconecmd sconehfd) 28 | target_compile_definitions(sconecmd PRIVATE SCONE_HYFYDY) 29 | endif() 30 | 31 | if (SCONE_LUA) 32 | target_link_libraries(sconecmd sconelua) 33 | target_compile_definitions(sconecmd PRIVATE SCONE_LUA) 34 | endif() 35 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/SimilarityObjective.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** SimilarityObjective.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "ModelObjective.h" 12 | #include "xo/filesystem/path.h" 13 | 14 | namespace scone 15 | { 16 | class SimilarityObjective : public ModelObjective 17 | { 18 | public: 19 | SimilarityObjective( const PropNode& props, const path& find_file_folder ); 20 | virtual ~SimilarityObjective() {} 21 | 22 | virtual void AdvanceSimulationTo( Model& m, TimeInSeconds t ) const override; 23 | virtual fitness_t GetResult( Model& m ) const override; 24 | virtual PropNode GetReport( Model& m ) const override; 25 | virtual TimeInSeconds GetDuration() const override { return 0.0; } 26 | virtual result EvaluateModel( Model& m, const xo::stop_token& st ) const override; 27 | 28 | private: 29 | path file_; 30 | ModelObjectiveUP target_; 31 | ModelUP target_model_; 32 | String signature_; 33 | mutable fitness_t result_; 34 | 35 | protected: 36 | virtual String GetClassSignature() const override; 37 | 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/TestObjective.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** TestObjective.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "TestObjective.h" 10 | 11 | #include "spot_test/test_functions.h" 12 | #include "xo/string/string_tools.h" 13 | #include "scone/core/string_tools.h" 14 | 15 | namespace scone 16 | { 17 | double schwefel( const spot::par_vec& v ) 18 | { 19 | double sum = 0.0; 20 | for ( index_t i = 0; i < v.size(); ++i ) 21 | sum += v[ i ] * sin( sqrt( fabs( v[ i ] ) ) ); 22 | return 418.9829 * v.size() - sum; 23 | } 24 | 25 | TestObjective::TestObjective( const PropNode& pn, const path& find_file_folder ) : 26 | Objective( pn, find_file_folder ) 27 | { 28 | INIT_PROP( pn, dim_, 10 ); 29 | 30 | for ( index_t i = 0; i < dim_; ++i ) 31 | info_.add( ParInfo( stringf( "P%d", i ), 0, 200, -500, 500 ) ); 32 | } 33 | 34 | fitness_t TestObjective::evaluate( const SearchPoint& point ) const 35 | { 36 | return schwefel( point.values() ); 37 | } 38 | 39 | String TestObjective::GetClassSignature() const 40 | { 41 | return stringf( "T%d", dim_ ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/CmaOptimizer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** CmaOptimizer.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "CmaOptimizer.h" 10 | #include "xo/string/string_tools.h" 11 | #include "xo/filesystem/filesystem.h" 12 | 13 | namespace scone 14 | { 15 | const long DEFAULT_RANDOM_SEED = 123; 16 | 17 | CmaOptimizer::CmaOptimizer( const PropNode& props, const PropNode& scenario_pn, const path& scenario_dir ) : 18 | Optimizer( props, scenario_pn, scenario_dir ), 19 | mu_( 0 ), 20 | lambda_( 0 ), 21 | sigma_( 1.0 ), 22 | max_attempts( 100 ) 23 | { 24 | INIT_PROP( props, lambda_, 0 ); 25 | INIT_PROP( props, mu_, 0 ); 26 | INIT_PROP( props, sigma_, 1.0 ); 27 | INIT_PROP( props, random_seed, DEFAULT_RANDOM_SEED ); 28 | INIT_PROP( props, flat_fitness_epsilon_, 1e-6 ); 29 | } 30 | 31 | CmaOptimizer::~CmaOptimizer() 32 | {} 33 | 34 | String CmaOptimizer::GetClassSignature() const 35 | { 36 | auto str = Optimizer::GetClassSignature(); 37 | if ( random_seed != DEFAULT_RANDOM_SEED ) 38 | str += xo::stringf( ".R%d", random_seed ); 39 | return str; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/Actuator.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Actuator.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/core/HasName.h" 12 | #include "scone/core/HasData.h" 13 | #include "scone/core/Storage.h" 14 | #include "scone/core/PropNode.h" 15 | #include "xo/container/circular_deque.h" 16 | 17 | namespace scone 18 | { 19 | class SCONE_API Actuator : public virtual HasName, public virtual HasData 20 | { 21 | public: 22 | Actuator(); 23 | virtual ~Actuator(); 24 | 25 | virtual double AddInput( double v ) { return m_ActuatorControlValue += v; } 26 | virtual void ClearInput(); 27 | virtual double GetInput() const { return m_ActuatorControlValue; } 28 | virtual double GetClampedInput() const { return xo::clamped( GetInput(), GetMinInput(), GetMaxInput() ); } 29 | virtual Real GetMinInput() const = 0; 30 | virtual Real GetMaxInput() const = 0; 31 | 32 | virtual void StoreData( Storage< Real >::Frame& frame, const StoreDataFlags& flags ) const override; 33 | virtual PropNode GetInfo() const; 34 | 35 | protected: 36 | double m_ActuatorControlValue; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /scenarios/UnitTests/OpenSim3/data/neural_delays_FEA.pn: -------------------------------------------------------------------------------- 1 | pelvis_tilt = 0.100 2 | pelvis_list = 0.100 3 | pelvis_rotation = 0.100 4 | lumbar_extension = 0.100 5 | lumbar_bending = 0.100 6 | lumbar_rotation = 0.100 7 | 8 | hamstrings = 0.010 9 | glut_max = 0.010 10 | iliopsoas = 0.010 11 | vasti = 0.020 12 | bifemsh = 0.020 13 | gastroc = 0.035 14 | 15 | ercspn = 0.010 16 | intobl = 0.010 17 | extobl = 0.010 18 | glut_med1 = 0.010 19 | glut_med2 = 0.010 20 | glut_med3 = 0.010 21 | glut_min1 = 0.010 22 | glut_min2 = 0.010 23 | glut_min3 = 0.010 24 | glut_max1 = 0.010 25 | glut_max2 = 0.010 26 | glut_max3 = 0.010 27 | semimem = 0.010 28 | semiten = 0.010 29 | bifemlh = 0.010 30 | bifemsh = 0.020 31 | sar = 0.010 32 | add_long = 0.010 33 | add_brev = 0.010 34 | add_mag1 = 0.010 35 | add_mag2 = 0.010 36 | add_mag3 = 0.010 37 | tfl = 0.010 38 | pect = 0.010 39 | grac = 0.010 40 | iliacus = 0.010 41 | psoas = 0.010 42 | quad_fem = 0.010 43 | gem = 0.010 44 | peri = 0.010 45 | rect_fem = 0.010 46 | vas_med = 0.020 47 | vas_int = 0.020 48 | vas_lat = 0.020 49 | med_gas = 0.035 50 | lat_gas = 0.035 51 | soleus = 0.035 52 | tib_post = 0.035 53 | flex_dig = 0.035 54 | flex_hal = 0.035 55 | tib_ant = 0.035 56 | per_brev = 0.035 57 | per_long = 0.035 58 | per_tert = 0.035 59 | ext_dig = 0.035 60 | ext_hal = 0.035 61 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/State.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** State.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "State.h" 10 | 11 | #include 12 | #include "scone/core/Exception.h" 13 | #include "xo/string/string_tools.h" 14 | 15 | namespace scone 16 | { 17 | index_t State::AddVariable( const String& name, Real value ) 18 | { 19 | names_.push_back( name ); 20 | values_.push_back( value ); 21 | return names_.size() - 1; 22 | } 23 | 24 | void State::SetValues( const std::vector& v ) 25 | { 26 | SCONE_ASSERT( values_.size() <= v.size() ); 27 | xo::copy( v.begin(), v.begin() + values_.size(), values_.begin() ); 28 | } 29 | 30 | index_t State::FindIndex( const String& name ) const 31 | { 32 | auto it = std::find( names_.begin(), names_.end(), name ); 33 | if ( it != names_.end() ) 34 | return it - names_.begin(); 35 | else return NoIndex; 36 | } 37 | 38 | index_t State::FindIndexByPattern( const String& pattern, index_t idx ) const 39 | { 40 | for ( ; idx < names_.size(); ++idx ) 41 | if ( xo::pattern_match( names_[ idx ], pattern ) ) 42 | return idx; 43 | return NoIndex; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/deprecated/MetaReflexParams.cpp: -------------------------------------------------------------------------------- 1 | #include "MetaReflexParams.h" 2 | 3 | namespace scone 4 | { 5 | MetaReflexParams::MetaReflexParams( const PropNode& props, Params& par, Model& model, const String& pnp ) 6 | { 7 | Init( props, par, model, pnp ); 8 | } 9 | 10 | void MetaReflexParams::Init( const PropNode& props, Params& par, Model& model, const String& pnp ) 11 | { 12 | if ( model.GetCustomProps() ) 13 | { 14 | if ( const PropNode* mrcprops = model.GetCustomProps()->try_get_child( "meta_reflex_control" ) ) 15 | { 16 | ref_pos = mrcprops->get( "use_ref", true ) ? Degree( par.try_get( "R" + pnp, props, ( "R" + pnp ), 0.0 ) ) : Degree( 0 ); 17 | length_gain = mrcprops->get( "use_length", true ) ? par.try_get( "L" + pnp, props, ( "L" + pnp ), 0.0 ) : 0; 18 | force_gain = mrcprops->get( "use_force", true ) ? par.try_get( "F" + pnp, props, ( "F" + pnp ), 0.0 ) : 0; 19 | constant = mrcprops->get( "use_constant", true ) ? par.try_get( "C" + pnp, props, ( "C" + pnp ), 0.0 ) : 0; 20 | stiffness = mrcprops->get( "use_stiffness", true ) ? par.try_get( "S" + pnp, props, ( "S" + pnp ), 0.0 ) : 0; 21 | symmetry = mrcprops->get( "use_symmetry", true ) ? par.try_get( "sym" + pnp, props, ( "sym" + pnp ), 0.0 ) : 0; 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/ConditionalMuscleReflex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ConditionalMuscleReflex.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "MuscleReflex.h" 12 | #include "scone/core/Angle.h" 13 | #include "scone/core/Range.h" 14 | 15 | namespace scone 16 | { 17 | /// MuscleReflex that is only active when a specific DOF is within a specific range. 18 | class ConditionalMuscleReflex : public MuscleReflex 19 | { 20 | public: 21 | ConditionalMuscleReflex( const PropNode& props, Params& par, Model& model, const Location& loc ); 22 | virtual ~ConditionalMuscleReflex(); 23 | 24 | /// Name of the DoF used for the condition. 25 | Dof& dof; 26 | 27 | /// Maximum dof position [rad or m] for this reflex to be active; default = 1e12. 28 | Real pos_max; 29 | 30 | /// Minimum dof position [rad or m] for this reflex to be active; default = -1e12. 31 | Real pos_min; 32 | 33 | virtual void ComputeControls( double timestamp ) override; 34 | 35 | protected: 36 | SensorDelayAdapter* m_pConditionalDofPos; 37 | SensorDelayAdapter* m_pConditionalDofVel; 38 | Range< Real > m_ConditionalPosRange; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /src/sconelib/scone/optimization/Objective.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Objective.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Params.h" 12 | #include "scone/core/HasSignature.h" 13 | #include "spot/objective.h" 14 | #include "scone/core/system_tools.h" 15 | #include "scone/core/HasExternalResources.h" 16 | 17 | namespace scone 18 | { 19 | using spot::fitness_t; 20 | using spot::result; 21 | 22 | /// Base class for Objectives. 23 | class SCONE_API Objective : public HasSignature, public HasExternalResources, public spot::objective 24 | { 25 | public: 26 | Objective( const PropNode& props, const path& external_resource_dir ); 27 | virtual ~Objective(); 28 | 29 | // write results and return all files written 30 | virtual std::vector< path > WriteResults( const path& file_base ) { return std::vector< path >(); } 31 | const path& GetExternalResourceDir() const { return external_resource_dir_; } 32 | void SetExternalResourceDir( const path& dir ) { external_resource_dir_ = dir; } 33 | 34 | protected: 35 | // this is where external resources of the objective reside 36 | path external_resource_dir_; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /src/sconelib/scone/measures/deprecated/PointMeasure.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Measure.h" 4 | #include "scone/model/Body.h" 5 | #include "scone/core/Range.h" 6 | #include "scone/core/Statistic.h" 7 | 8 | namespace scone 9 | { 10 | class PointMeasure : public Measure 11 | { 12 | public: 13 | PointMeasure( const PropNode& props, Params& par, Model& model, const Location& loc ); 14 | virtual ~PointMeasure() { }; 15 | 16 | virtual bool UpdateMeasure( const Model& model, double timestamp ) override; 17 | virtual double ComputeResult( Model& model ) override; 18 | 19 | protected: 20 | virtual String GetClassSignature() const override; 21 | virtual void StoreData( Storage< Real >::Frame& frame, const StoreDataFlags& flags ) const override; 22 | 23 | private: 24 | String body; 25 | Vec3 offset; 26 | Vec3 axes_to_measure; 27 | bool relative_to_model_com; 28 | 29 | Range< Real > range; 30 | Range< Real > vel_range; 31 | Range< Real > acc_range; 32 | Real squared_range_penalty; 33 | Real abs_range_penalty; 34 | Real squared_velocity_range_penalty; 35 | Real abs_velocity_range_penalty; 36 | Real squared_acceleration_range_penalty; 37 | Real abs_acceleration_range_penalty; 38 | Statistic<> penalty; 39 | 40 | Body* m_pTargetBody; // non-owning pointer 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /src/sconestudio/SconeStorageDataModel.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** SconeStorageDataModel.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "QDataAnalysisView.h" 12 | #include "scone/core/Storage.h" 13 | 14 | class SconeStorageDataModel : public QDataAnalysisModel 15 | { 16 | public: 17 | SconeStorageDataModel( const scone::Storage<>* s = nullptr ); 18 | virtual ~SconeStorageDataModel() {} 19 | 20 | void setStorage( const scone::Storage<>* s ); 21 | virtual size_t seriesCount() const override; 22 | 23 | virtual QString label( int idx ) const override; 24 | 25 | virtual double value( int idx, double time ) const override; 26 | 27 | virtual std::vector< std::pair< float, float > > getSeries( int idx, double min_interval = 0.0 ) const override; 28 | 29 | virtual double timeFinish() const override; 30 | virtual double timeStart() const override; 31 | virtual xo::index_t timeIndex( double time ) const override; 32 | virtual double timeValue( xo::index_t idx ) const override; 33 | 34 | private: 35 | const scone::Storage<>* storage; 36 | bool equidistant_delta_time; 37 | mutable std::pair index_cache; 38 | }; 39 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/NoiseController.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** NoiseController.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "NoiseController.h" 10 | #include "scone/model/Model.h" 11 | #include "scone/model/Actuator.h" 12 | #include "scone/core/string_tools.h" 13 | 14 | namespace scone 15 | { 16 | NoiseController::NoiseController( const PropNode& props, Params& par, Model& model, const Location& loc ) : 17 | Controller( props, par, model, loc ), 18 | random_seed( props.get< unsigned int >( "random_seed", 123 ) ), 19 | rng_( random_seed ) 20 | { 21 | INIT_PROP( props, base_noise, 0 ); 22 | INIT_PROP( props, proportional_noise, 0 ); 23 | } 24 | 25 | bool NoiseController::ComputeControls( Model& model, double timestamp ) 26 | { 27 | for ( auto& a : model.GetActuators() ) 28 | { 29 | auto noise_std = base_noise + proportional_noise * a->GetInput(); 30 | if ( noise_std > 0.0 ) 31 | a->AddInput( rng_.norm( 0.0, noise_std ) ); 32 | } 33 | return false; 34 | } 35 | 36 | String NoiseController::GetClassSignature() const 37 | { 38 | return stringf( "N%02d", xo::round_cast( 100 * proportional_noise ) ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/sconelib/scone/measures/JointLoadMeasure.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** JointLoadMeasure.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Measure.h" 12 | #include "scone/core/Statistic.h" 13 | #include "scone/model/Joint.h" 14 | #include "RangePenalty.h" 15 | 16 | namespace scone 17 | { 18 | /// Measure for penalizing joint load, if above a specific threshold. 19 | /// See RangePenalty for details on how to set range, abs_penalty and squared_penalty. 20 | class JointLoadMeasure : public Measure, public RangePenalty 21 | { 22 | public: 23 | JointLoadMeasure( const PropNode& props, Params& par, const Model& model, const Location& loc ); 24 | 25 | virtual double ComputeResult( const Model& model ) override; 26 | virtual bool UpdateMeasure( const Model& model, double timestamp ) override; 27 | 28 | protected: 29 | virtual String GetClassSignature() const override; 30 | virtual void StoreData( Storage< Real >::Frame& frame, const StoreDataFlags& flags ) const override; 31 | 32 | private: 33 | enum Method { NoMethod, JointReactionForce }; 34 | int method; 35 | Real joint_load; 36 | const Joint& joint; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /src/sconelib/scone/model/Joint.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Joint.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/core/HasName.h" 12 | #include "scone/core/HasData.h" 13 | #include "scone/core/PropNode.h" 14 | #include "scone/core/Vec3.h" 15 | 16 | namespace scone 17 | { 18 | class Dof; 19 | class Body; 20 | class Joint; 21 | 22 | class SCONE_API Joint : public HasName, HasData 23 | { 24 | public: 25 | Joint( Body& body, Body& parent_body ); 26 | virtual ~Joint(); 27 | 28 | virtual Vec3 GetPos() const = 0; 29 | virtual Vec3 GetReactionForce() const = 0; 30 | virtual Real GetLimitMoment() const; 31 | virtual Real GetLimitPower() const = 0; 32 | virtual Real GetLoad() const; 33 | 34 | const Body& GetBody() const { return m_Body; } 35 | const Body& GetParentBody() const { return m_ParentBody; } 36 | 37 | const std::vector< Dof* >& GetDofs() const; 38 | void StoreData( Storage::Frame& frame, const StoreDataFlags& flags ) const override; 39 | virtual PropNode GetInfo() const; 40 | 41 | protected: 42 | Body& m_Body; 43 | Body& m_ParentBody; 44 | mutable std::vector< Dof* > m_Dofs; 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/deprecated/MetaReflexVirtualMuscle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "scone/core/PropNode.h" 4 | #include "scone/optimization/Params.h" 5 | #include "scone/model/Model.h" 6 | #include "scone/model/Locality.h" 7 | #include "scone/model/SensorDelayAdapter.h" 8 | #include "scone/model/Dof.h" 9 | #include "MetaReflexParams.h" 10 | #include 11 | 12 | namespace scone 13 | { 14 | class MetaReflexVirtualMuscle 15 | { 16 | public: 17 | MetaReflexVirtualMuscle( const PropNode& props, Params& par, Model& model, const Locality& area ); 18 | virtual ~MetaReflexVirtualMuscle() {} 19 | 20 | Real GetLocalBalance() { return local_balance; } 21 | void UpdateLocalBalance( const Vec3& global_balance ); 22 | 23 | String name; 24 | 25 | MetaReflexParams mrp; 26 | MetaReflexParams bal_mrp; 27 | Real delay; 28 | 29 | Real GetSimilarity( const Muscle& mus, Real tot_abs_moment_arm ); 30 | size_t GetDofCount() { return dof_infos.size(); } 31 | Vec3 average_moment_axis; 32 | 33 | private: 34 | 35 | struct DofInfo { 36 | Dof& dof; 37 | Real w; 38 | }; 39 | std::vector< DofInfo > dof_infos; 40 | 41 | Real local_balance; 42 | Real body_angvel_sensor_gain; 43 | SensorDelayAdapter* body_ori_sensor; 44 | SensorDelayAdapter* body_angvel_sensor; 45 | Real body_sensor_delay; 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/PieceWiseLinearFunction.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** PieceWiseLinearFunction.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Function.h" 12 | #include "PropNode.h" 13 | #include "scone/optimization/Params.h" 14 | 15 | namespace scone 16 | { 17 | /// Parameterizable piece-wise linear function. 18 | class SCONE_API PieceWiseLinearFunction : public Function 19 | { 20 | public: 21 | PieceWiseLinearFunction( const PropNode& props, Params& par ); 22 | virtual ~PieceWiseLinearFunction(); 23 | 24 | /// Number of control points in this function. 25 | size_t control_points; 26 | 27 | /// Parameter for the y value of each control point. 28 | const PropNode& control_point_y; 29 | 30 | /// Parameter for the dt (delta time [s] from previous point) value of each control point. 31 | const PropNode& control_point_dt; 32 | 33 | /// Flag indicating if value should stay flat after passing the last control point; default = false. 34 | bool flat_extrapolation; 35 | 36 | virtual Real GetValue( Real x ) override; 37 | virtual String GetSignature() override; 38 | 39 | private: 40 | struct Impl; 41 | u_ptr< Impl > m_pImpl; 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /src/sconelib/scone/core/Polynomial.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Polynomial.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "Function.h" 12 | #include "scone/core/string_tools.h" 13 | #include "PropNode.h" 14 | #include "scone/optimization/Params.h" 15 | 16 | namespace scone 17 | { 18 | /// Parameterizable polynomial function. For each coefficient, the parameter can be defined 19 | /// through coefficient0, coefficient1, etc. 20 | class SCONE_API Polynomial : public Function 21 | { 22 | public: 23 | Polynomial( size_t degree ); 24 | Polynomial( const PropNode& props, Params& par ); 25 | virtual ~Polynomial(); 26 | 27 | /// Degree of the polynomial, coefficients are parameterized through coefficient0, coefficient1, etc. 28 | size_t degree; 29 | 30 | virtual Real GetValue( Real x ) override; 31 | virtual Real GetDerivativeValue( Real x ) override; 32 | virtual void SetCoefficient( size_t idx, Real value ); 33 | size_t GetCoefficientCount(); 34 | 35 | // a signature describing the function 36 | virtual String GetSignature() override { return stringf( "P%d", m_Coeffs.size() - 1 ); } 37 | 38 | protected: 39 | std::vector< Real > m_Coeffs; 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /tools/linux_4_package: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | source ./tools/build_config # sets relevant envvar defaults 5 | 6 | # keeping this list as short as possible is the only way to guarantee 7 | # that the resulting `.deb` package will install on multiple versions 8 | # of debian/ubuntu. This is why `scone` packages openscenegraph, 9 | # rather than depending on it via `apt`. 10 | dependencies=( 11 | # transitive: from libosgDB.so 12 | zlib1g 13 | 14 | # transitive: from libosimAnalyses.so 15 | liblapack3 16 | 17 | # scone 18 | freeglut3 19 | qt5-default 20 | libqt5printsupport5 21 | libqt5opengl5 22 | libqt5widgets5 23 | libpng16-16 24 | ) 25 | 26 | cd "${SCONE_BUILD_DIR}" 27 | fpm \ 28 | --force \ 29 | --name "scone" \ 30 | --version "$(cat linux/opt/scone/.version)" \ 31 | --maintainer "Thomas Geijtenbeek " \ 32 | --url "https://github.com/opensim-org/SCONE" \ 33 | --description "open-source software for predictive simulation of biological motion" \ 34 | --license "gnu-3.0" \ 35 | --architecture "x86_64" \ 36 | --input-type "dir" \ 37 | --output-type "deb" \ 38 | \ 39 | ${dependencies[@]/#/--depends } \ 40 | \ 41 | linux/=/ 42 | cd - 43 | 44 | echo "packaging complete" 45 | ls "${SCONE_BUILD_DIR}" 46 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/CompositeController.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** CompositeController.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "scone/controllers/Controller.h" 12 | 13 | namespace scone 14 | { 15 | /// Controller consisting of multiple child controllers. 16 | /// Child Controllers are inserted as children of this parameter, e.g. ''CompositeController { FeedForwardController { ... } ReflexController { ... } }''. 17 | class CompositeController : public Controller 18 | { 19 | public: 20 | CompositeController( const PropNode& props, Params& par, Model& model, const Location& loc ); 21 | virtual ~CompositeController() {} 22 | 23 | virtual bool PerformAnalysis( const Model& model, double timestamp ) override; 24 | virtual void StoreData( Storage::Frame& frame, const StoreDataFlags& flags ) const override; 25 | virtual std::vector WriteResults( const xo::path& file ) const override; 26 | 27 | const PropNode* Controllers; 28 | 29 | protected: 30 | virtual bool ComputeControls( Model& model, double timestamp ) override; 31 | 32 | virtual String GetClassSignature() const override; 33 | std::vector< ControllerUP > controllers_; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/Controller.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Controller.cpp 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #include "Controller.h" 10 | #include "spot/par_tools.h" 11 | 12 | namespace scone 13 | { 14 | Controller::Controller( const PropNode& props, Params& par, Model& model, const Location& target_area ) : 15 | HasSignature( props ), 16 | INIT_MEMBER( props, name, "" ) 17 | { 18 | INIT_PROP( props, disabled_, false ); 19 | INIT_PAR( props, par, start_time, 0.0 ); 20 | INIT_PAR( props, par, stop_time, 0.0 ); 21 | 22 | // add custom parameters 23 | if ( auto par_pn = props.try_get_child( "Parameters" ) ) 24 | { 25 | for ( auto& [key, value] : *par_pn ) 26 | par.get( key, value ); 27 | } 28 | } 29 | 30 | Controller::~Controller() 31 | { 32 | } 33 | 34 | bool Controller::UpdateControls( Model& model, double timestamp ) 35 | { 36 | if ( IsActive( model, timestamp ) ) 37 | return ComputeControls( model, timestamp ); 38 | else return false; 39 | } 40 | 41 | bool Controller::UpdateAnalysis( const Model& model, double timestamp ) 42 | { 43 | if ( IsActive( model, timestamp ) ) 44 | return PerformAnalysis( model, timestamp ); 45 | else return false; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/sconelib/scone/controllers/NoiseController.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** NoiseController.h 3 | ** 4 | ** Copyright (C) 2013-2019 Thomas Geijtenbeek and contributors. All rights reserved. 5 | ** 6 | ** This file is part of SCONE. For more information, see http://scone.software. 7 | */ 8 | 9 | #pragma once 10 | #include "Controller.h" 11 | #include "xo/numerical/random.h" 12 | 13 | namespace scone 14 | { 15 | /// Controller that adds random signals to actuators. 16 | /// For each controller timestep, a random noise is sampled from a normal distribution 17 | /// with a standard deviation of ''base_noise + current_signal * proportional_noise''. 18 | class NoiseController : public Controller 19 | { 20 | public: 21 | NoiseController( const PropNode& props, Params& par, Model& model, const Location& loc ); 22 | virtual ~NoiseController() {} 23 | 24 | /// Standard deviation of the normal distribution; default = 0. 25 | double base_noise; 26 | 27 | /// Proportional standard deviation of the normal distribution; default = 0. 28 | double proportional_noise; 29 | 30 | /// Random seed for noise sampling; default = 123. 31 | unsigned int random_seed; 32 | 33 | protected: 34 | virtual bool ComputeControls( Model& model, double timestamp ) override; 35 | virtual String GetClassSignature() const override; 36 | 37 | xo::random_number_generator rng_; 38 | }; 39 | } 40 | --------------------------------------------------------------------------------