MBsysPy.mbsyspy.mbs_invdyn module¶
Module to handle inverse dynamic analysis on Multibody systems.
Summary¶
Define the class MbsInvdyn based on the MbsInvdyn structure of MBsysC. This class has the functions required to manipulate the direct dynamic module. This includes setting the options, running an(or multiple) analysis and freeing the memory.
-
class
MBsysPy.mbsyspy.mbs_invdyn.
MbsInvdyn
(mbs, user_path=None, symbolic_path=None)¶ Bases:
object
Class of the invdyn computation module.
- Variables
mbs (MbsData) – Instance of MbsData related to the analysis.
results (MbsResult) – Instance of MbsResult containing the results of the direct dynamics analysis.
symbolic_path (str) – Path to the folder containing the symbolic functions(python modules) to be loaded.
user_path (str) – Path to the folder containing the user functions(python modules) to be loaded.
- Attributes
buffer_nb
Access to bufferNb attribute (read-only).
Methods
get_options
(self, *args)Get the specified options for Invdyn module.
run
(self, **kwargs)Run an inverse dynamics analysis.
set_options
(self, **kwargs)Set the specified options for Invdyn module.
set_user_fct_from_file
(self, function_name, …)Load a user function from a file chosen by the user instead of the default one in the userfctR folder.
set_user_fct_from_ptr
(self, function_name, …)Load a user function chosen by the user instead of the default one in the userfctR folder.
-
__init__
(self, mbs, user_path=None, symbolic_path=None)¶ Create an instance of the MbsInvdyn class for the provided MbsData instance.
- Parameters
mbs (MbsData) – Instance of MbsData related to the analysis.
user_path (str or None, optional) – The path to the folder containing the user functions. If not provided (‘None’) the path is retrieved from the MbsData instance ‘mbs’. default is None
symbolic_path (str or None, optional) – The path to the folder containing the symbolic functions. If not provided(‘None’) the path is retrieved from the MbsData instance ‘mbs’. default is None
- Returns
MbsInvdyn – A MbsInvdyn instance.
- Return type
self
-
property
buffer_nb
¶ Access to bufferNb attribute (read-only).
-
get_options
(self, *args)¶ Get the specified options for Invdyn module.
- Parameters
The different options specified in the documentation of ‘set_options()’
- Returns
- Return type
The value of the different options specified in the documentation of ‘set_options()’
-
run
(self, **kwargs)¶ Run an inverse dynamics analysis.
Options can be set with set_options. Options can be retrieved with get_options
Results are stored in the field results(if store_results == True)
- Returns
self.results – The MbsResults containing the results of the analysis.
- Return type
-
set_options
(self, **kwargs)¶ Set the specified options for Invdyn module.
- Parameters
motion (int) – Determines how the evolution of q, qd qdd are provided. oneshot(default): Uses q, qd and qdd at the current time and configuration of the MBS. closeloop: Only for inverse kinematics analysis. Same as oneshot but save the iteration of the close loop process(NR). trajectory: Compute the evolution of between t0 and tf.
trajectoryqname (char) – Give the path and filename(with extension) to the file containing the input trajectory in position of the joints. Only required for motion == ‘trajectory’ if some joints are independent. By default, pointer to NULL. Requirement on the file: First column is the time, other are the joints coordinates. Either provide only the independent joint(by increasing index), user_drivenjoint will be called. Either provide all the joint, user_drivenjoint will be neglected.
trajectoryqdname (char) – Give the path and filename(with extension) to the file containing the input trajectory in velocity of the joints. Only required for motion == ‘trajectory’ if some joints are independent. By default, pointer to NULL. Requirement on the file: First column is the time, other are the joints velocities. Either provide only the independent joint(by increasing index), user_drivenjoint will be called. Either provide all the joint, user_drivenjoint will be neglected.
trajectoryqddname (char) – Give the path and filename(with extension) to the file containing the input trajectory in acceleration of the joints. Only required for motion == ‘trajectory’ if some joints are independent. By default, pointer to NULL. Requirement on the file: First column is the time, other are the joints accelerations. Either provide only the independent joint(by increasing index), user_drivenjoint will be called. Either provide all the joint, user_drivenjoint will be neglected.
t0 (float) – initial time of the simulation, default = 0.0
tf (float) – final time of the simulation, default = 5.0
dt (float) – Time step, default = 0.001 For motion == ‘trajectory’(for inverse kinematic analysis, there must be at least one independent joint): Set to 0.0 to use the time vector of the coordinate input file(MbsSolvekinOptions::t0 and MbsSolvekinOptions::tf are ignored). Specify a value to use specific time vector.
save2file (int) – Determine whether results are written to files on disk(in MbsSolvekinOptions::respath folder): 1: results are saved 0: results are not saved default = 1
resfilename (str) – The keyword used for determining the name of result files
respath (str) – Path in which result file are saved. Default: the resultsR folder of the project
animpath (str) – Path in which anim file is saved. Default: the animationR folder of the project
save_anim (int) – 1 to save the anim file 0 otherwise(only valid if ‘save2file’ is set to 1) default = 1
framerate (int) – number of frame per second for the .anim file default = 1000
saveperiod (int) – The number of time steps between two buffer records default: 1(every time step are recorded)
max_save_user (int) – The maximal number of user variables saved default: 12
buffersize (int) – The number of time step that can be recorded in the buffer. Results are written to disk when the buffer is full. default: -1 compute the buffer size for saving results only once at the end according to dt0, t0 and tf.
buffer_format (str) – The format for saving the data (double) to file. For example set “%.3e” to use scientific notation with 3 decimal. defaut: ‘%e’.
verbose (int) – Gives informations during the process. default: 1, to disable set it to 0.
store_results (boolean) – 1 to save a copy of the results from the buffers default = 1
-
set_user_fct_from_file
(self, function_name, user_path, user_file)¶ Load a user function from a file chosen by the user instead of the default one in the userfctR folder.
The function is then unassigned by the module at the end of the run().
- Parameters
function_name (str) – name of the user function to replace.
user_path (str) – path to the new user function file.
user_file (str) – name of the new user function file.
-
set_user_fct_from_ptr
(self, function_name, user_fct_ptr)¶ Load a user function chosen by the user instead of the default one in the userfctR folder.
The function is then unassigned by the module at the end of the run().
- Parameters
function_name (str) – name of the user function to replace.
user_fct_ptr (ptr) – new user function pointer.