Comments (1)
Ok, this was simpler than I first thought. In fact the problem is the lack of documentation from my part :)
The function robot_code_to_func
second argument must be a tuple of the type (list of intermediate variables, expression)
. The tuple second element is an expression (or a matrix of expression as it is in the case of the Jacobian), and the first element is a list of intermediate variables for which the expression depends on.
So, if we have no intermediate variables (this is the case), we must pass an empty list; something like ([], expression)
:
J_str = sympybotics.robotcodegen.robot_code_to_func('python', ([], rbt.kin.J[-1]), 'calc_jac', 'jacobian', rbtdef)
The tuple (list of intermediate variables, expression)
has the same structure of the output of the Sympy cse
(common subexpression elimination) function. This function detects common subexpressions in expressions and put them as auxiliary intermediate variables. This is something a C compiler will also do (when optimization is turned on) on the generated code, although the Sympy.cse can be slightly better as it has more mathematical knowledge about the expression.
For the dynamic model, the Sympybotics.RobotDynCode
high level class uses an internal "iteractive" CSE I designed for the purpose. However, the geometric and kinematic parts has no CSE applied.
For the Jacobian, you can produce faster code by doing
J_code = sympy.cse(rbt.kin.J[-1])
J_str = sympybotics.robotcodegen.robot_code_to_func('python', J_code, 'calc_jac', 'jacobian', rbtdef)
(I have a personal script which generates the code for all the transformation matrices and all the Jacobians of all frames of a given robot as a single function, thus sharing the same common subexpressions in a very optimized way. I may release this code later.)
from sympybotics.
Related Issues (20)
- Parameter definition HOT 1
- Error with rbt = sympybotics.RobotDynCode(rbtdef, verbose=True) HOT 12
- How are these matrices T_pcorke, J_pcorke, tau_pcorke obtained? HOT 2
- Negative Torque HOT 1
- NameError: name 'L1' is not defined HOT 3
- How to get the regression matrix of 4 parameters? HOT 2
- > Hi,I solve it
- AttributeError: module 'sympy' has no attribute 'iterables' HOT 7
- Has anyone verified that this algorithm is correct? HOT 6
- function rne_park_forward issue HOT 1
- Regression matrix related to base parameter HOT 1
- Excitation trajectory HOT 1
- symbolic base inertial parameter HOT 1
- Is it possible to generate forward dynamics code? HOT 2
- Is this toolbox suitable for robots with prismatic joints? HOT 1
- what is the "params" in the function? HOT 3
- how to translate the ''min param group" to M, C,G
- Is it possible to construct the dynamics of robot with compliance actuator? HOT 1
- Closed Chain Kinematics
- Is this package suitable for robotic arms containing translational joints? 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 sympybotics.