Skip to content

Commit b4ba7ca

Browse files
authored
Use swig4.2 or later (#3985)
* Loosen swig version to 4.1.1 or higher * Do without R specification that SWIG fails to parse * SWIG out problematic signatures that break swig 4.2+ * A bit cleaner way to separate the scripting capable signature of createPeriodicTrajectory * Update MocoUtilities.h undo formatting changes for non-swig side for cleaner diff
1 parent 3783fbe commit b4ba7ca

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

Bindings/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if(BUILD_PYTHON_WRAPPING OR BUILD_JAVA_WRAPPING)
2-
find_package(SWIG 4.1.1 EXACT REQUIRED)
2+
find_package(SWIG 4.1.1 REQUIRED)
33
endif()
44

55
# Flags are both Python and Java bindings will use.

OpenSim/Common/DelimFileAdapter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ DelimFileAdapter<T>::clone() const {
307307
template<typename T>
308308
typename DelimFileAdapter<T>::OutputTables
309309
DelimFileAdapter<T>::extendRead(const std::string& fileName) const {
310+
#ifndef SWIG
310311
OPENSIM_THROW_IF(fileName.empty(),
311312
EmptyFileName);
312313

@@ -468,6 +469,7 @@ DelimFileAdapter<T>::extendRead(const std::string& fileName) const {
468469
output_tables.emplace(tableString(), table);
469470

470471
return output_tables;
472+
#endif
471473
}
472474

473475
template<typename T>

OpenSim/Moco/MocoUtilities.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ OSIMMOCO_API void prescribeControlsToModel(const MocoTrajectory& trajectory,
117117
OSIMMOCO_API MocoTrajectory simulateTrajectoryWithTimeStepping(
118118
const MocoTrajectory& trajectory, Model model,
119119
double integratorAccuracy = SimTK::NaN);
120-
120+
#ifndef SWIG
121121
/// Convert a trajectory covering half the period of a symmetric motion into a
122122
/// trajectory over the full period. This is useful for simulations of half a
123123
/// gait cycle.
@@ -171,12 +171,23 @@ OSIMMOCO_API MocoTrajectory createPeriodicTrajectory(
171171
".*lumbar_bending(?!/value).*",
172172
".*lumbar_rotation.*"},
173173
std::vector<std::string> negateAndShiftPatterns = {
174-
".*pelvis_list/value",
175-
".*pelvis_tz/value",
176-
".*lumbar_bending/value"},
174+
".*pelvis_list/value",
175+
".*pelvis_tz/value",
176+
".*lumbar_bending/value"},
177177
std::vector<std::pair<std::string, std::string>> symmetryPatterns =
178178
{{R"(_r(\/|_|$))", "_l$1"}, {R"(_l(\/|_|$))", "_r$1"}});
179-
179+
#else
180+
// Variant that doesn't take symmetryPatterns which are unusable from scripting
181+
OSIMMOCO_API MocoTrajectory createPeriodicTrajectory(
182+
const MocoTrajectory& halfPeriodTrajectory,
183+
std::vector<std::string> addPatterns = {".*pelvis_tx/value"},
184+
std::vector<std::string> negatePatterns = {".*pelvis_list(?!/value).*",
185+
".*pelvis_rotation.*", ".*pelvis_tz(?!/value).*",
186+
".*lumbar_bending(?!/value).*", ".*lumbar_rotation.*"},
187+
std::vector<std::string> negateAndShiftPatterns = {
188+
".*pelvis_list/value", ".*pelvis_tz/value",
189+
".*lumbar_bending/value"});
190+
#endif
180191
/// This obtains the value of the OPENSIM_MOCO_PARALLEL environment variable.
181192
/// The value has the following meanings:
182193
/// - 0: run in series (not parallel).

0 commit comments

Comments
 (0)