Commit 1aa92862 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Guilhem Saurel
Browse files

[Python] Make toFlags deprecated.

parent 0c0e089a
......@@ -7,20 +7,9 @@ from dynamic_graph.sot.core.task import Task
def toFlags(arr):
"""
Convert an array of boolean to a /flag/ format, type 001010110,
in little indian
(reverse order, first bool of the list will be the [01] of extrem right).
"""
lres = [0] * (max(arr) + 1)
for i in arr:
lres[i] = 1
lres.reverse()
res = ''
for i in lres:
res += str(i)
return Flags(res)
from warnings import warn
warn("This function is deprecated. Please, use Flags directly.")
return Flags(arr)
class MetaTask6d(object):
name = ''
......
......@@ -2,7 +2,7 @@ from dynamic_graph import plug
from dynamic_graph.sot.core.feature_generic import FeatureGeneric
from dynamic_graph.sot.core.gain_adaptive import GainAdaptive
from dynamic_graph.sot.core.matrix_util import matrixToTuple, vectorToTuple
from dynamic_graph.sot.core.meta_task_6d import toFlags
from dynamic_graph.sot.core.meta_task_6d import toFlags # kept for backward compatibility
from dynamic_graph.sot.core.meta_tasks import setGain
from dynamic_graph.sot.core.sot import Task
from numpy import identity, matrix, zeros
......@@ -67,9 +67,11 @@ class MetaTaskPosture(object):
MetaTaskPosture.nbDof = len(self.feature.errorIN.value)
qdes = zeros((MetaTaskPosture.nbDof, 1))
act = [ False, ] * MetaTaskPosture.nbDof
for limbName, jointValues in kwargs.items():
limbRange = self.postureRange[limbName]
act += limbRange
for i in limbRange:
act[i] = True
if jointValues != []:
if isinstance(jointValues, matrix):
qdes[limbRange, 0] = vectorToTuple(jointValues)
......@@ -77,7 +79,7 @@ class MetaTaskPosture(object):
qdes[limbRange, 0] = jointValues
self.ref = vectorToTuple(qdes)
if len(act) > 0:
self.feature.selec.value = toFlags(act)
self.feature.selec.value = Flags(act)
setGain(self.gain, gain)
......
......@@ -5,7 +5,7 @@ from dynamic_graph.sot.core import Flags
from dynamic_graph.sot.core.feature_generic import FeatureGeneric
from dynamic_graph.sot.core.gain_adaptive import GainAdaptive
from dynamic_graph.sot.core.matrix_util import matrixToTuple, rpy2tr
from dynamic_graph.sot.core.meta_task_6d import toFlags
from dynamic_graph.sot.core.meta_task_6d import toFlags # kept for backward compatibility
class MetaTaskCom(object):
......@@ -79,10 +79,9 @@ def goto6d(task, position, gain=None, resetJacobian=True):
def gotoNd(task, position, selec=None, gain=None, resetJacobian=True):
M = generic6dReference(position)
if selec is not None:
if isinstance(selec, str):
task.feature.selec.value = Flags(selec)
else:
task.feature.selec.value = toFlags(selec)
if not isinstance(selec, Flags):
selec = Flags(selec)
task.feature.selec.value = selec
task.featureDes.position.value = array(M)
setGain(task.gain, gain)
if 'resetJacobianDerivative' in task.task.__class__.__dict__.keys() and resetJacobian:
......
......@@ -2,7 +2,7 @@ from dynamic_graph import plug
from dynamic_graph.sot.core import Flags
from dynamic_graph.sot.core.feature_point6d_relative import FeaturePoint6dRelative
from dynamic_graph.sot.core.matrix_util import matrixToTuple
from dynamic_graph.sot.core.meta_task_6d import MetaTask6d, toFlags
from dynamic_graph.sot.core.meta_task_6d import MetaTask6d, toFlags # kept for backward compatibility
from dynamic_graph.sot.core.meta_tasks import generic6dReference, setGain
from dynamic_graph.sot.core.op_point_modifier import OpPointModifier
......@@ -94,10 +94,9 @@ def gotoNdRel(task, position, positionRef, selec=None, gain=None, resetJacobian=
M = generic6dReference(position)
MRef = generic6dReference(positionRef)
if selec is not None:
if isinstance(selec, str):
task.feature.selec.value = selec
else:
task.feature.selec.value = toFlags(selec)
if not isinstance(selec, Flags):
selec = Flags(selec)
task.feature.selec.value = selec
task.featureDes.position.value = matrixToTuple(M)
task.featureDes.positionRef.value = matrixToTuple(MRef)
setGain(task.gain, gain)
......
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