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

[MBsysPy][Bug] Functions set_qu/qv/qdriven/... can use MbsData::qu[1:] and similar list as input.

parent 620700c2
...@@ -2110,7 +2110,9 @@ class MbsData(object): ...@@ -2110,7 +2110,9 @@ class MbsData(object):
""" """
if isinstance(indices, (list, np.ndarray)): if isinstance(indices, (list, np.ndarray)):
for index in indices: # local list to avoid self-modification (ie. set all driven joints as independent)
local_indices = list(indices)
for index in local_indices:
libutilities.mbs_set_qu(self.mbs_data_ptr, index) libutilities.mbs_set_qu(self.mbs_data_ptr, index)
else: else:
libutilities.mbs_set_qu(self.mbs_data_ptr, indices) libutilities.mbs_set_qu(self.mbs_data_ptr, indices)
...@@ -2125,7 +2127,9 @@ class MbsData(object): ...@@ -2125,7 +2127,9 @@ class MbsData(object):
The ids of the joints to set as dependent. The ids of the joints to set as dependent.
""" """
if isinstance(indices, (list, np.ndarray)): if isinstance(indices, (list, np.ndarray)):
for index in indices: # local list to avoid self-modification (ie. set all independent to dependent)
local_indices = list(indices)
for index in local_indices:
libutilities.mbs_set_qv(self.mbs_data_ptr, index) libutilities.mbs_set_qv(self.mbs_data_ptr, index)
else: else:
libutilities.mbs_set_qv(self.mbs_data_ptr, indices) libutilities.mbs_set_qv(self.mbs_data_ptr, indices)
...@@ -2140,7 +2144,9 @@ class MbsData(object): ...@@ -2140,7 +2144,9 @@ class MbsData(object):
The ids of the joints to set as driven. The ids of the joints to set as driven.
""" """
if isinstance(indices, (list, np.ndarray)): if isinstance(indices, (list, np.ndarray)):
for index in indices: # local list to avoid self-modification (ie. set all independent to driven)
local_indices = list(indices)
for index in local_indices:
libutilities.mbs_set_qdriven(self.mbs_data_ptr, index) libutilities.mbs_set_qdriven(self.mbs_data_ptr, index)
else: else:
libutilities.mbs_set_qdriven(self.mbs_data_ptr, indices) libutilities.mbs_set_qdriven(self.mbs_data_ptr, indices)
...@@ -2159,6 +2165,7 @@ class MbsData(object): ...@@ -2159,6 +2165,7 @@ class MbsData(object):
The ids of the joints to set as actuated. The ids of the joints to set as actuated.
""" """
if isinstance(indices, (list, np.ndarray)): if isinstance(indices, (list, np.ndarray)):
# No need of local list
for index in indices: for index in indices:
libutilities.mbs_set_qa(self.mbs_data_ptr, index) libutilities.mbs_set_qa(self.mbs_data_ptr, index)
else: else:
...@@ -2174,7 +2181,9 @@ class MbsData(object): ...@@ -2174,7 +2181,9 @@ class MbsData(object):
The ids of the joints to be removed from the actuated list. The ids of the joints to be removed from the actuated list.
""" """
if isinstance(indices, (list, np.ndarray)): if isinstance(indices, (list, np.ndarray)):
for index in indices: # local list to avoid self-modification (ie. unset all qa)
local_indices = list(indices)
for index in local_indices:
libutilities.mbs_unset_qa(self.mbs_data_ptr, index) libutilities.mbs_unset_qa(self.mbs_data_ptr, index)
else: else:
libutilities.mbs_unset_qa(self.mbs_data_ptr, indices) libutilities.mbs_unset_qa(self.mbs_data_ptr, indices)
......
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