Commit b90de19a authored by Louis Beauloye's avatar Louis Beauloye
Browse files

[Ctypes] Modal, Invdyn, Solvekin in python + some improvements

parent ec44b2db
......@@ -31,6 +31,7 @@ from .forward_decl import MbsDirdyn_c
from .forward_decl import MbsEquil_c
from .forward_decl import MbsModal_c
from .forward_decl import MbsInvdyn_c
from .forward_decl import MbsSolvekin_c
......@@ -144,5 +145,53 @@ 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_invdyn_init.argtypes =[ctypes.POINTER(MbsInvdyn_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_invdyn_init.restype = None
libmodules.mbs_invdyn_loop.argtypes =[ctypes.POINTER(MbsInvdyn_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_invdyn_loop.restype = None
libmodules.mbs_invdyn_finish.argtypes =[ctypes.POINTER(MbsInvdyn_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_invdyn_finish.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
libmodules.mbs_delete_invdyn.restype = None
libmodules.mbs_new_solvekin.argtypes =[ctypes.POINTER(MbsData_c)]
libmodules.mbs_new_solvekin.restype = ctypes.POINTER(MbsSolvekin_c)
libmodules.mbs_delete_solvekin.argtypes =[ctypes.POINTER(MbsSolvekin_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_delete_solvekin.restype = None
libmodules.mbs_run_solvekin.argtypes =[ctypes.POINTER(MbsSolvekin_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_run_solvekin.restype = None
libmodules.mbs_solvekin_init.argtypes =[ctypes.POINTER(MbsSolvekin_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_solvekin_init.restype = None
libmodules.mbs_solvekin_loop.argtypes =[ctypes.POINTER(MbsSolvekin_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_solvekin_loop.restype = None
libmodules.mbs_solvekin_finish.argtypes =[ctypes.POINTER(MbsSolvekin_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_solvekin_finish.restype = None
libmodules.mbs_new_modal.argtypes =[ctypes.POINTER(MbsData_c)]
libmodules.mbs_new_modal.restype = ctypes.POINTER(MbsModal_c)
libmodules.mbs_delete_modal.argtypes =[ctypes.POINTER(MbsModal_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_delete_modal.restype = None
libmodules.mbs_run_modal.argtypes =[ctypes.POINTER(MbsModal_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_run_modal.restype = None
libmodules.mbs_modal_init.argtypes =[ctypes.POINTER(MbsModal_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_modal_init.restype = None
libmodules.mbs_modal_loop.argtypes =[ctypes.POINTER(MbsModal_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_modal_loop.restype = None
libmodules.mbs_modal_finish.argtypes =[ctypes.POINTER(MbsModal_c), ctypes.POINTER(MbsData_c)]
libmodules.mbs_modal_finish.restype = None
\ No newline at end of file
......@@ -20,3 +20,4 @@ from .mbs_dirdyn import *
from .mbs_invdyn import *
from .mbs_equil import *
from .mbs_modal import *
from .mbs_solvekin import *
......@@ -867,7 +867,7 @@ class MbsData(object):
libutilities.mbs_set_qv(self.mbs_data_ptr, indices)
def set_qa(self, indices):
"""
""" Set a variable to actuated partition
"""
if isinstance(indices,(list,np.ndarray)):
for index in indices:
......@@ -876,7 +876,7 @@ class MbsData(object):
libutilities.mbs_set_qa(self.mbs_data_ptr, indices)
def unset_qa(self, indices):
"""
""" Unset a variable from the actuated partition
"""
if isinstance(indices,(list,np.ndarray)):
for index in indices:
......@@ -885,7 +885,8 @@ class MbsData(object):
libutilities.mbs_unset_qa(self.mbs_data_ptr, indices)
def empty_qa(self):
""" Remove all joints from the actuated partition
"""
libutilities.mbs_empty_qa(self.mbs_data_ptr)
def __del__(self):
......
......@@ -382,6 +382,7 @@ class MbsDirdyn(object):
>>> mbs_dirdyn.run()
"""
# Assing required user functions
self.__assign_user_fct__()
self.mbs.__assign_user_fct__()
......@@ -403,6 +404,8 @@ class MbsDirdyn(object):
if self.get_options("save2file"):
#c_mbs_dirdyn_write_buffers(self.mbs_dirdyn_ptr)
size1 = self.mbs_dirdyn_ptr.contents.buffers[0].contents.index
if size1 == 0:
size1 = self.mbs_dirdyn_ptr.contents.buffers[0].contents.size
size2 = self.mbs_dirdyn_ptr.contents.buffers[0].contents.nx+1
# array are initialized to the time pointer so as to start index of joints at 1 (we have to ensure contiguity between t and x in buffers ! ! !)
......@@ -417,22 +420,21 @@ class MbsDirdyn(object):
self.results.qdd = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[2].contents.tx ,(size1, size2)))
size2 = self.mbs_dirdyn_ptr.contents.buffers[3].contents.nx+1
self.results.Qq = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[3].contents.tx ,(size1, size2)))
buffer_id = 4
if self.mbs.Nux:
size2 = self.mbs_dirdyn_ptr.contents.buffers[4].contents.nx+1
self.results.ux = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[4].contents.tx ,(size1, size2)))
self.results.uxd = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[5].contents.tx ,(size1, size2)))
if self.mbs.Nlink:
size2 = self.mbs_dirdyn_ptr.contents.buffers[6].contents.nx+1
self.results.Z = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[6].contents.tx ,(size1, size2)))
self.results.Zd = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[7].contents.tx ,(size1, size2)))
self.results.Fl = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[8].contents.tx ,(size1, size2)))
else :
if self.mbs.Nlink:
size2 = self.mbs_dirdyn_ptr.contents.buffers[4].contents.nx+1
self.results.Z = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[4].contents.tx ,(size1, size2)))
self.results.Zd = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[5].contents.tx ,(size1, size2)))
self.results.Fl = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[6].contents.tx ,(size1, size2)))
size2 = self.mbs_dirdyn_ptr.contents.buffers[buffer_id].contents.nx+1
self.results.ux = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[buffer_id].contents.tx ,(size1, size2)))
self.results.uxd = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[buffer_id+1].contents.tx ,(size1, size2)))
buffer_id = buffer_id + 2
if self.mbs.Nlink:
size2 = self.mbs_dirdyn_ptr.contents.buffers[buffer_id].contents.nx+1
self.results.Z = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[buffer_id].contents.tx ,(size1, size2)))
self.results.Zd = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[buffer_id+1].contents.tx ,(size1, size2)))
self.results.Fl = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[buffer_id+2].contents.tx ,(size1, size2)))
buffer_id = buffer_id + 3
if self.mbs.nqc:
size2 = self.mbs_dirdyn_ptr.contents.buffers[buffer_id].contents.nx+1
self.results.Qc = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[buffer_id].contents.tx ,(size1, size2)))
if self.mbs_dirdyn_ptr.contents.user_buffer.contents.nx:
size = self.mbs_dirdyn_ptr.contents.user_buffer.contents.index
......@@ -832,7 +834,14 @@ class MbsResult(object):
Numpy array containing the current values of the generalized
accelerations.
Qq : ndarray
Numpy array containing the values of the joint forces..
Numpy array containing the values of the joint forces.
Qc : ndarray
Numpy array containing the value of joint force introduced in driven
joints to respect the user function
qa : ndarray of int
Numpy array of integers containing the indices of actuated
articulations (only for inverse dynamic). Those articulations are
controlled by an actuator.
t : ndarray
Numpy array containing the values of the time vector
ux : ndarray
......@@ -866,9 +875,11 @@ class MbsResult(object):
self.Z=[]
self.Zd=[]
self.Qq=[]
self.qa=[]
self.t=[]
self.ux=[]
self.uxd=[]
self.Qc=[]
self.outputs={}
self.mbs=mbs
......@@ -939,7 +950,7 @@ class MbsResult(object):
else:
if __DEBUG__ : print( "DEBUG>> file '"+CurFile+"' not found in folder '"+os.path.dirname(path))
# Link
if self.mbs.Nlink:
CurFile = baseFileName+'_linkF.res'
path = os.path.abspath(os.path.join(result_path, CurFile))
......@@ -961,6 +972,15 @@ class MbsResult(object):
self.results.Zd = np.loadtxt(path)
else:
if __DEBUG__ : print( "DEBUG>> file '"+CurFile+"' not found in folder '"+os.path.dirname(path))
# Qc
if self.mbs.nqc:
CurFile = baseFileName+'_Qc.res'
path = os.path.abspath(os.path.join(result_path, CurFile))
if (os.path.isfile(path) ):
self.results.Qc = np.loadtxt(path)
else:
if __DEBUG__ : print( "DEBUG>> file '"+CurFile+"' not found in folder '"+os.path.dirname(path))
......
......@@ -46,6 +46,7 @@ from ..mbsysc_loader.callback import user_cons_jdqd_wrap
from ..mbsysc_loader.callback import mbs_cons_hJ_wrap
from ..mbsysc_loader.callback import mbs_cons_jdqd_wrap
from ..mbsysc_loader.callback import mbs_invdyna_wrap
from ..mbsysc_loader.callback import mbs_dirdyna_wrap
#==============================================================================
......@@ -63,9 +64,12 @@ class MbsInvdyn(object):
def __init__(self, mbs, user_path=None, symbolic_path=None):
if __DEBUG__ : print( "DEBUG>> Creating MbsInvdyn struct for "+mbs.mbs_name+"' MBS.")
self.module_name = type(self).__name__
if __DEBUG__ : print( "DEBUG>> Creating " +self.module_name + " struct for "+mbs.mbs_name+"' MBS.")
self.mbs_invdyn_ptr = libmodules.mbs_new_invdyn(mbs.mbs_data_ptr)
if __DEBUG__ : print( "DEBUG>> MbsInvdyn structure loaded")
if __DEBUG__ : print( "DEBUG>> " +self.module_name + " structure loaded")
self.mbs = mbs
......@@ -109,7 +113,7 @@ class MbsInvdyn(object):
self.store_results = True
# Exposing some memory
if __DEBUG__ : print( "DEBUG>> Exposing MbsInvdyn fields")
if __DEBUG__ : print( "DEBUG>> Exposing " +self.module_name + " fields")
# Constraints
self._h = self._Jac = self._jdqd = None
if self.mbs.Ncons>0:
......@@ -137,14 +141,14 @@ class MbsInvdyn(object):
def __str__(self):
if __DEBUG__ : print( "DEBUG>> start of __str")
return "MbsInvdyn instance has nothing to be printed from C library!"
return self.module_name + " instance has nothing to be printed from C library!"
def __load_user_fct__(self, user_path):
"""
Load user function where some args depend on MbsInvdyn module.
Load user function where some args depend on MbsInvdyn/MbsSolvekin module.
Load the user functions in which some of the arguments are
dependent of MbsInvdyn module instance. The functions will be
dependent of MbsInvdyn/MbsSolvekin module instance. The functions will be
assigned to the MbsData instance when the 'run' functions is called
and unassigned at the end.
......@@ -177,10 +181,10 @@ class MbsInvdyn(object):
def __load_symbolic_fct__(self, symbolic_path):
"""
Load symbolic function where some args depend on MbsInvdyn module.
Load symbolic function where some args depend on MbsInvdyn/MbsSolvekin module.
Load the symb functions in which some of the arguments are
dependent of MbsInvdyn module instance. The functions will be
dependent of MbsInvdyn/MbsSolvekin module instance. The functions will be
assigned to the MbsData instance when the 'run' functions is called
and unassigned at the end.
......@@ -188,6 +192,7 @@ class MbsInvdyn(object):
- cons_hJ (from mbs_cons_hJ_MBSNAME.py)
- cons_jdqd (from mbs_cons_jdqd_MBSNAME.py)
- invdyna (from mbs_invdyna_MBSNAME.py)
- dirdyna (from mbs_dirdyna_MBSNAME.py)
"""
mbs_name = self.mbs.mbs_name
template_path = os.path.join(__MODULE_DIR__,'../templates/symbolic')
......@@ -213,6 +218,7 @@ class MbsInvdyn(object):
self.mbs_cons_jdqd = module.cons_jdqd
# invdyna
#not used in the MbsSolvekin module
symb_file = "mbs_invdyna_"+mbs_name+".py"
path = os.path.abspath(os.path.join(symbolic_path, symb_file))
if not os.path.isfile(path):
......@@ -222,12 +228,23 @@ class MbsInvdyn(object):
module = imp.load_source(symb_file[:-3], path)
self.mbs_invdyna = module.invdyna
# dirdyna
#not used in the MbsInvdyn module
symb_file = "mbs_dirdyna_"+mbs_name+".py"
path = os.path.abspath(os.path.join(symbolic_path, symb_file))
if not os.path.isfile(path):
if __DEBUG__ : print( "DEBUG>> file '"+symb_file+"' not found in folder '"+os.path.dirname(path))
symb_file = "mbs_dirdyna_PRJ.py"
path = os.path.abspath(os.path.join(template_path, symb_file))
module = imp.load_source(symb_file[:-3], path)
self.mbs_dirdyna = module.dirdyna
return
def __assign_user_fct__(self):
"""
Assign and wrap python user function where some args depend
on MbsInvdyn module. Store the functions in the MbsData instance
on MbsInvdyn/MbsSolvekin module. Store the functions in the MbsData instance
and assign the pointer of functions in the C structure
"""
# cons_hJ
......@@ -244,7 +261,7 @@ class MbsInvdyn(object):
def __assign_symbolic_fct__(self):
"""
Assign and wrap python symbolic function where some args depend
on MbsInvdyn module. Store the functions in the MbsData instance
on MbsInvdyn/MbsSolvekin module. Store the functions in the MbsData instance
and assign the pointer of functions in the C structure
"""
......@@ -259,15 +276,22 @@ class MbsInvdyn(object):
self.mbs.mbs_data_ptr.contents.mbs_cons_jdqd = self.ptrs_to_symb_fcts["mbs_cons_jdqd"]
# invdyna
#not used in the MbsSolvekin module
self.ptrs_to_symb_fcts["mbs_invdyna"] = mbs_invdyna_wrap(lambda phi,mbs,tsim : self.mbs_invdyna(self._phi, self.mbs, tsim))
self.mbs.mbs_invdyna = self.mbs_invdyna
self.mbs.mbs_data_ptr.contents.mbs_invdyna = self.ptrs_to_symb_fcts["mbs_invdyna"]
# dirdyna
#not used in the MbsInvdyn module
self.ptrs_to_symb_fcts["mbs_dirdyna"] = mbs_dirdyna_wrap(lambda M,c,mbs,tsim : self.mbs_dirdyna(self._M, self._c, self.mbs, tsim))
self.mbs.mbs_dirdyna = self.mbs_dirdyna
self.mbs.mbs_data_ptr.contents.mbs_dirdyna = self.ptrs_to_symb_fcts["mbs_dirdyna"]
return
def __unassign_user_fct__(self):
"""
Unassign user function where some args depend on MbsInvdyn module.
Unassign user function where some args depend on MbsInvdyn/MbsSolvekin module.
"""
self.ptrs_to_user_fcts = {}
......@@ -282,7 +306,7 @@ class MbsInvdyn(object):
def __unassign_symbolic_fct__(self):
"""
Unassign symbolic function where some args depend on MbsInvdyn module.
Unassign symbolic function where some args depend on MbsInvdyn/MbsSolvekin module.
"""
self.ptrs_to_symb_fcts = {}
......@@ -293,13 +317,15 @@ class MbsInvdyn(object):
self.mbs.mbs_data_ptr.contents.mbs_cons_jdqd = mbs_cons_jdqd_wrap(lambda jdqd,mbs,tsim : callback_undefined("mbs_cons_jdqd"))
self.mbs.mbs_invdyna = None
self.mbs.mbs_data_ptr.contents.mbs_invdyna = mbs_invdyna_wrap(lambda Q,mbs,tsim : callback_undefined("mbs_invdyna"))
self.mbs.mbs_dirdyna = None
self.mbs.mbs_data_ptr.contents.mbs_dirdyna = mbs_dirdyna_wrap(lambda M,c,mbs,tsim : callback_undefined("mbs_dirdyna"))
return
def __del__(self):
libmodules.mbs_delete_invdyn(self.mbs_invdyn_ptr, self.mbs.mbs_data_ptr)
if __DEBUG__ : print("DEBUG>> MbsInvdyn pointer deleted")
if __DEBUG__ : print("DEBUG>> " +self.module_name + " pointer deleted")
def run(self):
"""
......@@ -307,6 +333,8 @@ class MbsInvdyn(object):
Options can be setted with set_options
Options can be retrieved with get_options
Results are stored in the field results (if store_results == True)
"""
# Assing required user functions
self.__assign_user_fct__()
......@@ -316,7 +344,19 @@ class MbsInvdyn(object):
self.__assign_symbolic_fct__()
self.mbs.__assign_symb_fct__()
libmodules.mbs_run_invdyn(self.mbs_invdyn_ptr, self.mbs.mbs_data_ptr)
if not self.store_results:
libmodules.mbs_run_invdyn(self.mbs_invdyn_ptr, self.mbs.mbs_data_ptr)
else:
#save2file forced to 1 because if buffers don't have the complete results, results are loaded from files
self.set_options(save2file = 1)
libmodules.mbs_invdyn_init(self.mbs_invdyn_ptr, self.mbs.mbs_data_ptr)
libmodules.mbs_invdyn_loop(self.mbs_invdyn_ptr, self.mbs.mbs_data_ptr)
# Results (buffer) memory is kept BUT FILES WILL BE WRITTEN LATER
if self.get_options("save2file"):
self._load_results()
libmodules.mbs_invdyn_finish(self.mbs_invdyn_ptr, self.mbs.mbs_data_ptr)
# Anassign user functions
self.__unassign_user_fct__()
......@@ -326,6 +366,55 @@ class MbsInvdyn(object):
self.__unassign_symbolic_fct__()
self.mbs.__unassign_symb_fct__()
def _load_results(self):
"""
Load the results from the buffers
If the beginning of the integration is not available in the buffers,
the complete results are loaded from files
"""
#c_mbs_invdyn_write_buffers(self.mbs_invdyn_ptr)
size1 = self.mbs_invdyn_ptr.contents.buffers[0].contents.index
if size1 == 0:
size1 = self.mbs_invdyn_ptr.contents.buffers[0].contents.size
size2 = self.mbs_invdyn_ptr.contents.buffers[0].contents.nx+1
# array are initialized to the time pointer so as to start index of joints at 1 (we have to ensure contiguity between t and x in buffers ! ! !)
self.results.q = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.buffers[0].contents.tx ,(size1, size2)))
# get time array from the q buffer
self.results.t = self.results.q[:,0]
if not self.results.t[0] == self.get_options("t0"):
print("The beginning of the integration is not available in the buffer.\n The complete results have to be loaded from files.")
self.results.load_results_from_file()
# get qd and qdd buffer
self.results.qd = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.buffers[1].contents.tx ,(size1, size2)))
self.results.qdd = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.buffers[2].contents.tx ,(size1, size2)))
size2 = self.mbs_invdyn_ptr.contents.buffers[3].contents.nx+1
self.results.Qq = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.buffers[3].contents.tx ,(size1, size2)))
if self.module_name == "MbsInvdyn":
size2 = self.mbs_invdyn_ptr.contents.buffers[4].contents.nx+1
self.results.qa = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.buffers[4].contents.tx ,(size1, size2)))
buffer_id = 5
else:
buffer_id = 4
if self.mbs.Nlink:
size2 = self.mbs_invdyn_ptr.contents.buffers[buffer_id].contents.nx+1
self.results.Z = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.buffers[buffer_id].contents.tx ,(size1, size2)))
self.results.Zd = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.buffers[buffer_id+1].contents.tx ,(size1, size2)))
self.results.Fl = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.buffers[buffer_id+2].contents.tx ,(size1, size2)))
buffer_id = buffer_id + 3
if self.mbs.nqc:
size2 = self.mbs_invdyn_ptr.contents.buffers[buffer_id].contents.nx+1
self.results.Qc = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.buffers[buffer_id].contents.tx ,(size1, size2)))
if self.mbs_invdyn_ptr.contents.user_buffer.contents.nx:
size = self.mbs_invdyn_ptr.contents.user_buffer.contents.index
nbOutput = self.mbs_invdyn_ptr.contents.user_buffer.contents.nx
user_out = np.copy(np.ctypeslib.as_array(self.mbs_invdyn_ptr.contents.user_buffer.contents.X[0],(nbOutput, size)))
for i in range(nbOutput):
name = self.mbs_invdyn_ptr.contents.user_buffer.contents.names[i]
name = name.decode('utf-8')
self.results.outputs[name] = user_out[i,:]
def set_options(self, **kwargs):
"""
......@@ -414,7 +503,19 @@ class MbsInvdyn(object):
for key, value in kwargs.items():
if key == "motion":
self.mbs_invdyn_ptr.contents.options.contents.motion = value
if (type(value) is int) and (value>=0 and value<=2):
self.mbs_invdyn_ptr.contents.options.contents.motion = value
elif type(value) is str:
if value == "oneshot":
self.mbs_invdyn_ptr.contents.options.contents.motion = 0
elif value == "closeloop":
self.mbs_invdyn_ptr.contents.options.contents.motion = 1
elif value == "trajectory":
self.mbs_invdyn_ptr.contents.options.contents.motion = 2
else:
print(">>" +self.module_name + ">> " + value + " is not an motion")
else:
print(">>" +self.module_name + ">> " + value + " is not an motion")
elif key == "trajectoryqname":
self.mbs_invdyn_ptr.contents.options.contents.trajectoryqname = value.encode('utf-8')
elif key == "trajectoryqdname":
......@@ -450,7 +551,7 @@ class MbsInvdyn(object):
elif key == "store_results":
self.store_results = value
else:
print(">>INVDYN>> The option "+key+ " is not defined in this module")
print(">>" +self.module_name + ">> The option "+key+ " is not defined in this module")
def get_options(self, *args):
"""
......@@ -471,7 +572,12 @@ class MbsInvdyn(object):
options = []
for key in args:
if key == "motion":
options.append(self.mbs_invdyn_ptr.contents.options.contents.motion)
if self.mbs_invdyn_ptr.contents.options.contents.motion == 0:
options.append("oneshot")
elif self.mbs_invdyn_ptr.contents.options.contents.motion == 1:
options.append("closeloop")
elif self.mbs_invdyn_ptr.contents.options.contents.motion == 2:
options.append("trajectory")
elif key == "trajectoryqname":
options.append(ctypes.string_at(self.mbs_invdyn_ptr.contents.options.contents.trajectoryqname).decode("utf-8"))
elif key == "trajectoryqdname":
......@@ -507,7 +613,7 @@ class MbsInvdyn(object):
elif key == "store_results":
options.append(self.store_results)
else:
print(">>INVDYN>> The option "+key+ " is not defined in this module")
print(">>" +self.module_name + ">> The option "+key+ " is not defined in this module")
if len(options) == 0:
return
......
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