Coder Social home page Coder Social logo

cdsousa / sympybotics Goto Github PK

View Code? Open in Web Editor NEW
191.0 13.0 81.0 714 KB

[UNMAINTAINED] Symbolic Framework for Modeling and Identification of Robot Dynamics

License: Other

Shell 0.06% Python 99.94%
unmaintained robot-dynamics identification python sympy

sympybotics's Introduction

SymPyBotics

Symbolic Framework for Modeling and Identification of Robot Dynamics

Uses Sympy and Numpy libraries.

Build Status

Citation:

DOI

Example

Definition of a 2 DOF example robot:

>>> import sympy
>>> import sympybotics
>>> rbtdef = sympybotics.RobotDef('Example Robot', # robot name
...                               [('-pi/2', 0, 0, 'q+pi/2'),  # list of tuples with Denavit-Hartenberg parameters
...                                ( 'pi/2', 0, 0, 'q-pi/2')], # (alpha, a, d, theta)
...                               dh_convention='standard' # either 'standard' or 'modified'
...                              )
>>> rbtdef.frictionmodel = {'Coulomb', 'viscous'} # options are None or a combination of 'Coulomb', 'viscous' and 'offset'
>>> rbtdef.gravityacc = sympy.Matrix([0.0, 0.0, -9.81]) # optional, this is the default value
>>> rbtdef.dynparms()
[L_1xx, L_1xy, L_1xz, L_1yy, L_1yz, L_1zz, l_1x, l_1y, l_1z, m_1, fv_1, fc_1, L_2xx, L_2xy, L_2xz, L_2yy, L_2yz, L_2zz, l_2x, l_2y, l_2z, m_2, fv_2, fc_2]

L is the link inertia tensor computed about the link frame; l is the link first moment of inertia; m is the link mass. These are the so-called barycentric parameters, with respect to which the dynamic model is linear.

Generation of geometric, kinematic and dynamic models:

>>> rbt = sympybotics.RobotDynCode(rbtdef, verbose=True)
generating geometric model
generating kinematic model
generating inverse dynamics code
generating gravity term code
generating coriolis term code
generating coriolis matrix code
generating inertia matrix code
generating regressor matrix code
generating friction term code
done
>>> rbt.geo.T[-1]
Matrix([
[-sin(q1)*sin(q2), -cos(q1),  sin(q1)*cos(q2), 0],
[ sin(q2)*cos(q1), -sin(q1), -cos(q1)*cos(q2), 0],
[         cos(q2),        0,          sin(q2), 0],
[               0,        0,                0, 1]])
>>> rbt.kin.J[-1]
Matrix([
[0,        0],
[0,        0],
[0,        0],
[0, -cos(q1)],
[0, -sin(q1)],
[1,        0]])

C function generation:

>>> tau_str = sympybotics.robotcodegen.robot_code_to_func('C', rbt.invdyn_code, 'tau_out', 'tau', rbtdef)

Doing print(tau_str), function code will be output:

void tau( double* tau_out, const double* parms, const double* q, const double* dq, const double* ddq )
{
  double x0 = sin(q[1]);
  double x1 = -dq[0];
  double x2 = -x1;
  double x3 = x0*x2;
  double x4 = cos(q[1]);
  double x5 = x2*x4;
  double x6 = parms[13]*x5 + parms[15]*dq[1] + parms[16]*x3;
  double x7 = parms[14]*x5 + parms[16]*dq[1] + parms[17]*x3;
  double x8 = -ddq[0];
  double x9 = -x4;
  double x10 = dq[1]*x1;
  double x11 = x0*x10 + x8*x9;
  double x12 = -x0*x8 - x10*x4;
  double x13 = 9.81*x0;
  double x14 = 9.81*x4;
  double x15 = parms[12]*x5 + parms[13]*dq[1] + parms[14]*x3;

  tau_out[0] = -parms[3]*x8 + x0*(parms[14]*x11 + parms[16]*ddq[1] + parms[17]*x12 - dq[1]*x15 - parms[19]*x14 + x5*x6) - x9*(parms[12]*x11 + parms[13]*ddq[1] + parms[14]*x12 + dq[1]*x7 + parms[19]*x13 - x3*x6);
  tau_out[1] = parms[13]*x11 + parms[15]*ddq[1] + parms[16]*x12 - parms[18]*x13 + parms[20]*x14 + x15*x3 - x5*x7;

  return;
}

Dynamic base parameters:

>>> rbt.calc_base_parms()
>>> rbt.dyn.baseparms
Matrix([
[L_1yy + L_2zz],
[         fv_1],
[         fc_1],
[L_2xx - L_2zz],
[        L_2xy],
[        L_2xz],
[        L_2yy],
[        L_2yz],
[         l_2x],
[         l_2z],
[         fv_2],
[         fc_2]])

Author

Cristóvão Duarte Sousa

Install

From git source:

git clone https://github.com/cdsousa/SymPyBotics.git
cd sympybotics
python setup.py install

License

New BSD license. See License File

sympybotics's People

Contributors

cdsousa avatar neka-nat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sympybotics's Issues

Regression matrix related to base parameter

Hi, This is a really great job. I got a question about how to get the Matrix with the base parameter. Is there any way to get that? I tried to use the rank of the Regression matrix and find the linear transformation matrix but it is too complex...

Has anyone verified that this algorithm is correct?

When I was identifying the inertia parameters of the fifth joint, I found that the torque of the fifth joint obtained by the Newton Euler inverse dynamic equation was not equal to the torque value of the fifth joint obtained by this method. Is this the problem of this algorithm? I think my Newton Euler iterative method should not have problems. Is that the problem with this method?

can't generate python code from symbolic Jacobian or

The code generation for the mass, Coriolis, gravity terms all work great. However when I try to generate code from the symbolic Jacobian or the forward kinematics (T), it fails. Running the following command:

J_str = sympybotics.robotcodegen.robot_code_to_func('python', rbt.kin.J[-1], 'calc_jac', 'jacobian', rbtdef)

Results in the following error:

TypeError Traceback (most recent call last)
/home/killpack/git/byu/development/sandbox_levi/baxter_sympybotics/ in ()
----> 1 J_str = sympybotics.robotcodegen.robot_code_to_func('python', rbt.kin.J[-1], 'calc_jac', 'jacobian', rbtdef)

/usr/local/lib/python2.7/dist-packages/sympybotics-0.3_git-py2.7.egg/sympybotics/robotcodegen.pyc in robot_code_to_func(lang, code, outputname, funcname, rbtdef)
33
34 code_symbols = set()
---> 35 for iv, se in code[0]:
36 code_symbols.update(se.free_symbols)
37 for e in code[1]:

TypeError: 'Add' object is not iterable

This is an awesome library and I'm sure there is something simple I'm not doing. More documentation or a simple example similar to the one on the front page would be great.

best,
Marc Killpack

Example code crashes

The example crashes when creating the kinematics model.

>>> rbt = sympybotics.RobotDynCode(rbtdef, verbose=True)
generating geometric model
generating kinematic model
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympybotics/robotmodel.py", line 52, in __init__
    self.kin = Kinematics(self.rbtdef, self.geo)
  File "sympybotics/kinematics.py", line 30, in __init__
    p_ext = geom.p + [sympy.zeros(3, 1)]
TypeError: zeros() takes exactly 1 argument (2 given)

Tutorial would be nice

Hi! Great work. Unfortunately I do not understand all details. A tutorial would be nice, where you (graphically) describe, what are the parameters to set up a robot and work with your functions.
E.g. you wrote 'q+pi/2' and so on: What is q?

got an error of "NameError: global name 'math' is not defined" by the example in site

Hi, I try to create the robot base paramters with the code in the readme.md.

 rbtdef = sympybotics.RobotDef('Example Robot', # robot name
                              [('-pi/2', 0, 0, 'q+pi/2'),  # list of tuples with Denavit-Hartenberg parameters
                                ( 'pi/2', 0, 0, 'q-pi/2')], # (alpha, a, d, theta)
                              dh_convention='standard' # either 'standard' or 'modified')
rbtdef.gravityacc = sympy.Matrix([0.0, 0.0, -9.81]) # optional, this is the default value
rbt = sympybotics.RobotDynCode(rbtdef, verbose=True)
rbt.calc_base_parms()

and I got this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build\bdist.win-amd64\egg\sympybotics\robotmodel.py", line 122, in calc_base_parms
  File "build\bdist.win-amd64\egg\sympybotics\dynamics\dynamics.py", line 55, in calc_base_parms
  File "build\bdist.win-amd64\egg\sympybotics\dynamics\dyn_parm_dep.py", line 22, in find_dyn_parm_deps
  File "<string>", line 6, in regressor_func
NameError: global name 'math' is not defined

I try to fix it to add "import math", but I can not fide where I can add.
so how to do?
I am running in Python 2.7.15 with the last verstion of Sympy and Numpy libraries (installed by pip).
Thank you

Dynamic Parameters

In the test examples, the dynamic parameters values (dynparm_test) were used to generate Centrifugal, inertial, gravity matrices. The dynamic parameters values (dynparm_test) were given as a row vector as a input. I would like to know in which way the row vector had to be constructed ( for eg (m_1 r_x r_y r_z ....) or (r_x r_y r_z m_1.....)). I tried to figure it out by comparing the values used in test examples with the peter corke's puma560 (p560.dyn()) but some values did not match and i could not figure it out.

Also is there a possibility to generate symbolic representation of forward dynamics of any robot (with torque and dynamic parameters as input) using this software ?

Latex

Is there a way of outputing to latex?
For example, a proof?

Base and tool transform along with dh_parameter of robot

What if my base is transformed to say, 90 deg in Y direction adn so does homogenous transformation changes. How would I be able to add the base related geometry so that my dynamics would take care of the issue. Same with the tool transform

If I used symbol represent D-H parameter, “NameError: name 'a2' is not defined” appeared when executed "rbt.calc_base_parms()".

rbtdef = sympybotics.RobotDef('UR5', # robot name
[(0, 0, 'd1','q'), # list of tuples with Denavit-Hartenberg parameters
('pi/2', 0,0, 'q'),
( 0, 'a2',0, 'q'),
( 0, 'a3','d4', 'q'),
( 'pi/2', 0,'d5', 'q'),
('-pi/2', 0,'d6', 'q'),], # (alpha, a, d, theta)
dh_convention='modified' # either 'standard' or 'modified'
)
......
rbt.calc_base_parms()
It will appear "NameError: name 'a2' is not defined", what can I do to repair it?
Thank you very much!

How to get the regression matrix of 4 parameters?

Since I want to do adaptive control, through this equation M(q)·v_dot+C(q,q_dot)·v+G=Y(q,q_dot,v,v_dot), finally get the regression matrix of four parameters , Can I generate such a matrix by changing the code?

old code to generate Coriolis matrix (instead of a vector) no longer works

I believe this is related to my previous issue that was due to a simple change in API. However, at one point, the author of this package shared a file with me for taking a partial derivative of symbolic code. I used this for generating a symbolic Coriolis matrix instead of a vector. I'm sure if I knew sympy and sympybotics better, there would be a simpler way, however, this function below and the code that called it worked in the past:

# used for differentiating code with respect to x                                                                                          
def code_diff( code, x ):
    ivars = code[0]
    exprs = code[1]
    ivars_diff = []
    exprs_diff = []

    d_dx = dict() # to store derivative symbols                                                                                            
    d_dx[x] = sympy.sympify(1) # the derivative of a variable relatively to itself is 1                                                    

    for ivar,f in ivars:

        # chain rule for composite functions                                                                                               
        # df/dx = sum_vi dvi/dx*dvi/dx:                                                                                                    
        df_dx = sympy.sympify(0)
        for v in f.free_symbols:
            if v in d_dx: # if v is not in d_dx it is because its derivative is 0                                                          
                df_dx += f.diff(v) * d_dx[v] # df/dx += df(v)/dv * dv(x)/dx                                                                

        d_ivar = sympy.Symbol('d'+str(ivar),real=True)

        d_dx[ivar] = d_ivar

        ivars_diff.append( (ivar,f) )
        ivars_diff.append( (d_ivar,df_dx) )

    for f in exprs:
        df_dx = sympy.sympify(0)
        for v in f.free_symbols:
            if v in d_dx:
                df_dx += f.diff(v) * d_dx[v]
        exprs_diff.append( df_dx )

    return (ivars_diff,exprs_diff)

I call this function as follows to generate first a list of symbolic expressions and then python code which is the partial derivative of the mass matrix with respect to each joint that I write to file:

# the partial derviative of the mass matrix with respect to each joint, this is used to calculate Coriolis matrix                          
dMdq = [ ]
for i in xrange(rbt.dof):
    dMdq.append(code_diff(rbt.M_code, rbt.rbtdef.q[i]))

for i in xrange(len(dMdq)):                                                                                                        
    func_buf = sympybotics.robotcodegen.robot_code_to_func( 'python',  dMdq[i], 'dMdq_out'+str(i), 'dMdq'+str(i), rbtdef )

We then used this to calculate each entry of the Coriolis matrix. However, now this code throws the following error when I run it (this is from ipython):

--> 156     func_buf = sympybotics.robotcodegen.robot_code_to_func( 'python',  dMdq[i], 'dMdq_out'+str(i), 'dMdq'+str(i), rbtdef )


/usr/local/lib/python2.7/dist-packages/sympybotics-0.3_git-py2.7.egg/sympybotics/robotcodegen.pyc in robot_code_to_func(lang, code, outputname, funcname, rbtdef)
     36         code_symbols.update(se.free_symbols)
     37     for e in code[1]:
---> 38         for ei in e:
     39             code_symbols.update(ei.free_symbols)
     40 

TypeError: 'Add' object is not iterable

Any thoughts on why this is failing would be great. If there is an easier way to modify the current Coriolis calculation to get the matrix form in addition to the vector form (which should just be factoring a joint velocity from every symbolic term), that would be great too.

Thanks a lot.

Barycentric Parameters

hello,
I would like to know that the barycentric parameters you gave is based on the frame attached to joint or to the mass center of the link.
thanks!

Is it possible to construct the dynamics of robot with compliance actuator?

The examples and code given focus on the modeling of rigid joint robots, but for robots with flexibility, such as series elastic actuators, it does not seem possible to calculate the regression matrix directly with this tool. I noticed that when defining the robot, the simplified motor dynamics model could be introduced into the total model, which would introduce a new inertia parameter {I_a} about the linkage variable {q} rather than the motor variable {theta}. Therefore, is it possible to modify some place to adapt to compliance actuator?

What is the mean of "+/-pi/2" in Kinematic symbol “theta”?

Sorry, I don't understand the mean of "+/-pi/2" in Kinematic symbol “theta”. Looking forward to your reply, Thank you very much.
e.g.
rbtdef = sympybotics.RobotDef('Example Robot', # robot name
... [('-pi/2', 0, 0, 'q+pi/2'), # list of tuples with Denavit-Hartenberg parameters
... ( 'pi/2', 0, 0, 'q-pi/2')], # (alpha, a, d, theta)
... dh_convention='standard' # either 'standard' or 'modified'
... )

Closed Chain Kinematics

Does this library support robots with closed chain kinematic links, such as the parallel delta robot?

Excitation trajectory

Great work!
I want to optimize the excitation trajectory, but I don't know how to get the W (linear independent regression matrix). And if I get the W, should I optimize all W(t) (cause the trajectory has about 10 seconds)or just find the W(t0) with the max cond number and optimize that or make a super big matrix W include all the data and optmize....
Thank you so much for this project. Hope I can get your advice. Thank you!

NameError: name 'L1' is not defined

Hi,

I am trying to run the my code step by step in the Python Shell.
When I put rbt.calc_base_parms(), I got the following errors.
Please give me any advice to fix this issue.

generating geometric model
generating kinematic model
generating inverse dynamics code
generating gravity term code
generating coriolis term code
generating coriolis matrix code
generating inertia matrix code
generating regressor matrix code
generating friction term code
done
Traceback (most recent call last):
File ".\symbotics_test.py", line 22, in
rbt.calc_base_parms()
File "D:\Program Files\python3.7\lib\site-packages\sympybotics-1.0.dev0-py3.7.egg\sympybotics\robotmodel.py", line 122, in calc_base_parms
File "D:\Program Files\python3.7\lib\site-packages\sympybotics-1.0.dev0-py3.7.egg\sympybotics\dynamics\dynamics.py", line 55, in calc_base_parms
File "D:\Program Files\python3.7\lib\site-packages\sympybotics-1.0.dev0-py3.7.egg\sympybotics\dynamics\dyn_parm_dep.py", line 22, in find_dyn_parm_deps
File "", line 6, in regressor_func
NameError: name 'L1' is not defined

This is my code:

import sympy
import sympybotics
from sympybotics._compatibility_ import exec_

pi = sympy.pi
q = sympybotics.robotdef.q
L1,L2 = sympy.symbols('L1,L2')


twolink = sympybotics.RobotDef('twolink',[(0,0,0,q),
                                         (0,L1,0,q)],
                              dh_convention='modified')

twolink.frictionmodel = {'Coulomb', 'viscous'}
twolink.gravityacc = sympy.Matrix([0.0, 0.0, 'g'])
rbt = sympybotics.RobotDynCode(twolink, verbose=True)

rbt.calc_base_parms()
rbt.dyn.baseparms

how to return a regression matrix

hi,
I got the base parameters from your example, but have no idea how to get the regression matrix since it's important for identification. Do you have an exmaple about returning the regression matrix, that would help a lot, thanks.

tau_str = sympybotics.robotcodegen.robot_code_to_func('C', rbt.invdyn_code, 'tau_out', 'tau', rbtdef) print(tau_str)

Is this line of code used to generate torque expression?
What is the mean of the expression of "parms[]"?
Thank you very much.

double x0 = sin(q[1]);
double x1 = cos(q[1]);
double x2 = dq[0]x1;
double x3 = ddq[0]x0 + dq[1]x2;
double x4 = ddq[0]x1;
double x5 = dq[0]x0;
double x6 = -dq[1];
double x7 = x4 + x5
x6;
double x8 = -0.31
((x0)
(x0)) - 0.31
((x1)
(x1));
double x9 = 0.31dq[1];
double x10 = x4
x8 + x5x9;
double x11 = x2
x8;
double x12 = -parms[16];
double x13 = parms[17]x5 + parms[19]x11 + x12x2;
double x14 = cos(q[2]);
.......
tau_out[0] = ddq[0]parms[3] + x0(ddq[1]parms[12] + parms[10]x3 + parms[11]x7 + parms[17]x10 + x13x9 + x14x44 + x15x38 + x2x39 + x32
x46 + x37x47 + x45x6) + x1x8(parms[17]x3 + parms[19]x10 + parms[26]x22 + parms[29]x10 + x12x7 + x17x36 + x19x28 + x2x52 + x42x51 + x47x5) + x1*(ddq[1]parms[14] + dq[1]x48 + parms[11]x3 + parms[13]x7 + parms[18]x31 + x10x12 + x11x49 + x15x44 + x16x38 + x39x50);
tau_out[1] = ddq[1]parms[15] + 0.31ddq[1]parms[16] + 0.31dq[1]x49 + parms[12]x3 + parms[14]x7 + parms[16]x32 - parms[17]x31 + 0.31parms[19]x32 + 0.31x13x50 + 0.31x15(parms[28]x20 + parms[29]x33 + x22x30 + x23x42 + x29x43) + 0.31x16(parms[27]x19 + parms[29]x40 + x20x26 + x21x29 + x34x36) - x2x48 + 0.31x3x46 + x45x5 + x52x9 + x53;
tau_out[2] = x53;

How can I get the regressor matrix of a robot?

Hi, it is a great work!
But I am trying to get the regressor matrix of a robot and I use: rbt.Hb_code and rbt.H_code. The resulting output is ([(x0, \ddot{q}_1), (x1, 50*\ddot{q}_1), (x2, -\dot{q}_2), (x3, cos(q2)), (x4, \dot{q}_1), (x5, x3*x4), (x6, x2*x5), (x7, sin(q2)), (x8, -x3), (x9, x4*x7), (x10, x2*x9), (x11, x0*x3 + x10), (x12, -x2), (x13, x12*x5), (x14, x0*x7), (x15, x13 + x14), (x16, x10 + x11), (x17, -x7), (x18, x16*x17), (x19, -\ddot{q}_2), (x20, x5*x9), (x21, x19 + x20), (x22, x2**2),...
I am not quite understand the meaning of these x, they seem not related to the dynamic parameters. So how can I get the right regressor matrix of a robot?

function rne_park_forward issue

In this function,
dV[i] = ifunc(geom.S[i] * rbtdef.ddq[i]) +
ifunc(Adj(geom.Tdh_inv[i], dV[i - 1])) +
ifunc(adj(ifunc(Adj(geom.Tdh_inv[i], V[i - 1])),
ifunc(geom.S[i] * rbtdef.dq[i])))

but I think
dV[i] = ifunc(geom.S[i] * rbtdef.ddq[i]) +
ifunc(Adj(geom.Tdh_inv[i], dV[i - 1])) +
ifunc(adj(ifunc(Adj(geom.Tdh_inv[i], V[i - 1]) +ifunc(geom.S[i] * rbtdef.dq[i])),
ifunc(geom.S[i] * rbtdef.dq[i])))

beccause the bold font content should be the adjoint matrix of twist V[i]。

How to Obtain Observation Matrix?

when i get the Dynamic base parameters by code of 'rbt.calc_base_parms() rbt.dyn.baseparms'
how can i know the Observation Matrix at this point,and transformation matrix from parameters to Dynamic base parameters.
Thank you

Generate Direct Dynamics C Code

Does this package generate direct dynamics c code?

I was able to get inv_dyn but would like to have a function that takes (q, qdot , tau) and calculates qdotdot.

Parameter definition

Hey, thanks for providing this very useful tool.
I was not 100% sure, how to interprete your description of the barycentric parameters:
"L is the link inertia tensor computed about the link frame; l is the link first moment of inertia; m is the link mass. These are the so-called barycentric parameters, with respect to which the dynamic model is linear."

Am I right, that small l is the [x,y,z] vector from the i-th link frame origin to the i-th link center of mass in terms of the i-th link frame?

what is the "params" in the function?

void g_code( double* G, const double* parms )
{
//
  G[0] = 9.81*parms[21] + 9.81*parms[33] + 9.81*parms[45] + 9.81*parms[9];
  G[1] = 0;
  G[2] = 0;
  G[3] = 0;
//
  return;
}

Error with rbt = sympybotics.RobotDynCode(rbtdef, verbose=True)

Hi,

I am trying to run the example code step by step in the Python Shell.
When I put rbt = sympybotics.RobotDynCode(rbtdef, verbose=True), I got the following errors.
Please give me any advice to fix this issue.

generating geometric model
generating kinematic model
generating inverse dynamics code
Traceback (most recent call last):
File "C:\Users\ymcho\AppData\Local\Programs\Python\Python37\SymPyBotics\example\kuka_dynamics.py", line 16, in
rbt = sympybotics.RobotDynCode(rbtdef, verbose=True)
File "C:\Users\ymcho\AppData\Local\Programs\Python\Python37\lib\site-packages\sympybotics\robotmodel.py", line 58, in init
self.dyn.gen_invdyn(invdyn_se.collect)
File "C:\Users\ymcho\AppData\Local\Programs\Python\Python37\lib\site-packages\sympybotics\dynamics\dynamics.py", line 22, in gen_invdyn
self.invdyn = rne(self.rbtdef, self.geom, ifunc)
File "C:\Users\ymcho\AppData\Local\Programs\Python\Python37\lib\site-packages\sympybotics\dynamics\rne.py", line 29, in rne
fw_results = rne_forward(rbtdef, geom, ifunc)
File "C:\Users\ymcho\AppData\Local\Programs\Python\Python37\lib\site-packages\sympybotics\dynamics\rne.py", line 15, in rne_forward
return rne_forward(rbtdef, geom, ifunc)
File "C:\Users\ymcho\AppData\Local\Programs\Python\Python37\lib\site-packages\sympybotics\dynamics\rne_park.py", line 50, in rne_park_forward
V[i] = ifunc(Adj(geom.Tdh_inv[i], V[i - 1])) +
File "C:\Users\ymcho\AppData\Local\Programs\Python\Python37\lib\site-packages\sympybotics\symcode\subexprs.py", line 170, in collect
out_exprs = list(map(self._parse, prep_exprs))
File "C:\Users\ymcho\AppData\Local\Programs\Python\Python37\lib\site-packages\sympybotics\symcode\subexprs.py", line 142, in _parse
if sympy.iterables.iterable(expr):
AttributeError: module 'sympy' has no attribute 'iterables'

symbolic base inertial parameter

Hi,i am researching on the symbolic paramter for kinmatic and dynamic in robotic , now i have a problem on symbolic assignment in this toolbox. In the exmaple all values are zero or pi-related except variable joints. When i attempt to assgin symbolic value in the definition and try to get the result of rbt.dyn.baseparms(), i will get the undefined error in the python function which i don't understand. So i'm wondering if it is possible for the symbolic assignment in this toolbox for generation of the base parameter? such as
rbtdef = sympybotics.RobotDef('S2RR1', # robot name
[('-pi/2', 0, 0, 'q'+'-pi/2'),
('-pi/2', 0, 'd', 'q')],# (alpha, a, d, theta)
dh_convention='modified' # either 'standard' or 'modified'
)
rbt = sympybotics.RobotDynCode(rbtdef, verbose=True)
rbt.calc_base_parms()

thanks a lot.

Is it possible to generate forward dynamics code?

Hi,

I was wondering if there is a way to generate code for the forward dynamics rather than the inverse dynamics. I want to generate a function to return ddq given tau, q, dq, and the params. I have found an example of how to compute the forward kinematics and was wondering if there was a similar option?

Thanks in advance

> Hi,I solve it

hen I annotation these codes, the problem is solved.
in subexprs.py
...
# if sympy.iterables.iterable(expr):
# return expr
...

is it possible to generate Center Of Mass Jacobian for a humanoid robot using SymPyBotics?

Hi! I met with some problems with the Center Of Mass Jacobian for a humanoid robot.

Since humanoid robot has a "floating base" as the root of the kinematics tree, I have no idea how to define a floating base using SymPyBotics, and how to generate Center Of Mass Jacobian code for a robot with a floating base.

It is easy to use RBDyn library to calculate the CoM Jacobian, but it uses more than 1.5 milliseconds, and I want it to be faster, so I want to speed up the calculation by generating the CoM Jacobian code.

can you guys offer some help? Thanks a lot !

Certain joint offsets lead to "NameError: global name 'sqrt' is not defined" in calc_base_parms()

The model in the following code leads to an error:

import sympy
import sympybotics
rbtdef = sympybotics.RobotDef('left_arm',
                         [('pi/2', 0, 0, 'pi/2'),
                         ('pi/2', 0.03, 0.246, '-pi'),
                         ('-pi/2', -0.03, 0, '-pi/4'),
                         ('pi/2', 0, 0.186, 'pi'),
                         ('pi/2', 0, 0, 'pi'),
                         ('pi', 0, 0, 'pi/2')],
                        dh_convention='standard'
                         )
rbt = sympybotics.RobotDynCode(rbtdef, verbose=True)
rbt.calc_base_parms(verbose=True)

Whereby changing the offsets of the first four joints works fine:

import sympy
import sympybotics
rbtdef = sympybotics.RobotDef('left_arm',
                         [('pi/2', 0, 0, '-pi/2'),
                         ('pi/2', 0.03, 0.246, '-pi/2'),
                         ('-pi/2', -0.03, 0,' 0'),
                         ('pi/2', 0, 0.186, '0'),
                         ('pi/2', 0, 0, 'pi'),
                         ('pi', 0, 0, 'pi/2')],
                         dh_convention='standard'
                         )
rbt = sympybotics.RobotDynCode(rbtdef, verbose=True)
rbt.calc_base_parms(verbose=True)

Console output and error message:

generating geometric model
generating kinematic model
generating inverse dynamics code
generating gravity term code
generating coriolis term code
generating coriolis matrix code
generating inertia matrix code
generating regressor matrix code
done
calculating base parameters and regressor code
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
    202             else:
    203                 filename = fname
--> 204             __builtin__.execfile(filename, *where)

/home/philipp/thor_identification/left_arm/URDF_file_handling/dh_to_baseparams.py in        <module>()
     17 rbt = sympybotics.RobotDynCode(rbtdef, verbose=True)
     18 
---> 19 rbt.calc_base_parms(verbose=True)
     20 print rbt.dyn.baseparms
     21 

/usr/local/lib/python2.7/dist-packages/sympybotics-1.0_dev-py2.7.egg/sympybotics            /robotmodel.pyc in calc_base_parms(self, verbose)
    120             _fprint('calculating base parameters and regressor code')
    121 
--> 122         self.dyn.calc_base_parms(regressor_func)
    123 
    124         H_se = Subexprs()

/usr/local/lib/python2.7/dist-packages/sympybotics-1.0_dev-py2.7.egg/sympybotics/dynamics   /dynamics.pyc in calc_base_parms(self, regressor_func)
     53 
     54         Pb, Pd, Kd = find_dyn_parm_deps(
---> 55             self.dof, self.n_dynparms, regressor_func)
     56 
     57         self.Pb = sympy.Matrix(Pb).applyfunc(lambda x: x.nsimplify())

/usr/local/lib/python2.7/dist-packages/sympybotics-1.0_dev-py2.7.egg/sympybotics/dynamics   /dyn_parm_dep.pyc in find_dyn_parm_deps(dof, parm_num, regressor_func)
     20                for j in range(dof)]
     21         Z[i * dof: i * dof + dof, :] = numpy.matrix(
---> 22             regressor_func(q, dq, ddq)).reshape(dof, parm_num)
     23 
     24     R1_diag = numpy.linalg.qr(Z, mode='economic').diagonal().round(round)

/usr/local/lib/python2.7/dist-packages/sympybotics-1.0_dev-py2.7.egg/sympybotics            /robotmodel.pyc in regressor_func(q, dq, ddq)

NameError: global name 'sqrt' is not defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.