Commit 6d832138 authored by Louis Beauloye's avatar Louis Beauloye
Browse files

[Ctypes] Invdyn structure and python + Solvekin structure

parent a2f038d9
#!/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
......@@ -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 *
......@@ -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):
......
......@@ -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
#!/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
#!/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
......@@ -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 *
......@@ -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)
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment