Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
robotran
mbsysc
Commits
db261975
Commit
db261975
authored
Oct 14, 2020
by
Olivier Lantsoght
Browse files
[MBsysPy] Fix user output vector in outputs
parent
476eabea
Changes
3
Hide whitespace changes
Inline
Side-by-side
MBsysC/mbs_interface/MBsysPy/_mbsysc_loader/mbs_functions_c.py
View file @
db261975
...
...
@@ -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
]
...
...
MBsysC/mbs_interface/MBsysPy/examples/5_sensors/userfctR/user_dirdyn.py
View file @
db261975
...
...
@@ -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,
...
...
MBsysC/mbs_interface/MBsysPy/mbsyspy/mbs_dirdyn.py
View file @
db261975
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment