Esempio n. 1
0
    def __init__(self, ic, node=None):
        """
        Init method.

        @param ic: The ICE controller.
        @param node: The ROS node controller.
        """

        self.camera = CameraClient(ic, "drone.Camera", True)
        self.cmdvel = CMDVel(ic, "drone.CMDVel")
        self.extra = Extra(ic, "drone.Extra")
        self.navdata = NavDataClient(ic, "drone.Navdata", True)
        self.pose = Pose3DClient(ic, "drone.Pose3D", True)
Esempio n. 2
0
    def __init__(self, ic, node=None):
        """
        Init method.

        @param ic: The ICE controller.
        @param node: The ROS node controller.
        """

        self.camera = CameraClient(ic, "drone.Camera", True)
        self.cmdvel = CMDVel(ic, "drone.CMDVel")
        self.extra = Extra(ic, "drone.Extra")
        self.navdata = NavDataClient(ic, "drone.Navdata", True)
        self.pose = Pose3DClient(ic, "drone.Pose3D", True)
Esempio n. 3
0
#

import sys
from PyQt5.QtWidgets import QApplication
from gui.GUI import MainWindow
from gui.threadGUI import ThreadGUI
from parallelIce.cameraClient import CameraClient
from parallelIce.motors import Motors
from parallelIce.pose3dClient import Pose3DClient
from parallelIce.laserClient import LaserClient
import easyiceconfig as EasyIce
from MyAlgorithm import MyAlgorithm

if __name__ == "__main__":
    ic = EasyIce.initialize(sys.argv)
    cameraL = CameraClient(ic, "ObstacleAvoidance.CameraLeft", True)
    cameraR = CameraClient(ic, "ObstacleAvoidance.CameraRight", True)
    motors = Motors(ic, "ObstacleAvoidance.Motors")
    pose3d = Pose3DClient(ic, "ObstacleAvoidance.Pose3D", True)
    laser = LaserClient(ic, "ObstacleAvoidance.Laser", True)
    algorithm = MyAlgorithm(cameraL, cameraR, pose3d, laser, motors)

    app = QApplication(sys.argv)
    myGUI = MainWindow()
    myGUI.setCameraL(cameraL)
    myGUI.setCameraR(cameraR)
    myGUI.setMotors(motors)
    myGUI.setPose3D(pose3d)
    myGUI.setLaser(laser)
    myGUI.setAlgorithm(algorithm)
    myGUI.show()
from parallelIce.cameraClient import CameraClient
from sensors.cameraFilter import CameraFilter
from parallelIce.navDataClient import NavDataClient
from parallelIce.cmdvel import CMDVel
from parallelIce.extra import Extra
from parallelIce.pose3dClient import Pose3DClient
from gui.GUI import MainWindow
from PyQt5.QtWidgets import QApplication

import signal

signal.signal(signal.SIGINT, signal.SIG_DFL)

if __name__ == '__main__':
    ic = EasyIce.initialize(sys.argv)
    cameraCli = CameraClient(ic, "Introrob.Camera", True)
    camera = CameraFilter(cameraCli)
    navdata = NavDataClient(ic, "Introrob.Navdata", True)
    pose = Pose3DClient(ic, "Introrob.Pose3D", True)
    cmdvel = CMDVel(ic, "Introrob.CMDVel")
    extra = Extra(ic, "Introrob.Extra")

    algorithm = MyAlgorithm(camera, navdata, pose, cmdvel, extra)

    app = QApplication(sys.argv)
    frame = MainWindow()
    frame.setCamera(camera)
    frame.setNavData(navdata)
    frame.setPose3D(pose)
    frame.setCMDVel(cmdvel)
    frame.setExtra(extra)
Esempio n. 5
0
from uav_viewer_py.gui.threadGUI import ThreadGUI
from parallelIce.cameraClient import CameraClient
from parallelIce.navDataClient import NavDataClient
from parallelIce.cmdvel import CMDVel
from parallelIce.extra import Extra
from parallelIce.pose3dClient import Pose3DClient
from uav_viewer_py.gui.GUI import MainWindow
from PyQt5.QtWidgets import QApplication

import signal

signal.signal(signal.SIGINT, signal.SIG_DFL)

if __name__ == '__main__':
    ic = EasyIce.initialize(sys.argv)
    camera = CameraClient(ic, "UavViewer.Camera", True)
    navdata = NavDataClient(ic, "UavViewer.Navdata", True)
    pose = Pose3DClient(ic, "UavViewer.Pose3D", True)
    cmdvel = CMDVel(ic, "UavViewer.CMDVel")
    extra = Extra(ic, "UavViewer.Extra")

    app = QApplication(sys.argv)
    frame = MainWindow()
    frame.setCamera(camera)
    frame.setNavData(navdata)
    frame.setPose3D(pose)
    frame.setCMDVel(cmdvel)
    frame.setExtra(extra)
    frame.show()

    t2 = ThreadGUI(frame)
Esempio n. 6
0
class Drone():

    """
    Drone class.
    """

    def __init__(self, ic, node=None):
        """
        Init method.

        @param ic: The ICE controller.
        @param node: The ROS node controller.
        """

        self.camera = CameraClient(ic, "drone.Camera", True)
        self.cmdvel = CMDVel(ic, "drone.CMDVel")
        self.extra = Extra(ic, "drone.Extra")
        self.navdata = NavDataClient(ic, "drone.Navdata", True)
        self.pose = Pose3DClient(ic, "drone.Pose3D", True)

    def close(self):
        """
        Close communications with servers.
        """

        self.camera.stop()
        self.navdata.stop()
        self.pose.stop()

    def color_object_centroid(self):
        """
        Return the x,y centroid of a colorful object in the camera.

        @return: The (x,y) centroid of the object or None if not found.
        """

        # FIXME: set color (manual)
        color = BLUE_RANGE

        # get image from camera
        frame = self.camera.getImage()

        # resize the frame
        frame = imutils.resize(frame, width=600)

        # convert to the HSV color space
        hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

        # construct a mask for the color specified
        # then perform a series of dilations and erosions
        # to remove any small blobs left in the mask
        mask = cv2.inRange(hsv, color[0], color[1])
        mask = cv2.erode(mask, None, iterations=2)
        mask = cv2.dilate(mask, None, iterations=2)

        # find contours in the mask and
        # initialize the current center
        cnts = cv2.findContours(
            mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[-2]
        center = None

        # only proceed if at least one contour was found
        if len(cnts) > 0:
            # find the largest contour in the mask, then use
            # it to compute the minimum enclosing circle and
            # centroid
            c = max(cnts, key=cv2.contourArea)
            ((x, y), radius) = cv2.minEnclosingCircle(c)
            M = cv2.moments(c)
            center = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))

            # only proceed if the radius meets a minimum size
            if radius > 10:
                # draw the circle border
                cv2.circle(
                    frame, (int(x), int(y)), int(radius), (0, 255, 255), 2)

                # and the centroid
                cv2.circle(frame, center, 5, (0, 0, 255), -1)

        # show the frame to our screen
        cv2.imshow("Frame", frame)
        key = cv2.waitKey(1) & 0xFF

        return center

    def go_up_down(self, direction):
        """
        Set the vertical movement of the drone.

        @param direction: direction of the move. Options: forward (default), back.
        """

        # set default velocity (m/s)
        vz = 1.0

        if direction == "down":
            vz = -vz

        # assign velocity
        self.cmdvel.setVZ(vz)

        # publish movement
        self.cmdvel.sendVelocities()

    def move(self, direction):
        """
        Set the horizontal movement of the drone.

        @param direction: direction of the move. Options: forward (default), back.
        """

        # set default velocities (m/s)
        vx = 5.0
        vy = 0.0

        # set different direction
        if direction == "back":
            vx = -vx
        elif direction == "left":
            vy = float(vx)
            vx = 0.0
        elif direction == "right":
            vy = float(-vx)
            vx = 0.0

        # assign velocities
        self.cmdvel.setVX(vx)
        self.cmdvel.setVY(vy)

        # publish movement
        self.cmdvel.sendVelocities()

    def turn(self, direction):
        """
        Set the angular velocity.

        @param direction: direction of the move. Options: left (default), right.
        """

        # set default velocity (m/s)
        yaw = 5.0 * math.pi

        if direction == "right":
            yaw = -yaw

        # assign velocity
        self.cmdvel.setYaw(yaw)

        # publish movement
        self.cmdvel.sendVelocities()

    def stop(self):
        """
        Set all velocities to zero.
        """

        self.cmdvel.setVX(0)
        self.cmdvel.setVY(0)
        self.cmdvel.setVZ(0)
        self.cmdvel.setYaw(0)

        self.cmdvel.sendVelocities()

    def take_off(self):
        """
        Send the take off command.
        """

        self.extra.takeoff()
        time.sleep(1)

    def land(self):
        """
        Send the land command.
        """

        self.extra.land()
        time.sleep(1)
Esempio n. 7
0
import sys
import easyiceconfig as EasyIce
from gui.threadGUI import ThreadGUI
from parallelIce.cameraClient import CameraClient
from sensors.cameraFilter import CameraFilter
from gui.GUI import MainWindow
from PyQt5.QtWidgets import QApplication


import signal

signal.signal(signal.SIGINT, signal.SIG_DFL)

if __name__ == '__main__':
    ic = EasyIce.initialize(sys.argv)
    prop = ic.getProperties()
    cameraCli = CameraClient(ic, "ColorTuner.Camera", True)
    camera = CameraFilter(cameraCli)
    
    app = QApplication(sys.argv)
    frame = MainWindow()
    frame.setCamera(camera)
    frame.show()

    t2 = ThreadGUI(frame)  
    t2.daemon=True
    t2.start()
    
    sys.exit(app.exec_()) 
Esempio n. 8
0
class Drone():
    """
    Drone class.
    """
    def __init__(self, ic, node=None):
        """
        Init method.

        @param ic: The ICE controller.
        @param node: The ROS node controller.
        """

        self.camera = CameraClient(ic, "drone.Camera", True)
        self.cmdvel = CMDVel(ic, "drone.CMDVel")
        self.extra = Extra(ic, "drone.Extra")
        self.navdata = NavDataClient(ic, "drone.Navdata", True)
        self.pose = Pose3DClient(ic, "drone.Pose3D", True)

    def close(self):
        """
        Close communications with servers.
        """

        self.camera.stop()
        self.navdata.stop()
        self.pose.stop()

    def color_object_centroid(self):
        """
        Return the x,y centroid of a colorful object in the camera.

        @return: The (x,y) centroid of the object or None if not found.
        """

        # FIXME: set color (manual)
        color = BLUE_RANGE

        # get image from camera
        frame = self.camera.getImage()

        # resize the frame
        frame = imutils.resize(frame, width=600)

        # convert to the HSV color space
        hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

        # construct a mask for the color specified
        # then perform a series of dilations and erosions
        # to remove any small blobs left in the mask
        mask = cv2.inRange(hsv, color[0], color[1])
        mask = cv2.erode(mask, None, iterations=2)
        mask = cv2.dilate(mask, None, iterations=2)

        # find contours in the mask and
        # initialize the current center
        cnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL,
                                cv2.CHAIN_APPROX_SIMPLE)[-2]
        center = None

        # only proceed if at least one contour was found
        if len(cnts) > 0:
            # find the largest contour in the mask, then use
            # it to compute the minimum enclosing circle and
            # centroid
            c = max(cnts, key=cv2.contourArea)
            ((x, y), radius) = cv2.minEnclosingCircle(c)
            M = cv2.moments(c)
            center = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))

            # only proceed if the radius meets a minimum size
            if radius > 10:
                # draw the circle border
                cv2.circle(frame, (int(x), int(y)), int(radius), (0, 255, 255),
                           2)

                # and the centroid
                cv2.circle(frame, center, 5, (0, 0, 255), -1)

        # show the frame to our screen
        cv2.imshow("Frame", frame)
        key = cv2.waitKey(1) & 0xFF

        return center

    def go_up_down(self, direction):
        """
        Set the vertical movement of the drone.

        @param direction: direction of the move. Options: forward (default), back.
        """

        # set default velocity (m/s)
        vz = 1.0

        if direction == "down":
            vz = -vz

        # assign velocity
        self.cmdvel.setVZ(vz)

        # publish movement
        self.cmdvel.sendVelocities()

    def move(self, direction):
        """
        Set the horizontal movement of the drone.

        @param direction: direction of the move. Options: forward (default), back.
        """

        # set default velocities (m/s)
        vx = 5.0
        vy = 0.0

        # set different direction
        if direction == "back":
            vx = -vx
        elif direction == "left":
            vy = float(vx)
            vx = 0.0
        elif direction == "right":
            vy = float(-vx)
            vx = 0.0

        # assign velocities
        self.cmdvel.setVX(vx)
        self.cmdvel.setVY(vy)

        # publish movement
        self.cmdvel.sendVelocities()

    def turn(self, direction):
        """
        Set the angular velocity.

        @param direction: direction of the move. Options: left (default), right.
        """

        # set default velocity (m/s)
        yaw = 5.0 * math.pi

        if direction == "right":
            yaw = -yaw

        # assign velocity
        self.cmdvel.setYaw(yaw)

        # publish movement
        self.cmdvel.sendVelocities()

    def stop(self):
        """
        Set all velocities to zero.
        """

        self.cmdvel.setVX(0)
        self.cmdvel.setVY(0)
        self.cmdvel.setVZ(0)
        self.cmdvel.setYaw(0)

        self.cmdvel.sendVelocities()

    def take_off(self):
        """
        Send the take off command.
        """

        self.extra.takeoff()
        time.sleep(1)

    def land(self):
        """
        Send the land command.
        """

        self.extra.land()
        time.sleep(1)
Esempio n. 9
0
from PyQt5.QtWidgets import QApplication
import easyiceconfig as EasyIce
import signal

# de componente2
from control.control import Control
from control.threadcontrol import ThreadControl
from control.cameraFilter import CameraFilter

signal.signal(signal.SIGINT, signal.SIG_DFL)

if __name__ == '__main__':

    ic = EasyIce.initialize(sys.argv)
    prop = ic.getProperties()
    cameraCli = CameraClient(ic, "basic_component.Camera", True)
    camera = CameraFilter(cameraCli)
    #control = Control(camera)

    app = QApplication(sys.argv)
    frame = Gui()
    frame.setControl(camera)
    frame.show()

    t1 = ThreadControl(camera)
    t1.start()
    t2 = ThreadGUI(frame)
    t2.start()

    sys.exit(app.exec_())
Esempio n. 10
0
import sys
from PyQt5.QtWidgets import QApplication
from gui.GUI import MainWindow
from gui.threadGUI import ThreadGUI
from parallelIce.motors import Motors
from parallelIce.pose3dClient import Pose3DClient
from parallelIce.cameraClient import CameraClient
from parallelIce.laserClient import LaserClient
import easyiceconfig as EasyIce
from MyAlgorithm import MyAlgorithm

if __name__ == "__main__":
    ic = EasyIce.initialize(sys.argv)
    motors = Motors(ic, "Stop.Motors")
    pose3d = Pose3DClient(ic, "Stop.Pose3D", True)
    cameraC = CameraClient(ic, "Stop.CameraC", True)
    cameraL = CameraClient(ic, "Stop.CameraL", True)
    cameraR = CameraClient(ic, "Stop.CameraR", True)

    algorithm = MyAlgorithm(pose3d, cameraC, cameraL, cameraR, motors)

    app = QApplication(sys.argv)
    myGUI = MainWindow()
    myGUI.setMotors(motors)
    myGUI.setCameraC(cameraC)
    myGUI.setCameraL(cameraL)
    myGUI.setCameraR(cameraR)
    myGUI.setPose3D(pose3d)
    myGUI.setAlgorithm(algorithm)
    myGUI.show()
Esempio n. 11
0
#       Aitor Martinez Fernandez <*****@*****.**>
#       Francisco Miguel Rivas Montero <*****@*****.**>
#

import sys
from gui.GUI import MainWindow
from gui.threadGUI import ThreadGUI
from parallelIce.cameraClient import CameraClient
from parallelIce.motors import Motors
import easyiceconfig as EasyIce
from MyAlgorithm import MyAlgorithm
from PyQt5.QtWidgets import QApplication

if __name__ == "__main__":
    ic = EasyIce.initialize(sys.argv)
    cameraL = CameraClient(ic, "FollowLine.CameraLeft", True)
    cameraR = CameraClient(ic, "FollowLine.CameraRight", True)
    motors = Motors(ic, "FollowLine.Motors")
    algorithm = MyAlgorithm(cameraL, cameraR, motors)

    app = QApplication(sys.argv)
    myGUI = MainWindow()
    myGUI.setCameraL(cameraL)
    myGUI.setCameraR(cameraR)
    myGUI.setMotors(motors)
    myGUI.setAlgorithm(algorithm)
    myGUI.show()

    t2 = ThreadGUI(myGUI)
    t2.daemon = True
    t2.start()