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
23e06afa
Commit
23e06afa
authored
Jan 28, 2021
by
Olivier Lantsoght
Browse files
[MBsysPy][Example] Update PendulumSpringC to test MbsDirdyn oneshot case.
parent
42a75f17
Changes
1
Hide whitespace changes
Inline
Side-by-side
ExampleProjects/PendulumSpringC/workR/main_MBsysPy.py
View file @
23e06afa
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Example of multibody system computed with MBsysPy using Python project files.
Summary
-------
This template loads the data file *.mbs and execute:
- the coordinate partitioning module
- the direct dynamic module (time integration of equations of motion).
- the equilibrium module
- the modal module
- the inverse dynamic module
"""
Universite catholique de Louvain
CEREM : Centre for research in mechatronics
http://www.robotran.be
Contact : info@robotran.be
Main script template for complete model:
-----------------------------------------------
This template loads the data file *.mbs and execute:
- the coordinate partitioning module
- the direct dynamic module (time integration of
equations of motion).
- the equilibrium module
- the modal module
- the inverse dynamic module
It may be adapted and completed by the user.
(c) Universite catholique de Louvain
"""
# Author: Robotran Team
# (c) Universite catholique de Louvain, 2021
#
===
===========================================================================
#
%%
===========================================================================
# Packages loading
#
=
=============================================================================
#
=============================================================================
import
sys
sys
.
path
.
append
(
"../../../MBsysC/mbs_interface"
)
# Relative path for this example script
# Add path to the MBsysC build folder
sys
.
path
.
insert
(
1
,
"../../../MBsysC/build/python"
)
import
MBsysPy
as
Robotran
#
===
===========================================================================
#
%%
===========================================================================
# Project loading
#==============================================================================
mbs_data
=
Robotran
.
MbsData
(
"../dataR/PendulumSpringC.mbs"
,
user_path
=
"userfctR/userfctR_python"
,
symbolic_path
=
"symbolicR/symbolicR_python"
)
# =============================================================================
mbs_data
=
Robotran
.
MbsData
(
"../dataR/PendulumSpringC.mbs"
,
user_path
=
"userfctR/userfctR_python"
,
symbolic_path
=
"symbolicR/symbolicR_python"
)
print
(
mbs_data
)
#
===
===========================================================================
#
%%
===========================================================================
# Partitionning
#
=
=============================================================================
#
=============================================================================
mbs_data
.
process
=
1
mbs_part
=
Robotran
.
MbsPart
(
mbs_data
)
mbs_part
.
set_options
(
rowperm
=
1
,
verbose
=
1
)
mbs_part
.
set_options
(
rowperm
=
1
,
verbose
=
1
)
mbs_part
.
run
()
#
===
===========================================================================
#
%%
===========================================================================
# Equilibrium
#
=
=============================================================================
#
=============================================================================
mbs_data
.
process
=
2
mbs_equil
=
Robotran
.
MbsEquil
(
mbs_data
)
mbs_equil
.
set_options
(
method
=
1
,
senstol
=
1e-2
,
verbose
=
1
)
mbs_equil
.
set_options
(
method
=
1
,
senstol
=
1e-2
,
verbose
=
1
)
mbs_equil
.
run
()
#
===
===========================================================================
#
%%
===========================================================================
# Modal Analysis
#
=
=============================================================================
#
=============================================================================
mbs_data
.
process
=
4
mbs_modal
=
Robotran
.
MbsModal
(
mbs_data
)
mbs_modal
.
set_options
(
save_result
=
1
,
save_anim
=
1
,
mode_ampl
=
0.2
)
mbs_modal
.
set_options
(
save_result
=
1
,
save_anim
=
1
,
mode_ampl
=
0.2
)
mbs_modal
.
run
()
#==============================================================================
# Direct Dynamics
#==============================================================================
# %%===========================================================================
# Direct Dynamics, oneshot
# =============================================================================
mbs_data
.
process
=
3
mbs_data
.
qd
[
1
]
=
1.5
mbs_dirdyn
=
Robotran
.
MbsDirdyn
(
mbs_data
)
mbs_dirdyn
.
set_options
(
flag_oneshot
=
1
)
mbs_dirdyn
.
run
()
# %%===========================================================================
# Direct Dynamics, time integration
# =============================================================================
mbs_data
.
process
=
3
mbs_data
.
qd
[
1
]
=
1.5
mbs_dirdyn
=
Robotran
.
MbsDirdyn
(
mbs_data
)
mbs_dirdyn
.
set_options
(
dt0
=
1e-3
,
tf
=
1
0.
0
,
save2file
=
1
)
mbs_dirdyn
.
set_options
(
integrator
=
"RK4"
,
resfilename
=
"RK4"
)
mbs_dirdyn
.
set_options
(
dt0
=
1e-3
,
tf
=
0.
1
,
save2file
=
1
)
mbs_dirdyn
.
set_options
(
integrator
=
"RK4"
,
resfilename
=
"RK4"
)
mbs_dirdyn
.
run
()
#
===
===========================================================================
#
%%
===========================================================================
# Inverse Dynamics
#
=
=============================================================================
#
=============================================================================
mbs_data
.
process
=
6
mbs_data
.
reset
()
mbs_data
.
set_qa
(
4
)
...
...
@@ -82,8 +86,8 @@ mbs_data.set_qa(1)
mbs_data
.
set_qa
(
3
)
mbs_data
.
set_qa
(
2
)
mbs_invdyn
=
Robotran
.
MbsInvdyn
(
mbs_data
)
mbs_invdyn
.
set_options
(
trajectoryqname
=
"../resultsR/RK4_q.res"
)
mbs_invdyn
.
set_options
(
trajectoryqdname
=
"../resultsR/RK4_qd.res"
)
mbs_invdyn
.
set_options
(
trajectoryqddname
=
"../resultsR/RK4_qdd.res"
)
mbs_invdyn
.
set_options
(
t0
=
1.0
,
tf
=
2.0
,
dt
=
2.5e-3
)
mbs_invdyn
.
set_options
(
trajectoryqname
=
"../resultsR/RK4_q.res"
)
mbs_invdyn
.
set_options
(
trajectoryqdname
=
"../resultsR/RK4_qd.res"
)
mbs_invdyn
.
set_options
(
trajectoryqddname
=
"../resultsR/RK4_qdd.res"
)
mbs_invdyn
.
set_options
(
t0
=
1.0
,
tf
=
2.0
,
dt
=
2.5e-3
)
mbs_invdyn
.
run
()
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