Comments (2)
Hi there!
Casadi does not actually carry actual data, but graph of the code that can generate the results of a computation. Therefore, it is sort of meaningless to get the array, as MX are graphs. Henceforth, there is no such thing as to_array()
, but you can get the graph using to_mx()
.
That said, you can evaluate the graph. You must, however, first convert the graph (the MX) to a casadi.Function
and then you can call that very function to evaluate the graph. I made an easy interface to convert to casadi.Function
in Python. It would look something like:
import biorbd_casadi as casadi
from casadi import MX
import numpy as np
# Get a model
model = biorbd.Model("pendulum.bioMod")
# Create a symbolic variable of dimension (nq x 1) that will be used to create the graph
q_symbolic = MX.sym("q", model.nbQ(), 1)
# Create the casadi function
com_func = biorbd.to_casadi_func('com', model.CoM, q_symbolic) # Alternatively you can create yourself the function using casadi.Function
# Evaluate the graph with actual data
q = np.random.rand(model.nbQ()) # This can also be casadi.DM
com = com_func(q) # This a DM, but can be converted to array using "com = np.array(com)"
print(com)
Hope this helps!
from biorbd.
Interesting, thanks a lot!
from biorbd.
Related Issues (20)
- anticlockwise rotation in .bioMod HOT 1
- getting COM for the whole model HOT 6
- Add ligaments HOT 2
- Choose the muscle characteristic curves instead of a muscle type
- missing euler-cardan sequence yxy HOT 2
- Degree to radian
- Conda install PackagesNotFoundError HOT 3
- Possible to use coordinates of pose estimation with pyomeca? HOT 1
- Issues with the biorbd.model_creation HOT 5
- Create a flag to consider of not the mesh form the model HOT 2
- Declaration LoopConstraint HOT 2
- Constrained EKF HOT 1
- Angular momentum around contact points HOT 4
- Correct presentation of joint angles from biorbd? HOT 16
- Perform inverse dynamics with IMUs and forces from pressure insoles
- Bug in ID with ExternalForceSet ? HOT 6
- SetLocalJCS crash in biorbd_casadi
- Set Symbolic markers HOT 4
- Bug on musculotendon length HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from biorbd.