Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5aad196
osim_to_biomod -> biobuddy
EveCharbie Jul 15, 2025
787e81e
remove model creation
EveCharbie Jul 15, 2025
0cf621b
Example improved python wrapper
pariterre Aug 7, 2025
7fbcdda
Started to add a proper python interface
pariterre Sep 12, 2025
1134bf6
Added segment and external forces to wrapper
pariterre Sep 18, 2025
38678f2
Added ignores for forward and inverse dynamics
pariterre Sep 18, 2025
0752b1f
Separated into small files and added forward_kinematics
pariterre Sep 18, 2025
b54597a
Updated inverse_dynamics example
pariterre Sep 18, 2025
49b8cb7
Added kalman filter interface
pariterre Sep 19, 2025
53a6d30
Added Static optimization to interface
pariterre Sep 19, 2025
6a62077
Added tests for static optim and kalman
pariterre Sep 19, 2025
4210001
Fixed a bug in forward kinematics
pariterre Sep 19, 2025
264cd7d
Fixed segfault in markers
pariterre Sep 19, 2025
266c65f
Added muscles manipulation to python wrapper
pariterre Sep 19, 2025
335b247
Added jacobian to markers
pariterre Sep 19, 2025
abd610b
WIP
pariterre Sep 22, 2025
c944d83
Added segment frame and augmented muscles
pariterre Sep 23, 2025
11d423a
renamed markers to marker
pariterre Sep 23, 2025
c4773b1
Added more interface
pariterre Sep 23, 2025
86f1450
Adapted model tests to casadi
pariterre Sep 23, 2025
53b9c6d
Added markers to casadi tests
pariterre Sep 23, 2025
ed735c2
Finished testing python casadi wrapper
pariterre Sep 24, 2025
efccc89
Added the wrapper folder to install
pariterre Sep 24, 2025
9c51c29
Updated again
pariterre Sep 24, 2025
04bb7c4
Fixed some tests
pariterre Sep 24, 2025
16e408d
Bumped to 1.12.0
pariterre Sep 24, 2025
fe02c40
Merge remote-tracking branch 'EveCharbie/readme' into python_wrapper
pariterre Sep 24, 2025
5a69a4d
Show error messages in tests for debug
pariterre Sep 24, 2025
03d82ee
Fixed tests only designed for eigen
pariterre Sep 24, 2025
1de17cf
Typo in skip test condition
pariterre Sep 24, 2025
505fb4c
Higher tolerance on ipopt based test
pariterre Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
"version": "0.2.0",
"configurations": [
{
"name": "Forward dynamics Python example",
"name": "Python: Current example file",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/examples/python3/forward_dynamics.py",
"program": "${file}",
"cwd": "${workspaceFolder}/examples/python3",
"console": "integratedTerminal",
"justMyCode": false,
"justMyCode": false
},
{
"name": "Python: Current test file",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"cwd": "${workspaceFolder}/test/binding/python3",
"console": "integratedTerminal",
"justMyCode": false
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@
"[cpp]": {
"editor.defaultFormatter": "ms-vscode.cpptools"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.rulers": [
120
],
}
}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.17)

project(biorbd VERSION 1.11.3)
project(biorbd VERSION 1.12.0)
set(BIORBD_ROOT_FOLDER ${PROJECT_SOURCE_DIR})
set (BIORBD_NAME_NO_SUFFIX ${PROJECT_NAME})
set (CMAKE_CXX_STANDARD 11)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,10 @@ The tag `r` represented the width of the curve based of the torque-angle relatio
...

## Convert from OpenSim models
For users who have well-established models in OpenSim and wish to convert them to a `.bioMod`, there's a handy tool called Osim_to_biomod.
For users who have well-established models in OpenSim and wish to convert them to a `.bioMod`, there's a handy tool called BioBuddy.
This package facilitates the conversion process, ensuring that OpenSim models can be seamlessly integrated into our ecosystem.

To get started with the Osim_to_biomod package, please refer to its documentation and source code available at [Osim_to_biomod](https://github.com/pyomeca/osim_to_biomod) GitHub Repository.
To get started with the BioBuddy package, please refer to its documentation and source code available at [BioBuddy](https://github.com/pyomeca/biobuddy) GitHub Repository.

Let us know if you'd like any further modifications!

Expand Down
4 changes: 4 additions & 0 deletions binding/python3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ file(GLOB PYTHON_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.py")
INSTALL(FILES ${PYTHON_FILES}
DESTINATION "${Python3_SITELIB_INSTALL}/${BIORBD_PYTHON_DIR}"
)
file(GLOB PYTHON_FILES "${CMAKE_CURRENT_SOURCE_DIR}/wrapper/*.py")
INSTALL(FILES ${PYTHON_FILES}
DESTINATION "${Python3_SITELIB_INSTALL}/${BIORBD_PYTHON_DIR}/wrapper"
)

# Check if swig has its version 3 or 4, to choose the right place to put the library
if(${SWIG_VERSION} MATCHES "^3(\.[0-9]*)*$")
Expand Down
35 changes: 26 additions & 9 deletions binding/python3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
import numpy as np
from . import biorbd # This is created while installing using CMake
from .biorbd import *
from ._version import __version__
from .surface_max_torque_actuator import *
from .rigid_body import *
from .utils import *
from .wrapper import *
from .wrapper import has_static_optimization, has_extended_kalman_filter


if biorbd.currentLinearAlgebraBackend() == 1:
from casadi import Function, MX, SX, horzcat
if biorbd.currentLinearAlgebraBackend() == biorbd.CASADI:
from casadi import MX, SX, Function, horzcat

def to_casadi_func(name, func, *all_param, expand=True):
backend = biorbd.CASADI

def to_casadi_func(name, func, *all_param, expand=True, **kwargs):
cx_param = []
for p in all_param:
if isinstance(p, (MX, SX)):
cx_param.append(p)
for value in kwargs.values():
if isinstance(value, (MX, SX)):
cx_param.append(value)

if isinstance(func, (MX, SX, Function)):
func_evaluated = func
func_evaluated = [func]
else:
func_evaluated = func(*all_param)
func_evaluated = func(*all_param, **kwargs)
if isinstance(func_evaluated, (list, tuple)):
func_evaluated = horzcat(*[val if isinstance(val, MX) else val.to_mx() for val in func_evaluated])
func_evaluated = [val if isinstance(val, MX) else val.to_mx() for val in func_evaluated]
elif not isinstance(func_evaluated, MX):
func_evaluated = func_evaluated.to_mx()
func = Function(name, cx_param, [func_evaluated])
func_evaluated = [func_evaluated.to_mx()]
else:
func_evaluated = [func_evaluated]
func = Function(name, cx_param, func_evaluated)
return func.expand() if expand else func

elif biorbd.currentLinearAlgebraBackend() == biorbd.EIGEN3:
backend = biorbd.EIGEN3

def to_casadi_func(name, func, *all_param, expand=True):
raise RuntimeError("to_casadi_func is only available with the CASADI backend")

else:
raise RuntimeError("Unknown backend")
19 changes: 19 additions & 0 deletions binding/python3/wrapper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from .biorbd_model import Biorbd
from .extended_kalman_filter import ExtendedKalmanFilterMarkers, has_extended_kalman_filter
from .external_force_set import ExternalForceSet
from .marker import Marker
from .muscle import Muscle
from .segment_frame import SegmentFrame
from .segment import Segment
from .static_optimization import StaticOptimization, has_static_optimization

__all__ = [
Biorbd.__name__,
ExtendedKalmanFilterMarkers.__name__,
ExternalForceSet.__name__,
Marker.__name__,
Muscle.__name__,
SegmentFrame.__name__,
Segment.__name__,
StaticOptimization.__name__,
]
Loading
Loading