Commit 8b1895df authored by Olivier Lantsoght's avatar Olivier Lantsoght 🏁
Browse files

[MBsysPy] Pep8.

parent 3ed1cd35
# -*- coding: utf-8 -*-
"""
-------------------------------
(c) Universite catholique de Louvain, 2019
"""Definition of CFUNCTYPE needed for callback functions."""
# (c) Universite catholique de Louvain, 2019
Creation : 2019 by O. Lantsoght
Last update : 2019
version MBsysC v1.11.2
-------------------------------
Portable Python interface to MBsysC using Ctypes.
Definition of CFUNCTYPE needed for callback functions.
"""
import ctypes
......@@ -28,15 +16,15 @@ from .forward_decl import MbsInfos_c
from .forward_decl import MbsSensor_c
#==============================================================================
# =============================================================================
# Global parameter of the current module
#==============================================================================
# =============================================================================
__DEBUG__ = False
#==============================================================================
# =============================================================================
# Declaration of function to be linked with the libraries
#==============================================================================
# =============================================================================
# User
user_JointForces_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(MbsData_c), ctypes.c_double)
user_load_post_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(MbsData_c))
......@@ -63,11 +51,11 @@ mbs_new_user_model_wrap = ctypes.CFUNCTYPE(ctypes.POINTER(UserModel_c))
mbs_delete_user_model_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(UserModel_c))
mbs_delete_user_IO_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(UserIO_c))
mbs_get_user_IO_size_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
mbs_load_user_model_xml_wrap= ctypes.CFUNCTYPE(None, ctypes.POINTER(MbsInfos_c), ctypes.POINTER(UserModel_c))
mbs_load_user_model_xml_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(MbsInfos_c), ctypes.POINTER(UserModel_c))
mbs_bind_user_model_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(MbsInfos_c), ctypes.POINTER(UserModel_c))
mbs_print_user_model_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(UserModel_c))
mbs_get_user_model_size_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_int))
mbs_get_user_model_list_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_int))
mbs_get_user_model_list_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_int))
# Symbolic
mbs_link_wrap = ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.POINTER(ctypes.c_double)), ctypes.POINTER(ctypes.POINTER(ctypes.c_double)), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(MbsData_c), ctypes.c_double)
......
# -*- coding: utf-8 -*-
"""
-------------------------------
(c) Universite catholique de Louvain, 2019
Creation : 2019 by O. Lantsoght
Last update : 2019
version MBsysC v1.11.2
-------------------------------
Portable Python interface to MBsysC using Ctypes.
Forward declaration of all required MBsysC structure.
"""
"""Forward declaration of all required MBsysC structure."""
# (c) Universite catholique de Louvain, 2019
import ctypes
#==============================================================================
# =============================================================================
# Global parameter of the current module
#==============================================================================
# =============================================================================
__DEBUG__ = False
#==============================================================================
# =============================================================================
# forward declaration of structures (C) as class
#==============================================================================
# =============================================================================
class MbsInfos_c(ctypes.Structure):
pass
class MbsInfoBase_c(ctypes.Structure):
......@@ -120,4 +107,4 @@ class AnimInfo_c(ctypes.Structure):
class MbsLpk_c(ctypes.Structure):
pass
class MbsSS_c(ctypes.Structure):
pass
\ No newline at end of file
pass
# -*- coding: utf-8 -*-
"""
-------------------------------
(c) Universite catholique de Louvain, 2019
Creation : 2019 by O. Lantsoght
Last update : 2019
version MBsysC v1.11.2
-------------------------------
Portable Python interface to MBsysC using Ctypes.
While generating the libraries:
- SENSORKIN MUST BE UNDEFINED
- REALTIME MUST BE UNDEFINED
- PRJ_FCT_PTR MUST BE DEFINED
Declaration of MBsysC structure related to mbs_data.h header file in MBsysC.
"""
"""Declaration of MBsysC structure related to mbs_data.h header file in MBsysC."""
# (c) Universite catholique de Louvain, 2019
import ctypes
......@@ -73,186 +54,189 @@ from .callback import mbs_sensor_wrap
from .callback import mbs_gensensor_wrap
#==============================================================================
# =============================================================================
# user_c
#==============================================================================
user_c._fields_ =[# REAL_TIME cannot be defined
("user_JointForces", user_JointForces_wrap),
# user load
("user_load_post", user_load_post_wrap),
# user dirdyn
("user_dirdyn_init", user_dirdyn_init_wrap),
("user_dirdyn_loop", user_dirdyn_loop_wrap),
("user_dirdyn_finish", user_dirdyn_finish_wrap),
# user equil
("user_equil_init", user_equil_init_wrap),
("user_equil_loop", user_equil_loop_wrap),
("user_equil_finish", user_equil_finish_wrap),
("user_equil_fxe", user_equil_fxe_wrap),
# Generalities
("user_Derivative", user_Derivative_wrap),
("user_DrivenJoints", user_DrivenJoints_wrap),
("user_cons_hJ", user_cons_hJ_wrap),
("user_cons_jdqd", user_cons_jdqd_wrap),
("user_LinkForces", user_LinkForces_wrap),
("user_Link3DForces", user_Link3DForces_wrap),
("user_ExtForces", user_ExtForces_wrap),
# data exchange
("mbs_new_user_IO", mbs_new_user_IO_wrap),
("mbs_new_user_model", mbs_new_user_model_wrap),
("mbs_delete_user_model", mbs_delete_user_model_wrap),
("mbs_delete_user_IO", mbs_delete_user_IO_wrap),
("mbs_get_user_IO_size", mbs_get_user_IO_size_wrap),
("mbs_load_user_model_xml", mbs_load_user_model_xml_wrap),
("mbs_bind_user_model", mbs_bind_user_model_wrap),
("mbs_print_user_model", mbs_print_user_model_wrap),
("mbs_get_user_model_size", mbs_get_user_model_size_wrap),
("mbs_get_user_model_list", mbs_get_user_model_list_wrap)
]
#==============================================================================
# =============================================================================
user_c._fields_ = [
("user_JointForces", user_JointForces_wrap),
# user load
("user_load_post", user_load_post_wrap),
# user dirdyn
("user_dirdyn_init", user_dirdyn_init_wrap),
("user_dirdyn_loop", user_dirdyn_loop_wrap),
("user_dirdyn_finish", user_dirdyn_finish_wrap),
# user equil
("user_equil_init", user_equil_init_wrap),
("user_equil_loop", user_equil_loop_wrap),
("user_equil_finish", user_equil_finish_wrap),
("user_equil_fxe", user_equil_fxe_wrap),
# Generalities
("user_Derivative", user_Derivative_wrap),
("user_DrivenJoints", user_DrivenJoints_wrap),
("user_cons_hJ", user_cons_hJ_wrap),
("user_cons_jdqd", user_cons_jdqd_wrap),
("user_LinkForces", user_LinkForces_wrap),
("user_Link3DForces", user_Link3DForces_wrap),
("user_ExtForces", user_ExtForces_wrap),
# data exchange
("mbs_new_user_IO", mbs_new_user_IO_wrap),
("mbs_new_user_model", mbs_new_user_model_wrap),
("mbs_delete_user_model", mbs_delete_user_model_wrap),
("mbs_delete_user_IO", mbs_delete_user_IO_wrap),
("mbs_get_user_IO_size", mbs_get_user_IO_size_wrap),
("mbs_load_user_model_xml", mbs_load_user_model_xml_wrap),
("mbs_bind_user_model", mbs_bind_user_model_wrap),
("mbs_print_user_model", mbs_print_user_model_wrap),
("mbs_get_user_model_size", mbs_get_user_model_size_wrap),
("mbs_get_user_model_list", mbs_get_user_model_list_wrap)
]
# =============================================================================
# symb_c
#==============================================================================
symb_c._fields_ =[# REAL_TIME cannot be defined
("mbs_link", mbs_link_wrap),
("mbs_link3D", mbs_link3D_wrap),
("mbs_extforces", mbs_extforces_wrap),
("mbs_accelred", mbs_accelred_wrap),
("mbs_dirdyna", mbs_dirdyna_wrap),
("mbs_invdyna", mbs_invdyna_wrap),
("mbs_cons_hJ", mbs_cons_hJ_wrap),
("mbs_cons_jdqd", mbs_cons_jdqd_wrap),
("mbs_sensor", mbs_sensor_wrap),
("mbs_gensensor", mbs_gensensor_wrap)]
#==============================================================================
# =============================================================================
symb_c._fields_ = [
("mbs_link", mbs_link_wrap),
("mbs_link3D", mbs_link3D_wrap),
("mbs_extforces", mbs_extforces_wrap),
("mbs_accelred", mbs_accelred_wrap),
("mbs_dirdyna", mbs_dirdyna_wrap),
("mbs_invdyna", mbs_invdyna_wrap),
("mbs_cons_hJ", mbs_cons_hJ_wrap),
("mbs_cons_jdqd", mbs_cons_jdqd_wrap),
("mbs_sensor", mbs_sensor_wrap),
("mbs_gensensor", mbs_gensensor_wrap)
]
# =============================================================================
# Functions_c
#==============================================================================
Functions_c._anonymous_ = ("user","symb")
Functions_c._fields_ =[
("symbolicLibHandle", ctypes.POINTER(MbsDataLibInfo_c)),
("userfctLibHandle", ctypes.POINTER(MbsDataLibInfo_c)),
("symb", symb_c),
("user", user_c)]
#==============================================================================
# =============================================================================
Functions_c._anonymous_ = ("user", "symb")
Functions_c._fields_ = [
("symbolicLibHandle", ctypes.POINTER(MbsDataLibInfo_c)),
("userfctLibHandle", ctypes.POINTER(MbsDataLibInfo_c)),
("symb", symb_c),
("user", user_c)
]
# =============================================================================
# MbsData_c
#==============================================================================
# =============================================================================
MbsData_c._anonymous_ = ("fct",)
MbsData_c._fields_ =[
MbsData_c._fields_ = [
# Geometric and dynamic datas
("npt", ctypes.c_int),
("dpt", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("l", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("m", ctypes.POINTER(ctypes.c_double)),
("In", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("g", ctypes.c_double*(3+1)),
("nbody", ctypes.c_int),
("njoint", ctypes.c_int),
("npt", ctypes.c_int),
("dpt", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("l", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("m", ctypes.POINTER(ctypes.c_double)),
("In", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("g", ctypes.c_double * (3 + 1)),
("nbody", ctypes.c_int),
("njoint", ctypes.c_int),
# Coordinate partiotionning datas
("nqu", ctypes.c_int),
("nqc", ctypes.c_int),
("nqlocked",ctypes.c_int),
("nqdriven",ctypes.c_int),
("nqa", ctypes.c_int),
("nqv", ctypes.c_int),
("nhu", ctypes.c_int),
("qu", ctypes.POINTER(ctypes.c_int)),
("qc", ctypes.POINTER(ctypes.c_int)),
("nqu", ctypes.c_int),
("nqc", ctypes.c_int),
("nqlocked", ctypes.c_int),
("nqdriven", ctypes.c_int),
("nqa", ctypes.c_int),
("nqv", ctypes.c_int),
("nhu", ctypes.c_int),
("qu", ctypes.POINTER(ctypes.c_int)),
("qc", ctypes.POINTER(ctypes.c_int)),
("qlocked", ctypes.POINTER(ctypes.c_int)),
("qdriven", ctypes.POINTER(ctypes.c_int)),
("qa", ctypes.POINTER(ctypes.c_int)),
("qv", ctypes.POINTER(ctypes.c_int)),
("hu", ctypes.POINTER(ctypes.c_int)),
("qa", ctypes.POINTER(ctypes.c_int)),
("qv", ctypes.POINTER(ctypes.c_int)),
("hu", ctypes.POINTER(ctypes.c_int)),
# Initial and current generalized coordinates, velocties and acceleration
("q", ctypes.POINTER(ctypes.c_double)),
("qd", ctypes.POINTER(ctypes.c_double)),
("qdd", ctypes.POINTER(ctypes.c_double)),
("q0", ctypes.POINTER(ctypes.c_double)),
("qd0", ctypes.POINTER(ctypes.c_double)),
("qdd0", ctypes.POINTER(ctypes.c_double)),
("q", ctypes.POINTER(ctypes.c_double)),
("qd", ctypes.POINTER(ctypes.c_double)),
("qdd", ctypes.POINTER(ctypes.c_double)),
("q0", ctypes.POINTER(ctypes.c_double)),
("qd0", ctypes.POINTER(ctypes.c_double)),
("qdd0", ctypes.POINTER(ctypes.c_double)),
# Time and array for forces and torques
("frc", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("trq", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("Qq", ctypes.POINTER(ctypes.c_double)),
("Qa", ctypes.POINTER(ctypes.c_double)),
("tsim", ctypes.c_double),
("t0", ctypes.c_double),
("tf", ctypes.c_double),
("dt0", ctypes.c_double),
("frc", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("trq", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("Qq", ctypes.POINTER(ctypes.c_double)),
("Qa", ctypes.POINTER(ctypes.c_double)),
("tsim", ctypes.c_double),
("t0", ctypes.c_double),
("tf", ctypes.c_double),
("dt0", ctypes.c_double),
# Constraints datas
("lrod", ctypes.POINTER(ctypes.c_double)),
("Nloopc", ctypes.c_int),
("Ncons", ctypes.c_int),
("Nuserc", ctypes.c_int),
("NRerr", ctypes.c_double),
("lambda_", ctypes.POINTER(ctypes.c_double)),
("lrod", ctypes.POINTER(ctypes.c_double)),
("Nloopc", ctypes.c_int),
("Ncons", ctypes.c_int),
("Nuserc", ctypes.c_int),
("NRerr", ctypes.c_double),
("lambda_", ctypes.POINTER(ctypes.c_double)),
# The true key is "lambda" (lowe "l"), but this is a reserved keyword in
# Python, so a single trailing underscore is added.
# Forces in driven joints
("Qc", ctypes.POINTER(ctypes.c_double)),
("Qc", ctypes.POINTER(ctypes.c_double)),
# Links constraints
("Nlink", ctypes.c_int),
("Nlink", ctypes.c_int),
("Nlink3D", ctypes.c_int),
("Z", ctypes.POINTER(ctypes.c_double)),
("Zd", ctypes.POINTER(ctypes.c_double)),
("Fl", ctypes.POINTER(ctypes.c_double)),
("l3DWr", ctypes.POINTER(ctypes.c_double)),
("Z", ctypes.POINTER(ctypes.c_double)),
("Zd", ctypes.POINTER(ctypes.c_double)),
("Fl", ctypes.POINTER(ctypes.c_double)),
("l3DWr", ctypes.POINTER(ctypes.c_double)),
# Sensors
("Nsensor", ctypes.c_int),
# External forces
("Nxfrc", ctypes.c_int),
("xfidpt", ctypes.POINTER(ctypes.c_int)),
("SWr", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
("Nxfrc", ctypes.c_int),
("xfidpt", ctypes.POINTER(ctypes.c_int)),
("SWr", ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
# User model & User IO
# SENSORKIN MUST BE UNDEFINED
("Nuser_model", ctypes.c_int),
("user_model", ctypes.POINTER(UserModel_c)),
("n_user_IO", ctypes.c_int),
("user_IO", ctypes.POINTER(UserIO_c)),
("__user_IO_info", ctypes.POINTER(UserIoInfo_c)),
("Nuser_model", ctypes.c_int),
("user_model", ctypes.POINTER(UserModel_c)),
("n_user_IO", ctypes.c_int),
("user_IO", ctypes.POINTER(UserIO_c)),
("__user_IO_info", ctypes.POINTER(UserIoInfo_c)),
# User state
("ux", ctypes.POINTER(ctypes.c_double)),
("uxd", ctypes.POINTER(ctypes.c_double)),
("ux0", ctypes.POINTER(ctypes.c_double)),
("Nux", ctypes.c_int),
("ux", ctypes.POINTER(ctypes.c_double)),
("uxd", ctypes.POINTER(ctypes.c_double)),
("ux0", ctypes.POINTER(ctypes.c_double)),
("Nux", ctypes.c_int),
# Other fields
("udd", ctypes.POINTER(ctypes.c_double)),
("DonePart", ctypes.c_int),
("DoneEquil", ctypes.c_int),
("DoneModal", ctypes.c_int),
("process", ctypes.c_int),
("simu_end", ctypes.c_int),
("flag_stop", ctypes.c_int),
("mbs_filename", ctypes.c_char_p),
("build_path", ctypes.c_char_p),
("project_path", ctypes.c_char_p),
("mbs_name", ctypes.c_char_p),
# REALTIME FLAG MUST BE UNDEFINED
#("realtime", ctypes.c_void_p),
("udd", ctypes.POINTER(ctypes.c_double)),
("DonePart", ctypes.c_int),
("DoneEquil", ctypes.c_int),
("DoneModal", ctypes.c_int),
("process", ctypes.c_int),
("simu_end", ctypes.c_int),
("flag_stop", ctypes.c_int),
("mbs_filename", ctypes.c_char_p),
("build_path", ctypes.c_char_p),
("project_path", ctypes.c_char_p),
("mbs_name", ctypes.c_char_p),
# Pointer to projects functions
# PRJ_FCT_PTR MUST BE DEFINED
("fct", Functions_c)]
\ No newline at end of file
("fct", Functions_c)
# REALTIME FLAG can be defined
# ("realtime", ctypes.c_void_p),
]
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