Commit db261975 authored by Olivier Lantsoght's avatar Olivier Lantsoght
Browse files

[MBsysPy] Fix user output vector in outputs

parent 476eabea
......@@ -96,6 +96,8 @@ libutilities.mbs_set_error_msg_fct_ptr.restypes = None
libutilities.get_output_vector_nb.argtypes = []
libutilities.get_output_vector_nb.restypes = ctypes.c_int
libutilities.get_output_vector_label.argtypes = [ctypes.c_int]
libutilities.get_output_vector_label.restypes = ctypes.c_char_p
# LoadXML
libloadXML.mbs_info_reader.argtypes = [ctypes.c_char_p]
......
......@@ -33,6 +33,9 @@ def user_dirdyn_init(mbs, dd):
# In the next command, the sensor use the memory already allocated in C
mbs.sensors.append(Robotran.MbsSensor(mbs, 1, dd.mbs_dirdyn_ptr.contents.mbs_aux.contents.psens))
# We assign memory for storing a sensor field (vector only)
mbs.define_output_vector('sensor_velocity', 3)
return
......@@ -68,6 +71,8 @@ def user_dirdyn_loop(mbs, dd):
Robotran.set_output(mbs.sensors[0].A[3], "sensor_MbsData_MBsysPy")
Robotran.set_output(mbs.sensors[1].A[3], "sensor_Python_MBsysPy")
Robotran.set_output(mbs.sensors[2].A[3], "sensor_C_MBsysPy")
# Here we store all a vector
mbs.set_output_vector(mbs.sensors[1].V[1:], "sensor_velocity")
# Remark:
# All the approaches give the same results. If no new sensor are required,
......
......@@ -264,10 +264,9 @@ class MbsDirdyn(object):
nb_user_output_vector = libutilities.get_output_vector_nb()
for i in range(nb_user_output_vector):
ignored_length = len(bytes_to_str(ctypes.string_at(self.mbs_dirdyn_ptr.contents.options.contents.resfilename)))
size2 = self.mbs_dirdyn_ptr.contents.buffers[buffer_id].contents.nx + i
user_out = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[buffer_id].contents.tx, (size1, size2)))
name = os.path.basename(bytes_to_str(ctypes.string_at(self.mbs_dirdyn_ptr.contents.buffers[buffer_id].contents.filename)))[ignored_length:]
size2 = self.mbs_dirdyn_ptr.contents.buffers[buffer_id + i].contents.nx + 1
user_out = np.copy(np.ctypeslib.as_array(self.mbs_dirdyn_ptr.contents.buffers[buffer_id + i].contents.tx, (size1, size2)))
name = os.path.basename(bytes_to_str(ctypes.string_at(libutilities.get_output_vector_label(i))))
self.results.outputs[name] = user_out
if self.mbs_dirdyn_ptr.contents.user_buffer.contents.nx:
......
Markdown is supported
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