Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Wanghq866 opened this issue Sep 24, 2019 · 7 comments

Comments

@Wanghq866
Copy link

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!

@cdsousa
Copy link
Owner

cdsousa commented Sep 24, 2019

Strange, that should have worked out of the box as 'a2' is correctly quoted. Maybe that's some issue related to newer Python/SymPy versions, I've long stopped developing/using the package.
Let me ask other users (if anyone): have someone any clue about this?

UPDATE: See my last comment

@Wanghq866
Copy link
Author

Excuse me, what version of sympy did you develop? Thank you.

@cdsousa
Copy link
Owner

cdsousa commented Sep 26, 2019

I heavily used SymPyback in 2013, but I'm pretty sure SymPyBotics worked with SymPy versions from 2014 and 2015.

@dbdxnuliba
Copy link

I have find the same problem。

@Artourdaboi
Copy link

well i have the same issue. if someone works on dynamic identification, he has to use either SYMORO or sympybotics. sympybotics is really better except this issue... i wonder if you have developed other lib these years to replace sympybotics

@Artourdaboi
Copy link

import sympy
import numpy
import sympybotics

rbtdef=sympybotics.RobotDef('kuka1',
[(' 0',0.00,0.435,'q'),
('-pi/2',0.0,-0.114,'q-pi/2'),
('0','a1',0.1735,'q'),
('-pi/2',0.0,0.435,'q'),
('pi/2',0,0,'q'),
('-pi/2',0,0.136,'q+pi')],
dh_convention='modified');
rbtdef.gravityacc=sympy.Matrix([0.0,0.0,-9.81]);
rbtdef.frictionmodel={'Coulomb','viscous'}
rbt=sympybotics.RobotDynCode(rbtdef,verbose=True);
rbt.calc_base_parms()
Hb_func_def = sympybotics.robotcodegen.robot_code_to_func(
'Julia', rbt.Hb_code, 'Hb', 'Hb', rbtdef)
print Hb_func_def

Traceback (most recent call last):
File "C:\bot6_2fr.py", line 16, in
rbt.calc_base_parms()
File "build\bdist.win-amd64\egg\sympybotics\robotmodel.py", line 122, in calc_base_parms
self.dyn.calc_base_parms(regressor_func)
File "build\bdist.win-amd64\egg\sympybotics\dynamics\dynamics.py", line 55, in calc_base_parms
self.dof, self.n_dynparms, regressor_func)
File "build\bdist.win-amd64\egg\sympybotics\dynamics\dyn_parm_dep.py", line 22, in find_dyn_parm_deps
regressor_func(q, dq, ddq)).reshape(dof, parm_num)
File "", line 72, in regressor_func
NameError: global name 'a1' is not defined

python==2.7.15
sympy==0.7.3
numpy==1.15.1

@cdsousa
Copy link
Owner

cdsousa commented Apr 10, 2020

Well, @shaoxingmao, @dbdxnuliba and @Artourdaboi, now that I'm looking to this once again, I get what the issue is. It has, in fact, a very simple explanation, I'm terribly sorry I didn't get it at first:
that use case is simply not supposed to work!

The dynamics part is not supposed to work with symbols, you have to replace those 'a1', 'a2', ... by the actual numeric values!

When doing geometric computations, using symbolic DH parameters may work, as it is seen here https://github.com/cdsousa/SymPyBotics/blob/master/sympybotics/tests/test_results.py#L14-L25 .

However, for computations of dynamics, only numeric DH parameters are accepted, for instance https://github.com/cdsousa/SymPyBotics/blob/master/sympybotics/tests/test_results.py#L63-L74 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants