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
6d832138
Commit
6d832138
authored
Sep 02, 2019
by
Louis Beauloye
Browse files
[Ctypes] Invdyn structure and python + Solvekin structure
parent
a2f038d9
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
MBsysC/mbs_interface/MBsysPy/mbsysc_loader/MbsSolvekin_c.py
0 → 100644
View file @
6d832138
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
-------------------------------
(c) Universite catholique de Louvain, 2019
Creation : 2019 by LB
Last update : 2019
version MBsysC v1.11.2
-------------------------------
Portable Python interface to MBsysC using Ctypes.
Define the class MbsSolvekin based on the MbsSolvekin structure of MBsysC.
"""
import
ctypes
from
.forward_decl
import
MbsSolvekinOptions_c
from
.forward_decl
import
MbsSolvekin_c
from
.forward_decl
import
MbsBuffer_c
from
.forward_decl
import
MbsGrowingBuffer_c
from
.forward_decl
import
MbsAux_c
from
.forward_decl
import
MbsLutRes_c
#==============================================================================
# MbsSolvekin_c
#==============================================================================
MbsSolvekin_c
.
_fields_
=
[
(
"options"
,
ctypes
.
POINTER
(
MbsSolvekinOptions_c
)),
(
"mbs_aux"
,
ctypes
.
POINTER
(
MbsAux_c
)),
(
"tsim"
,
ctypes
.
c_double
),
(
"tindex"
,
ctypes
.
c_int
),
(
"buffers"
,
ctypes
.
POINTER
(
ctypes
.
POINTER
(
MbsBuffer_c
))),
(
"user_buffer"
,
ctypes
.
POINTER
(
MbsGrowingBuffer_c
)),
(
"bufferNb"
,
ctypes
.
c_int
),
(
"savedArrays"
,
ctypes
.
POINTER
(
ctypes
.
POINTER
(
ctypes
.
c_double
))),
(
"savePeriodCounter"
,
ctypes
.
c_int
),
(
"trajectorytype"
,
ctypes
.
c_int
),
(
"q"
,
ctypes
.
POINTER
(
MbsLutRes_c
)),
(
"qd"
,
ctypes
.
POINTER
(
MbsLutRes_c
)),
(
"qdd"
,
ctypes
.
POINTER
(
MbsLutRes_c
))]
\ No newline at end of file
MBsysC/mbs_interface/MBsysPy/mbsysc_loader/__init__.py
View file @
6d832138
...
...
@@ -26,3 +26,5 @@ from .mbs_equil_c import *
from
.mbs_modal_c
import
*
from
.mbs_sensor_c
import
*
from
.mbs_infos_c
import
*
from
.mbs_invdyn_c
import
*
from
.mbs_solvekin_c
import
*
MBsysC/mbs_interface/MBsysPy/mbsysc_loader/forward_decl.py
View file @
6d832138
...
...
@@ -87,6 +87,14 @@ class MbsDirdyn_c(ctypes.Structure):
pass
class
MbsDirdynOptions_c
(
ctypes
.
Structure
):
pass
class
MbsInvdyn_c
(
ctypes
.
Structure
):
pass
class
MbsLutRes_c
(
ctypes
.
Structure
):
pass
class
MbsSolvekinOptions_c
(
ctypes
.
Structure
):
pass
class
MbsSolvekin_c
(
ctypes
.
Structure
):
pass
class
MbsBuffer_c
(
ctypes
.
Structure
):
pass
class
MbsGrowingBuffer_c
(
ctypes
.
Structure
):
...
...
MBsysC/mbs_interface/MBsysPy/mbsysc_loader/mbs_functions_c.py
View file @
6d832138
...
...
@@ -30,6 +30,7 @@ from .forward_decl import MbsPart_c
from
.forward_decl
import
MbsDirdyn_c
from
.forward_decl
import
MbsEquil_c
from
.forward_decl
import
MbsModal_c
from
.forward_decl
import
MbsInvdyn_c
...
...
@@ -103,6 +104,7 @@ libmodules.mbs_run_part.restype = None
libmodules
.
mbs_delete_part
.
argtypes
=
[
ctypes
.
POINTER
(
MbsPart_c
)]
libmodules
.
mbs_delete_part
.
restype
=
None
libmodules
.
mbs_new_dirdyn
.
argtypes
=
[
ctypes
.
POINTER
(
MbsData_c
)]
libmodules
.
mbs_new_dirdyn
.
restype
=
ctypes
.
POINTER
(
MbsDirdyn_c
)
...
...
@@ -121,6 +123,7 @@ libmodules.mbs_dirdyn_finish.restype = None
libmodules
.
mbs_delete_dirdyn
.
argtypes
=
[
ctypes
.
POINTER
(
MbsDirdyn_c
),
ctypes
.
POINTER
(
MbsData_c
)]
libmodules
.
mbs_delete_dirdyn
.
restype
=
None
libmodules
.
mbs_new_equil
.
argtypes
=
[
ctypes
.
POINTER
(
MbsData_c
)]
libmodules
.
mbs_new_equil
.
restype
=
ctypes
.
POINTER
(
MbsEquil_c
)
...
...
@@ -130,5 +133,16 @@ libmodules.mbs_run_equil.restype = None
libmodules
.
mbs_delete_equil
.
argtypes
=
[
ctypes
.
POINTER
(
MbsEquil_c
),
ctypes
.
POINTER
(
MbsData_c
)]
libmodules
.
mbs_delete_equil
.
restype
=
None
libmodules
.
mbs_new_modal
.
argtypes
=
[
ctypes
.
POINTER
(
MbsData_c
)]
libmodules
.
mbs_new_modal
.
restype
=
ctypes
.
POINTER
(
MbsModal_c
)
\ No newline at end of file
libmodules
.
mbs_new_modal
.
restype
=
ctypes
.
POINTER
(
MbsModal_c
)
libmodules
.
mbs_new_invdyn
.
argtypes
=
[
ctypes
.
POINTER
(
MbsData_c
)]
libmodules
.
mbs_new_invdyn
.
restype
=
ctypes
.
POINTER
(
MbsInvdyn_c
)
libmodules
.
mbs_run_invdyn
.
argtypes
=
[
ctypes
.
POINTER
(
MbsInvdyn_c
),
ctypes
.
POINTER
(
MbsData_c
)]
libmodules
.
mbs_run_invdyn
.
restype
=
None
libmodules
.
mbs_delete_invdyn
.
argtypes
=
[
ctypes
.
POINTER
(
MbsInvdyn_c
),
ctypes
.
POINTER
(
MbsData_c
)]
libmodules
.
mbs_delete_invdyn
.
restype
=
None
\ No newline at end of file
MBsysC/mbs_interface/MBsysPy/mbsysc_loader/mbs_invdyn_c.py
0 → 100644
View file @
6d832138
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
-------------------------------
(c) Universite catholique de Louvain, 2019
Creation : 2019 by LB
Last update : 2019
version MBsysC v1.11.2
-------------------------------
Portable Python interface to MBsysC using Ctypes.
Define the class MbsInvdyn based on the MbsInvdyn structure of MBsysC.
"""
import
ctypes
from
.forward_decl
import
MbsInvdyn_c
from
.forward_decl
import
MbsSolvekinOptions_c
from
.forward_decl
import
MbsLutRes_c
from
.forward_decl
import
MbsBuffer_c
from
.forward_decl
import
MbsGrowingBuffer_c
from
.forward_decl
import
MbsAux_c
#==============================================================================
# MbsInvdyn_c
#==============================================================================
# copy of Solvekin
MbsInvdyn_c
.
_fields_
=
[
(
"options"
,
ctypes
.
POINTER
(
MbsSolvekinOptions_c
)),
(
"mbs_aux"
,
ctypes
.
POINTER
(
MbsAux_c
)),
(
"tsim"
,
ctypes
.
c_double
),
(
"tindex"
,
ctypes
.
c_int
),
(
"buffers"
,
ctypes
.
POINTER
(
ctypes
.
POINTER
(
MbsBuffer_c
))),
(
"user_buffer"
,
ctypes
.
POINTER
(
MbsGrowingBuffer_c
)),
(
"bufferNb"
,
ctypes
.
c_int
),
(
"savedArrays"
,
ctypes
.
POINTER
(
ctypes
.
POINTER
(
ctypes
.
c_double
))),
(
"savePeriodCounter"
,
ctypes
.
c_int
),
(
"trajectorytype"
,
ctypes
.
c_int
),
(
"q"
,
ctypes
.
POINTER
(
MbsLutRes_c
)),
(
"qd"
,
ctypes
.
POINTER
(
MbsLutRes_c
)),
(
"qdd"
,
ctypes
.
POINTER
(
MbsLutRes_c
))]
\ No newline at end of file
MBsysC/mbs_interface/MBsysPy/mbsysc_loader/mbs_solvekin_c.py
0 → 100644
View file @
6d832138
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
-------------------------------
(c) Universite catholique de Louvain, 2019
Creation : 2019 by LB
Last update : 2019
version MBsysC v1.11.2
-------------------------------
Portable Python interface to MBsysC using Ctypes.
Define the class MbsSolvekin based on the MbsSolvekin structure of MBsysC.
"""
import
ctypes
from
.forward_decl
import
MbsSolvekinOptions_c
from
.forward_decl
import
MbsSolvekin_c
from
.forward_decl
import
MbsBuffer_c
from
.forward_decl
import
MbsGrowingBuffer_c
from
.forward_decl
import
MbsAux_c
from
.forward_decl
import
MbsLutRes_c
#==============================================================================
# MbsSolvekin_c
#==============================================================================
MbsSolvekin_c
.
_fields_
=
[
(
"options"
,
ctypes
.
POINTER
(
MbsSolvekinOptions_c
)),
(
"mbs_aux"
,
ctypes
.
POINTER
(
MbsAux_c
)),
(
"tsim"
,
ctypes
.
c_double
),
(
"tindex"
,
ctypes
.
c_int
),
(
"buffers"
,
ctypes
.
POINTER
(
ctypes
.
POINTER
(
MbsBuffer_c
))),
(
"user_buffer"
,
ctypes
.
POINTER
(
MbsGrowingBuffer_c
)),
(
"bufferNb"
,
ctypes
.
c_int
),
(
"savedArrays"
,
ctypes
.
POINTER
(
ctypes
.
POINTER
(
ctypes
.
c_double
))),
(
"savePeriodCounter"
,
ctypes
.
c_int
),
(
"trajectorytype"
,
ctypes
.
c_int
),
(
"q"
,
ctypes
.
POINTER
(
MbsLutRes_c
)),
(
"qd"
,
ctypes
.
POINTER
(
MbsLutRes_c
)),
(
"qdd"
,
ctypes
.
POINTER
(
MbsLutRes_c
))]
#==============================================================================
# MbsSolvekinOptions_c
#==============================================================================
MbsSolvekinOptions_c
.
_fields_
=
[
(
"motion"
,
ctypes
.
c_int
),
(
"trajectoryqname"
,
ctypes
.
c_char_p
),
(
"trajectoryqdname"
,
ctypes
.
c_char_p
),
(
"trajectoryqddname"
,
ctypes
.
c_char_p
),
(
"t0"
,
ctypes
.
c_double
),
(
"tf"
,
ctypes
.
c_double
),
(
"dt"
,
ctypes
.
c_double
),
(
"save2file"
,
ctypes
.
c_int
),
(
"resfilename"
,
ctypes
.
c_char_p
),
(
"respath"
,
ctypes
.
c_char_p
),
(
"animpath"
,
ctypes
.
c_char_p
),
(
"save_anim"
,
ctypes
.
c_int
),
(
"framerate"
,
ctypes
.
c_int
),
(
"saveperiod"
,
ctypes
.
c_int
),
(
"max_save_user"
,
ctypes
.
c_int
),
(
"buffersize"
,
ctypes
.
c_int
),
(
"verbose"
,
ctypes
.
c_int
)]
\ No newline at end of file
MBsysC/mbs_interface/MBsysPy/mbsyspy/__init__.py
View file @
6d832138
...
...
@@ -17,5 +17,6 @@ from .mbs_sensor import *
from
.mbs_data
import
*
from
.mbs_part
import
*
from
.mbs_dirdyn
import
*
from
.mbs_invdyn
import
*
from
.mbs_equil
import
*
from
.mbs_modal
import
*
MBsysC/mbs_interface/MBsysPy/mbsyspy/mbs_data.py
View file @
6d832138
...
...
@@ -866,6 +866,28 @@ class MbsData(object):
else
:
libutilities
.
mbs_set_qv
(
self
.
mbs_data_ptr
,
indices
)
def
set_qa
(
self
,
indices
):
"""
"""
if
isinstance
(
indices
,(
list
,
np
.
ndarray
)):
for
index
in
indices
:
libutilities
.
mbs_set_qa
(
self
.
mbs_data_ptr
,
index
)
else
:
libutilities
.
mbs_set_qa
(
self
.
mbs_data_ptr
,
indices
)
def
unset_qa
(
self
,
indices
):
"""
"""
if
isinstance
(
indices
,(
list
,
np
.
ndarray
)):
for
index
in
indices
:
libutilities
.
mbs_unset_qa
(
self
.
mbs_data_ptr
,
index
)
else
:
libutilities
.
mbs_unset_qa
(
self
.
mbs_data_ptr
,
indices
)
def
empty_qa
(
self
):
libutilities
.
mbs_empty_qa
(
self
.
mbs_data_ptr
)
def
__del__
(
self
):
libloadXML
.
mbs_delete_infos
(
self
.
mbs_infos_ptr
)
...
...
MBsysC/mbs_interface/MBsysPy/mbsyspy/mbs_invdyn.py
0 → 100644
View file @
6d832138
This diff is collapsed.
Click to expand it.
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