Commit 1c0e5f24 authored by Olivier Lantsoght's avatar Olivier Lantsoght
Browse files

[Ctypes] Doc

parent e0dff722
......@@ -440,22 +440,22 @@ class MbsData(object):
def __load_user_fct__(self, user_path=None):
"""
Load all user functions where arguments are in MbsData instance.
Only load the user functions in which the arguments are not
dependent of another module instance (ie. MbsPart, MbsDirdyn...).
The other user functions will be loaded when a module is created.
The functions will be assigned to the MbsData instance when
the 'run' function in other modules is called and unassigned
at the end.
The loader user functions are :
- user_derivatives (from derivatives.py)
- user_DrivenJoints (from driven_joints.py)
- user_ExtForces (from ext_forces.py)
- user_JointForces (from joint_forces.py)
- user_LinkForces (from link_forces.py)
- user_Link3DForces (from link3D_forces.py)
Load all user functions where arguments are in MbsData instance.
Only load the user functions in which the arguments are not
dependent of another module instance (ie. MbsPart, MbsDirdyn...).
The other user functions will be loaded when a module is created.
The functions will be assigned to the MbsData instance when
the 'run' function in other modules is called and unassigned
at the end.
The loader user functions are :
- user_derivatives (from derivatives.py)
- user_DrivenJoints (from driven_joints.py)
- user_ExtForces (from ext_forces.py)
- user_JointForces (from joint_forces.py)
- user_LinkForces (from link_forces.py)
- user_Link3DForces (from link3D_forces.py)
"""
template_path = os.path.join(__MODULE_DIR__,'../templates/user')
project_path = self.project_path
......@@ -530,23 +530,23 @@ class MbsData(object):
def __load_symb_fct__(self, symb_path=None):
"""
Load all symbolic functions if all args are in MbsData instance.
Only load the symbolic functions in which the arguments are not
dependent of another module instance (ie. MbsPart, MbsDirdyn...).
The other symbolic functions will be loaded when a module is
instancied.
The functions will be assigned to the MbsData instance when
the 'run' function in other modules is called and unassigned
at the end.
The loader symbolic functions are :
- mbs_accelred (from mbs_accelred_MBSNAME.py)
- extforces (from mbs_extforces_MBSNAME.py)
- sensor (from mbs_gensensor_MBSNAME.py)
- sensor (from mbs_sensor_MBSNAME.py)
- link (from mbs_link_MBSNAME.py)
- link3D (from mbs_link3D_MBSNAME.py)
Load all symbolic functions if all args are in MbsData instance.
Only load the symbolic functions in which the arguments are not
dependent of another module instance (ie. MbsPart, MbsDirdyn...).
The other symbolic functions will be loaded when a module is
instancied.
The functions will be assigned to the MbsData instance when
the 'run' function in other modules is called and unassigned
at the end.
The loader symbolic functions are :
- mbs_accelred (from mbs_accelred_MBSNAME.py)
- extforces (from mbs_extforces_MBSNAME.py)
- sensor (from mbs_gensensor_MBSNAME.py)
- sensor (from mbs_sensor_MBSNAME.py)
- link (from mbs_link_MBSNAME.py)
- link3D (from mbs_link3D_MBSNAME.py)
"""
mbs_name = self.mbs_name
......@@ -628,14 +628,14 @@ class MbsData(object):
def __assign_user_fct__(self):
"""
Assign all user functions if all args are in MbsData instance.
Assign and wrap python user functions in which the arguments are
not dependent of another module instance (ie. MbsPart, MbsDirdyn...).
Store the functions in the MbsData instance and assign the pointer
of functions in the C structure.
The other user functions will be assigned when a module is
instancied.
Assign all user functions if all args are in MbsData instance.
Assign and wrap python user functions in which the arguments are
not dependent of another module instance (ie. MbsPart, MbsDirdyn...).
Store the functions in the MbsData instance and assign the pointer
of functions in the C structure.
The other user functions will be assigned when a module is
instancied.
"""
data_c_ptr=self.mbs_data_ptr.contents
......@@ -668,14 +668,14 @@ class MbsData(object):
def __assign_symb_fct__(self):
"""
Assign all symbolic functions if all args are in MbsData instance.
Assign and wrap python symbolic functions in which the arguments are
not dependent of another module instance (ie. MbsPart, MbsDirdyn...).
Store the functions in the MbsData instance and assign the pointer
of functions in the C structure.
The other user functions will be assigned when a module is
instancied.
Assign all symbolic functions if all args are in MbsData instance.
Assign and wrap python symbolic functions in which the arguments are
not dependent of another module instance (ie. MbsPart, MbsDirdyn...).
Store the functions in the MbsData instance and assign the pointer
of functions in the C structure.
The other user functions will be assigned when a module is
instancied.
"""
data_c_ptr=self.mbs_data_ptr.contents
......@@ -726,8 +726,7 @@ class MbsData(object):
self.SWr[ixF,1:7] = SWr[1:7]
def __callback_mbs_sensor(self, fun, sens, isens):
""" callback for gensensor, forcesensor and sensor
"""
""" callback for gensensor, forcesensor and sensor """
self.__sens.__reassign_memory__(sens)
fun(self.__sens,self, isens)
......@@ -737,10 +736,10 @@ class MbsData(object):
def __unassign_user_fct__(self):
"""
Unassign all user function if all args are in MbsData instance.
Only unassign the user functions in which the arguments are not
dependent of another module instance (ie. MbsPart, MbsDirdyn...).
Unassign all user function if all args are in MbsData instance.
Only unassign the user functions in which the arguments are not
dependent of another module instance (ie. MbsPart, MbsDirdyn...).
"""
#not necessary but if not present, dictionary must be filled in the load
#function and not the assign function
......@@ -755,10 +754,10 @@ class MbsData(object):
def __unassign_symb_fct__(self):
"""
Unassign all symbolic function if all args are in MbsData instance.
Only unassign the symbolic functions in which the arguments are not
dependent of another module instance (ie. MbsPart, MbsDirdyn...).
Unassign all symbolic function if all args are in MbsData instance.
Only unassign the symbolic functions in which the arguments are not
dependent of another module instance (ie. MbsPart, MbsDirdyn...).
"""
#not necessary but if not present, dictionary must be filled in the load
#function and not the assign function
......@@ -773,8 +772,8 @@ class MbsData(object):
def __generate_id__(self):
"""
Read the id's of the joints, links, sensors and extforces from MbsInfos
structure and store them into dictionaries in the MbsData instance.
Read the id's of the joints, links, sensors and extforces from MbsInfos
structure and store them into dictionaries in the MbsData instance.
"""
for i in range(self.njoint):
......@@ -801,13 +800,13 @@ class MbsData(object):
def __load_user_model__(self):
"""
Load user models in 2 nested dictionaries
The first one contains the names of the user models as keys and a
second dictionary for the parameters as values.
The second one contains the names of the parameters as keys and
numpy arrays that point toward C memory as values
Load user models in 2 nested dictionaries
The first one contains the names of the user models as keys and a
second dictionary for the parameters as values.
The second one contains the names of the parameters as keys and
numpy arrays that point toward C memory as values
"""
self.user_model._locked = False
infos_c_ptr=self.mbs_infos_ptr.contents
......@@ -845,13 +844,11 @@ class MbsData(object):
def set_nb_userc(self, nb):
""" Set the number of user constraints.
"""
""" Set the number of user constraints. """
libutilities.mbs_set_nb_userc(self.mbs_data_ptr, nb)
def set_qu(self, indices):
""" Set the specified joints as independent.
"""
""" Set the specified joints as independent. """
if isinstance(indices,(list,np.ndarray)):
for index in indices:
libutilities.mbs_set_qu(self.mbs_data_ptr, index)
......@@ -859,8 +856,7 @@ class MbsData(object):
libutilities.mbs_set_qu(self.mbs_data_ptr, indices)
def set_qv(self, indices):
""" Set the specified joints as dependent.
"""
""" Set the specified joints as dependent. """
if isinstance(indices,(list,np.ndarray)):
for index in indices:
libutilities.mbs_set_qv(self.mbs_data_ptr, index)
......@@ -868,8 +864,7 @@ class MbsData(object):
libutilities.mbs_set_qv(self.mbs_data_ptr, indices)
def set_qa(self, indices):
""" Set a variable to actuated partition
"""
""" Set a variable to actuated partition. """
if isinstance(indices,(list,np.ndarray)):
for index in indices:
libutilities.mbs_set_qa(self.mbs_data_ptr, index)
......@@ -877,8 +872,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
"""
""" Unset a variable from the actuated partition. """
if isinstance(indices,(list,np.ndarray)):
for index in indices:
libutilities.mbs_unset_qa(self.mbs_data_ptr, index)
......@@ -886,37 +880,39 @@ class MbsData(object):
libutilities.mbs_unset_qa(self.mbs_data_ptr, indices)
def empty_qa(self):
""" Remove all joints from the actuated partition
"""
""" Remove all joints from the actuated partition. """
libutilities.mbs_empty_qa(self.mbs_data_ptr)
def __del__(self):
libloadXML.mbs_delete_infos(self.mbs_infos_ptr)
libloadXML.mbs_delete_data(self.mbs_data_ptr)
if __DEBUG__ : print("DEBUG>> MbsData pointer deleted")
def mbs_reset_data(self,verbose=True):
"""
Reset mbs_data to its inital value
"""
def reset(self,verbose=False):
""" Reset mbs_data to its inital value."""
libutilities.mbs_reset_data(self.mbs_data_ptr)
if verbose :
print("mbs_data reseted to initial value")
def mbs_load_from_file(self, baseFileName="dirdyn", result_path="resultsR", time = -1):
""" Load a state to MbsData instance from files for specific time.
If the time specified is not found in the file, the last time step
lower than the specification is taken.
The fieds q, qd, qdd, ux, uxd, q0, qd0, qdd0, ux0 ant tsim are set.
:param baseFileName The path and resfilename containing the state to load.
The suffix _q, _qd, _ux.res will be added.
default = "dirdyn" if not specified
:param result_path The relative path of the result folder from the project folder
default = "resultsR" if not specified
:param time The time corresponding to the state to load
defaut value is the last state.
If the time specified is not found in the file, the last time step
lower than the specification is taken.
The fieds q, qd, qdd, ux, uxd, q0, qd0, qdd0, ux0 ant tsim are set.
Parameters
----------
baseFileName : str
The path and resfilename containing the state to load. The suffix
_q, _qd, _ux.res will be added.
default is "dirdyn"
result_path : str
The relative path of the result folder from the project folder.
default is "resultsR"
time : float
The time corresponding to the state to load.
defaut is "-1" (last state of the files).
"""
def find_index(temp, t):
if (t == -1):
......@@ -1006,14 +1002,20 @@ class MbsData(object):
if __DEBUG__ : print( "DEBUG>> file '"+CurFile+"' not found in folder '"+os.path.dirname(path))
def exe_dirdyn(self, **kwargs):
""" Run a dirdyn module with a specified set of options
Also run a partitioning module if needed.
Partioning options are setted to default values expect rowperm = 1
param : options of the dirdyn module (see set_options in dirdyn module)
out : MbsResults instance
""" Run a dirdyn module with a specified set of options.
Also run a partitioning module if needed.
Partioning options are setted to default values expect rowperm = 1
Parameters
----------
kwargs
Options to user for the analysis (see 'set_options' in MbsDirdyn).
Returns
-------
results : MbsResults instance
This object contains the results of the dirdyn analysis.
"""
if (not self.DonePart) and self.Ncons:
mbs_part = MbsPart(self)
......@@ -1030,9 +1032,12 @@ class MbsData(object):
return results
def exe_part(self, **kwargs):
""" Run a partitioning module with the specified options
param : options of the partitioning module (see set_options in part module)
""" Run a partitioning module with the specified set of options.
Parameters
----------
kwargs :
Options of the partitioning module (see 'set_options' in MbsPart).
"""
mbs_part = MbsPart(self)
......
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