meta_task_visual_point.py
Go to the documentation of this file.
1 from dynamic_graph import plug
2 from dynamic_graph.sot.core.feature_visual_point import FeatureVisualPoint
3 from dynamic_graph.sot.core.gain_adaptive import GainAdaptive
4 from dynamic_graph.sot.core.meta_tasks import setGain
5 from dynamic_graph.sot.core.op_point_modifier import OpPointModifier
6 from dynamic_graph.sot.core.task import Task
7 from dynamic_graph.sot.core.visual_point_projecter import VisualPointProjecter
8 
9 
10 class MetaTaskVisualPoint(object):
11  name = ""
12  opPoint = ""
13  dyn = 0
14  task = 0
15  feature = 0
16  featureDes = 0
17  proj = 0
18 
19  def opPointExist(self, opPoint):
20  sigsP = filter(
21  lambda x: x.getName().split(":")[-1] == opPoint, self.dyn.signals()
22  )
23  sigsJ = filter(
24  lambda x: x.getName().split(":")[-1] == "J" + opPoint, self.dyn.signals()
25  )
26  return len(sigsP) == 1 & len(sigsJ) == 1
27 
28  def defineDynEntities(self, dyn):
29  self.dyn = dyn
30 
31  def createOpPoint(self, opPoint, opPointRef="right-wrist"):
32  self.opPoint = opPoint
33  if self.opPointExist(opPoint):
34  return
35  self.dyn.createOpPoint(opPoint, opPointRef)
36 
37  def createOpPointModif(self):
38  self.opPointModif = OpPointModifier("opmodif" + self.name)
39  plug(self.dyn.signal(self.opPoint), self.opPointModif.signal("positionIN"))
40  plug(
41  self.dyn.signal("J" + self.opPoint), self.opPointModif.signal("jacobianIN")
42  )
43  self.opPointModif.activ = False
44 
45  def createFeatures(self):
46  self.feature = FeatureVisualPoint("feature" + self.name)
47  self.featureDes = FeatureVisualPoint("feature" + self.name + "_ref")
48  self.feature.selec.value = "11"
49 
50  def createTask(self):
51  self.task = Task("task" + self.name)
52 
53  def createGain(self):
54  self.gain = GainAdaptive("gain" + self.name)
55  self.gain.set(0.1, 0.1, 125e3)
56 
57  def createProj(self):
58  self.proj = VisualPointProjecter("proj" + self.name)
59 
60  def plugEverything(self):
61  self.feature.setReference(self.featureDes.name)
62  plug(self.dyn.signal(self.opPoint), self.proj.signal("transfo"))
63  plug(self.proj.signal("point2D"), self.feature.signal("xy"))
64  plug(self.proj.signal("depth"), self.feature.signal("Z"))
65  plug(self.dyn.signal("J" + self.opPoint), self.feature.signal("Jq"))
66  self.task.add(self.feature.name)
67  plug(self.task.error, self.gain.error)
68  plug(self.gain.gain, self.task.controlGain)
69 
70  def __init__(self, name, dyn, opPoint, opPointRef="right-wrist"):
71  self.name = name
72  self.defineDynEntities(dyn)
73  self.createOpPoint(opPoint, opPointRef)
74  self.createOpPointModif()
75  self.createFeatures()
76  self.createTask()
77  self.createGain()
78  self.createProj()
79  self.plugEverything()
80 
81  @property
82  def ref(self):
83  return self.featureDes.xy.value
84 
85  @ref.setter
86  def ref(self, m):
87  self.featureDes.xy.value = m
88 
89  @property
90  def target(self):
91  return self.proj.point3D
92 
93  @target.setter
94  def target(self, m):
95  self.proj.point3D.value = m
96 
97  @property
98  def opmodif(self):
99  if not self.opPointModif.activ:
100  return False
101  else:
102  return self.opPointModif.getTransformation()
103 
104  @opmodif.setter
105  def opmodif(self, m):
106  if isinstance(m, bool) and not m:
107  plug(self.dyn.signal(self.opPoint), self.proj.signal("transfo"))
108  plug(self.dyn.signal("J" + self.opPoint), self.feature.signal("Jq"))
109  self.opPointModif.activ = False
110  else:
111  if not self.opPointModif.activ:
112  plug(self.opPointModif.signal("position"), self.proj.signal("transfo"))
113  plug(self.opPointModif.signal("jacobian"), self.feature.signal("Jq"))
114  self.opPointModif.setTransformation(m)
115  self.opPointModif.activ = True
116 
117  def goto3D(self, point3D, gain=None, ref2D=None, selec=None):
118  self.target = point3D
119  if ref2D is not None:
120  self.ref = ref2D
121  if selec is not None:
122  self.feature.selec.value = selec
123  setGain(self.gain, gain)
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.createGain
def createGain(self)
Definition: meta_task_visual_point.py:53
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.opmodif
def opmodif(self)
Definition: meta_task_visual_point.py:98
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.createProj
def createProj(self)
Definition: meta_task_visual_point.py:57
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.createOpPoint
def createOpPoint(self, opPoint, opPointRef="right-wrist")
Definition: meta_task_visual_point.py:31
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.featureDes
int featureDes
Definition: meta_task_visual_point.py:16
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.defineDynEntities
def defineDynEntities(self, dyn)
Definition: meta_task_visual_point.py:28
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.gain
gain
Definition: meta_task_visual_point.py:54
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint
Definition: meta_task_visual_point.py:10
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.__init__
def __init__(self, name, dyn, opPoint, opPointRef="right-wrist")
Definition: meta_task_visual_point.py:70
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.target
target
Definition: meta_task_visual_point.py:118
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.name
string name
Definition: meta_task_visual_point.py:11
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.opPoint
string opPoint
Definition: meta_task_visual_point.py:12
set
void set(bool ownStorage, Vec3f *points_, unsigned int num_points_)
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.createTask
def createTask(self)
Definition: meta_task_visual_point.py:50
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.dyn
int dyn
Definition: meta_task_visual_point.py:13
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.createOpPointModif
def createOpPointModif(self)
Definition: meta_task_visual_point.py:37
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.plugEverything
def plugEverything(self)
Definition: meta_task_visual_point.py:60
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.task
int task
Definition: meta_task_visual_point.py:14
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.opPointModif
opPointModif
Definition: meta_task_visual_point.py:38
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.ref
ref
Definition: meta_task_visual_point.py:120
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.proj
int proj
Definition: meta_task_visual_point.py:17
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.feature
int feature
Definition: meta_task_visual_point.py:15
dynamic_graph.sot.core.meta_tasks.setGain
def setGain(gain, val)
Definition: meta_tasks.py:39
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.goto3D
def goto3D(self, point3D, gain=None, ref2D=None, selec=None)
Definition: meta_task_visual_point.py:117
dynamic_graph.sot.core.meta_tasks
Definition: meta_tasks.py:1
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.opPointExist
def opPointExist(self, opPoint)
Definition: meta_task_visual_point.py:19
dynamic_graph.sot.core.meta_task_visual_point.MetaTaskVisualPoint.createFeatures
def createFeatures(self)
Definition: meta_task_visual_point.py:45


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31