Commit 970c58c3 authored by Olivier Lantsoght's avatar Olivier Lantsoght
Browse files

[MBsysPy][Sensor] Callback for python sensor called by c library should work.

Only tested by (temporarly and thus removed) calling `mbs_sensor()` in `mbs_dirdyn_loop` function.
parent c78ebeda
......@@ -1503,9 +1503,32 @@ class MbsData(object):
self.SWr[ixF, 1:7] = SWr[1:7]
def __callback_mbs_sensor(self, fun, sens, isens):
"""Do the callback for gensensor, forcesensor and sensor."""
fun(self.__sens, self, isens)
"""Do the callback for gensensor, forcesensor and sensor.
This callback is used when a C-library (MBsysC, symbolicR, userfctR) calls
ask for the computation of a sensor if the symbolic functions are in
Currently the MBsysC core library never calls for a sensor computation.
Currently MBsysPy does not allows to load a userfctR C-library with
symbolic functions in Python.
So this function should never be called and has not been tested.
This function is defined for the future (change in MBsysPy, addons...).
mbs_warning("Warning: Computing MBsysPy sensor from C-library has not been tested! Check your results with care.")
# Check if the sensor is MBsysPy.MbsSensor instance or C pointer
if isinstance(sens, MbsSensor):
# Then use the current sensor
__sens = sens
# Then create a MbsSensor arout the C pointer
__sens = MbsSensor(self, id_=isens, sensor_ptr=sens)
# Note: The C-memory will not be freed by object destructor.
fun(__sens, self, isens)
def __callback_user_cons_hJ_part(self, fun, h, Jac, tsim):
__h = np.ctypeslib.as_array(h, (self.Nuserc + 1,))
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