Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
robotran
mbsysc
Commits
42a75f17
Commit
42a75f17
authored
Jan 28, 2021
by
Olivier Lantsoght
Browse files
[MBsysPy][MbsInvdyn][BUG] Missing user_invdyn_ function in module
parent
7fe4961d
Changes
5
Show whitespace changes
Inline
Side-by-side
MBsysC/mbs_interface/MBsysPy/mbsyspy/mbs_data.py
View file @
42a75f17
...
...
@@ -59,6 +59,9 @@ from .._mbsysc_loader.callback import user_equil_init_wrap
from
.._mbsysc_loader.callback
import
user_equil_loop_wrap
from
.._mbsysc_loader.callback
import
user_equil_finish_wrap
from
.._mbsysc_loader.callback
import
user_equil_fxe_wrap
from
.._mbsysc_loader.callback
import
user_invdyn_init_wrap
from
.._mbsysc_loader.callback
import
user_invdyn_loop_wrap
from
.._mbsysc_loader.callback
import
user_invdyn_finish_wrap
from
.._mbsysc_loader.callback
import
mbs_accelred_wrap
from
.._mbsysc_loader.callback
import
mbs_extforces_wrap
...
...
@@ -456,7 +459,8 @@ class MbsData(object):
user_fun_list
=
[
'cons_hJ'
,
'cons_jdqd'
,
'derivative'
,
'DrivenJoints'
,
'ExtForces'
,
'JointForces'
,
'LinkForces'
,
'Link3DForces'
,
'dirdyn_init'
,
'dirdyn_loop'
,
'dirdyn_finish'
,
'equil_init'
,
'equil_loop'
,
'equil_finish'
,
'equil_fxe'
'equil_init'
,
'equil_loop'
,
'equil_finish'
,
'equil_fxe'
,
'invdyn_init'
,
'invdyn_loop'
,
'invdyn_finish'
,
]
symb_fun_list
=
[
'accelred'
,
'cons_hJ'
,
'cons_jdqd'
,
'invdyna'
,
'dirdyna'
,
'extforces'
,
'gensensor'
,
'link'
,
'link3D'
,
'sensor'
...
...
@@ -669,6 +673,12 @@ class MbsData(object):
self
.
user_equil_finish
=
None
elif
fun
==
"equil_fxe"
:
self
.
user_equil_fxe
=
None
elif
fun
==
"invdyn_init"
:
self
.
user_invdyn_init
=
None
elif
fun
==
"invdyn_loop"
:
self
.
user_invdyn_loop
=
None
elif
fun
==
"invdyn_finish"
:
self
.
user_invdyn_finish
=
None
else
:
raise
TypeError
(
fun
+
" is not an existing user function"
)
else
:
...
...
@@ -764,6 +774,9 @@ class MbsData(object):
- 'equil_loop'
- 'equil_finish'
- 'equil_fxe'
- 'invdyn_init'
- 'invdyn_loop'
- 'invdyn_finish'
"""
template_path
=
os
.
path
.
join
(
module_dir
,
'../templates/user'
)
...
...
@@ -1013,6 +1026,57 @@ class MbsData(object):
spec
.
loader
.
exec_module
(
module
)
self
.
user_equil_fxe
=
module
.
user_equil_fxe
elif
fun
==
'invdyn_init'
:
if
self
.
user_invdyn_init
is
None
:
# user_invdyn
user_file
=
"user_invdyn.py"
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
user_path
,
user_file
))
if
not
os
.
path
.
isfile
(
path
):
mbs_msg
(
"file '"
+
user_file
+
"' not found in folder '"
+
os
.
path
.
dirname
(
path
))
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
template_path
,
user_file
))
else
:
if
__DEBUG__
:
mbs_msg
(
"DEBUG>> loading file '"
+
user_file
+
"' in folder '"
+
os
.
path
.
dirname
(
path
))
spec
=
importlib
.
util
.
spec_from_file_location
(
user_file
[:
-
3
],
path
)
module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
module
)
self
.
user_invdyn_init
=
module
.
user_invdyn_init
elif
fun
==
'invdyn_loop'
:
if
self
.
user_invdyn_loop
is
None
:
# user_invdyn
user_file
=
"user_invdyn.py"
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
user_path
,
user_file
))
if
not
os
.
path
.
isfile
(
path
):
mbs_msg
(
"file '"
+
user_file
+
"' not found in folder '"
+
os
.
path
.
dirname
(
path
))
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
template_path
,
user_file
))
else
:
if
__DEBUG__
:
mbs_msg
(
"DEBUG>> loading file '"
+
user_file
+
"' in folder '"
+
os
.
path
.
dirname
(
path
))
spec
=
importlib
.
util
.
spec_from_file_location
(
user_file
[:
-
3
],
path
)
module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
module
)
self
.
user_invdyn_loop
=
module
.
user_invdyn_loop
elif
fun
==
'invdyn_finish'
:
if
self
.
user_invdyn_finish
is
None
:
# user_invdyn
user_file
=
"user_invdyn.py"
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
user_path
,
user_file
))
if
not
os
.
path
.
isfile
(
path
):
mbs_msg
(
"file '"
+
user_file
+
"' not found in folder '"
+
os
.
path
.
dirname
(
path
))
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
template_path
,
user_file
))
else
:
if
__DEBUG__
:
mbs_msg
(
"DEBUG>> loading file '"
+
user_file
+
"' in folder '"
+
os
.
path
.
dirname
(
path
))
spec
=
importlib
.
util
.
spec_from_file_location
(
user_file
[:
-
3
],
path
)
module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
module
)
self
.
user_invdyn_finish
=
module
.
user_invdyn_finish
else
:
raise
TypeError
(
fun
+
" is not an existing user function"
)
else
:
...
...
@@ -1228,6 +1292,9 @@ class MbsData(object):
- 'equil_loop'
- 'equil_finish'
- 'equil_fxe'
- 'invdyn_init'
- 'invdyn_loop'
- 'invdyn_finish'
Returns
-------
...
...
@@ -1261,6 +1328,7 @@ class MbsData(object):
raise
TypeError
(
'mbs_module must belong to {:}'
.
format
((
MbsDirdyn
,
MbsEquil
,
MbsModal
,
MbsSolvekin
,
MbsInvdyn
,
MbsPart
)))
else
:
raise
ValueError
(
' A module needs to be passed as mbs_module argument'
)
elif
fun
==
'dirdyn_init'
:
# user_dirdyn
if
mbs_module
is
not
None
:
...
...
@@ -1327,6 +1395,36 @@ class MbsData(object):
raise
TypeError
(
'mbs_module must be MbsEquil to use equil_fxe'
)
else
:
raise
ValueError
(
'Equil module needs to be passed as mbs_module argument'
)
elif
fun
==
'invdyn_init'
:
# user_invdyn
if
mbs_module
is
not
None
:
if
isinstance
(
mbs_module
,
MbsInvdyn
):
self
.
ptrs_to_user_fcts
[
"user_invdyn_init"
]
=
user_invdyn_init_wrap
(
lambda
mbs
,
dd
:
self
.
user_invdyn_init
(
self
,
mbs_module
))
self
.
mbs_data_ptr
.
contents
.
user_invdyn_init
=
self
.
ptrs_to_user_fcts
[
"user_invdyn_init"
]
else
:
raise
TypeError
(
'mbs_module must be MbsInvdyn to use invdyn_init'
)
else
:
raise
ValueError
(
'Dirdyn module needs to be passed as mbs_module argument'
)
elif
fun
==
'invdyn_loop'
:
if
mbs_module
is
not
None
:
if
isinstance
(
mbs_module
,
MbsInvdyn
):
self
.
ptrs_to_user_fcts
[
"user_invdyn_loop"
]
=
user_invdyn_loop_wrap
(
lambda
mbs
,
dd
:
self
.
user_invdyn_loop
(
self
,
mbs_module
))
self
.
mbs_data_ptr
.
contents
.
user_invdyn_loop
=
self
.
ptrs_to_user_fcts
[
"user_invdyn_loop"
]
else
:
raise
TypeError
(
'mbs_module must be MbsInvdyn to use invdyn_loop'
)
else
:
raise
ValueError
(
'Dirdyn module needs to be passed as mbs_module argument'
)
elif
fun
==
'invdyn_finish'
:
if
mbs_module
is
not
None
:
if
isinstance
(
mbs_module
,
MbsInvdyn
):
self
.
ptrs_to_user_fcts
[
"user_invdyn_finish"
]
=
user_invdyn_finish_wrap
(
lambda
mbs
,
dd
:
self
.
user_invdyn_finish
(
self
,
mbs_module
))
self
.
mbs_data_ptr
.
contents
.
user_invdyn_finish
=
self
.
ptrs_to_user_fcts
[
"user_invdyn_finish"
]
else
:
raise
TypeError
(
'mbs_module must be MbsInvdyn to use invdyn_finish'
)
else
:
raise
ValueError
(
'Dirdyn module needs to be passed as mbs_module argument'
)
elif
fun
==
"derivative"
:
# derivative
self
.
ptrs_to_user_fcts
[
"user_Derivative"
]
=
user_Derivative_wrap
(
lambda
mbs
:
self
.
user_derivative
(
self
))
...
...
@@ -1613,6 +1711,9 @@ class MbsData(object):
- 'equil_loop'
- 'equil_finish'
- 'equil_fxe'
- 'invdyn_init'
- 'invdyn_loop'
- 'invdyn_finish'
Returns
-------
...
...
@@ -1651,6 +1752,12 @@ class MbsData(object):
self
.
mbs_data_ptr
.
contents
.
user_equil_finish
=
user_equil_finish_wrap
(
lambda
mbs
,
eq
:
callback_undefined
(
"user_equil_finish"
))
elif
fun
==
"equil_fxe"
:
self
.
mbs_data_ptr
.
contents
.
user_equil_fxe
=
user_equil_fxe_wrap
(
lambda
mbs
,
f
:
callback_undefined
(
"user_equil_fxe"
))
elif
fun
==
"invdyn_init"
:
self
.
mbs_data_ptr
.
contents
.
user_invdyn_init
=
user_invdyn_init_wrap
(
lambda
mbs
,
dd
:
callback_undefined
(
"user_invdyn_init"
))
elif
fun
==
"invdyn_loop"
:
self
.
mbs_data_ptr
.
contents
.
user_invdyn_loop
=
user_invdyn_loop_wrap
(
lambda
mbs
,
dd
:
callback_undefined
(
"user_invdyn_loop"
))
elif
fun
==
"invdyn_finish"
:
self
.
mbs_data_ptr
.
contents
.
user_invdyn_finish
=
user_invdyn_finish_wrap
(
lambda
mbs
,
dd
:
callback_undefined
(
"user_invdyn_finish"
))
else
:
raise
TypeError
(
fun
+
" is not an existing user function"
)
else
:
...
...
@@ -1951,6 +2058,42 @@ class MbsData(object):
spec
.
loader
.
exec_module
(
module
)
self
.
user_equil_fxe
=
module
.
user_equil_fxe
elif
function_name
==
'invdyn_init'
:
# user_invdyn
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
user_path
,
user_file
))
if
not
os
.
path
.
isfile
(
path
):
mbs_msg
(
" file '"
+
user_file
+
"' not found in folder '"
+
os
.
path
.
dirname
(
path
))
else
:
spec
=
importlib
.
util
.
spec_from_file_location
(
user_file
[:
-
3
],
path
)
module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
module
)
self
.
user_invdyn_init
=
module
.
user_invdyn_init
elif
function_name
==
'invdyn_loop'
:
# user_invdyn
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
user_path
,
user_file
))
if
not
os
.
path
.
isfile
(
path
):
mbs_msg
(
" file '"
+
user_file
+
"' not found in folder '"
+
os
.
path
.
dirname
(
path
))
else
:
spec
=
importlib
.
util
.
spec_from_file_location
(
user_file
[:
-
3
],
path
)
module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
module
)
self
.
user_invdyn_loop
=
module
.
user_invdyn_loop
elif
function_name
==
'invdyn_finish'
:
# user_invdyn
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
user_path
,
user_file
))
if
not
os
.
path
.
isfile
(
path
):
mbs_msg
(
" file '"
+
user_file
+
"' not found in folder '"
+
os
.
path
.
dirname
(
path
))
else
:
spec
=
importlib
.
util
.
spec_from_file_location
(
user_file
[:
-
3
],
path
)
module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
module
)
self
.
user_invdyn_finish
=
module
.
user_invdyn_finish
else
:
raise
TypeError
(
function_name
+
" is not an existing user function"
)
...
...
MBsysC/mbs_interface/MBsysPy/mbsyspy/mbs_invdyn.py
View file @
42a75f17
...
...
@@ -116,7 +116,8 @@ class MbsInvdyn(object):
self
.
symbolic_path
=
symbolic_path
self
.
user_fun_list
=
[
'cons_hJ'
,
'cons_jdqd'
,
'derivative'
,
'DrivenJoints'
,
'ExtForces'
,
'JointForces'
,
'LinkForces'
,
'Link3DForces'
'ExtForces'
,
'JointForces'
,
'LinkForces'
,
'Link3DForces'
,
'invdyn_init'
,
'invdyn_loop'
,
'invdyn_finish'
]
self
.
symb_fun_list
=
[
'accelred'
,
'cons_hJ'
,
'cons_jdqd'
,
'invdyna'
,
'dirdyna'
,
'extforces'
,
'gensensor'
,
...
...
MBsysC/mbs_interface/MBsysPy/templates/CompleteProject-Python.xml
View file @
42a75f17
...
...
@@ -13,6 +13,7 @@
<file
src=
"user/user_DrivenJoints.py"
dest=
"user_DrivenJoints.py"
/>
<file
src=
"user/user_equil.py"
dest=
"user_equil.py"
/>
<file
src=
"user/user_ExtForces.py"
dest=
"user_ExtForces.py"
/>
<file
src=
"user/user_invdyn.py"
dest=
"user_invdyn.py"
/>
<file
src=
"user/user_JointForces.py"
dest=
"user_JointForces.py"
/>
<file
src=
"user/user_Link3DForces.py"
dest=
"user_Link3DForces.py"
/>
<file
src=
"user/user_LinkForces.py"
dest=
"user_LinkForces.py"
/>
...
...
MBsysC/mbs_interface/MBsysPy/templates/SimpleProject-Python.xml
View file @
42a75f17
...
...
@@ -13,6 +13,7 @@
<file
src=
"user/user_DrivenJoints.py"
dest=
"user_DrivenJoints.py"
/>
<file
src=
"user/user_equil.py"
dest=
"user_equil.py"
/>
<file
src=
"user/user_ExtForces.py"
dest=
"user_ExtForces.py"
/>
<file
src=
"user/user_invdyn.py"
dest=
"user_invdyn.py"
/>
<file
src=
"user/user_JointForces.py"
dest=
"user_JointForces.py"
/>
<file
src=
"user/user_Link3DForces.py"
dest=
"user_Link3DForces.py"
/>
<file
src=
"user/user_LinkForces.py"
dest=
"user_LinkForces.py"
/>
...
...
MBsysC/mbs_interface/MBsysPy/templates/user/user_invdyn.py
0 → 100755
View file @
42a75f17
# -*- coding: utf-8 -*-
"""Module for the definition of user functions related to inverse dynamic analysis."""
# Author: Robotran Team
# (c) Universite catholique de Louvain, 2021
def
user_invdyn_init
(
mbs_data
,
mbs_invdyn
):
"""Run specific operation required by the user before running inverse dynamic.
Parameters
----------
mbs_data : MBsysPy.MbsData
The instance containing the multibody project.
mbs_invdyn : MBsysPy.MbsInvdyn
The instance of the current inverse dynamic process.
Returns
-------
None.
"""
print
(
"user_invdyn_init (Template) : This function should not be called"
)
return
def
user_invdyn_loop
(
mbs_data
,
mbs_invdyn
):
"""Run specific operation required by the user at the end of step.
Parameters
----------
mbs_data : MBsysPy.MbsData
The instance containing the multibody project.
mbs_invdyn : MBsysPy.MbsDirdyn
The instance of the current inverse dynamic process.
Returns
-------
None.
"""
print
(
"user_invdyn_loop(Template) : This function should not be called"
)
return
def
user_invdyn_finish
(
mbs_data
,
mbs_invdyn
):
"""Run specific operations required by the user when inverse dynamic analysis ends.
Parameters
----------
mbs_data : MBsysPy.MbsData
The instance containing the multibody project.
mbs_invdyn : MBsysPy.MbsDirdyn
The instance of the current inverse dynamic process.
Returns
-------
None.
"""
print
(
"user_invdyn_finish (Template) : This function should not be called"
)
return
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment