class Solver: robot = None sot = None def __init__(self, robot): self.robot = robot self.sot = SOT('solver') self.sot.signal('damping').value = 1e-6 self.sot.setNumberDofs(self.robot.dimension) if robot.simu: plug(self.sot.signal('control'), robot.simu.signal('control')) plug(self.robot.simu.state, self.robot.dynamic.position)
class Solver: def __init__(self, robot): self.robot = robot # Make sure control does not exceed joint limits. self.jointLimitator = JointLimitator('joint_limitator') plug(self.robot.dynamic.position, self.jointLimitator.joint) plug(self.robot.dynamic.upperJl, self.jointLimitator.upperJl) plug(self.robot.dynamic.lowerJl, self.jointLimitator.lowerJl) # Create the solver. self.sot = SOT('solver') self.sot.signal('damping').value = 1e-6 self.sot.setSize(self.robot.dimension) # Plug the solver control into the filter. plug(self.sot.control, self.jointLimitator.controlIN) # Important: always use 'jointLimitator.control' # and NOT 'sot.control'! if robot.device: plug(self.jointLimitator.control, robot.device.control) def push (self, task): """ Proxy method to push a task in the sot """ self.sot.push (task.name) def remove (self, task): """ Proxy method to remove a task from the sot """ self.sot.remove (task.name) def __str__ (self): return self.sot.display ()