How to use the pypot.robot.sensor.Sensor function in pypot

To help you get started, we’ve selected a few pypot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github poppy-project / pypot / pypot / robot / sensor.py View on Github external
from numpy import array, zeros


class Sensor(object):
    """ Purely abstract class representing any sensor object. """
    registers = []

    def __init__(self, name):
        self._name = name

    @property
    def name(self):
        return self._name


class ObjectTracker(Sensor):
    registers = Sensor.registers + ['position', 'orientation']

    def __init__(self, name):
        Sensor.__init__(self, name)

        self._pos = zeros(3)
        self._ori = zeros(3)

    @property
    def position(self):
        return self._pos

    @position.setter
    def position(self, new_pos):
        self._pos = array(new_pos)
github poppy-project / pypot / pypot / robot / sensor.py View on Github external
class Sensor(object):
    """ Purely abstract class representing any sensor object. """
    registers = []

    def __init__(self, name):
        self._name = name

    @property
    def name(self):
        return self._name


class ObjectTracker(Sensor):
    registers = Sensor.registers + ['position', 'orientation']

    def __init__(self, name):
        Sensor.__init__(self, name)

        self._pos = zeros(3)
        self._ori = zeros(3)

    @property
    def position(self):
        return self._pos

    @position.setter
    def position(self, new_pos):
        self._pos = array(new_pos)

    @property
github poppy-project / pypot / pypot / vrep / controller.py View on Github external
class VrepObjectTracker(SensorsController):

    """ Tracks the 3D position and orientation of a V-REP object. """

    def setup(self):
        """ Forces a first update to trigger V-REP streaming. """
        self.update()

    def update(self):
        """ Updates the position and orientation of the tracked objects. """
        for s in self.sensors:
            s.position = self.io.get_object_position(object_name=s.name)
            s.orientation = self.io.get_object_orientation(object_name=s.name)


class VrepCollisionDetector(Sensor):

    def __init__(self, name):
        Sensor.__init__(self, name)

        self._colliding = False

    @property
    def colliding(self):
        return self._colliding

    @colliding.setter
    def colliding(self, new_state):
        self._colliding = new_state


class VrepCollisionTracker(SensorsController):
github poppy-project / pypot / pypot / sensor / imagefeature / blob.py View on Github external
import cv2

from numpy import ones, uint8, concatenate

from ...robot.controller import SensorsController
from ...robot.sensor import Sensor


class Blob(Sensor):
    registers = Sensor.registers + ['center', 'radius']

    def __init__(self, x, y, radius):
        self.center = x, y
        self.radius = radius

    def draw(self, img, color=(255, 0, 0), thickness=3):
        cv2.circle(img, self.center, self.radius, color, thickness)

    @property
    def json(self):
        return {"center": self.center, "radius": self.radius}


class BlobDetector(SensorsController):
    channels = {
        'R': 2, 'G': 1, 'B': 0,