[Jderobot-admin] jderobot-r1090 - in trunk/src/testing/components: . followBall followBall/.qi followBall/interfaces followBall/interfaces/cpp followBall/interfaces/slice followBall/interfaces/slice/jderobot

bmenendez en jderobot.org bmenendez en jderobot.org
Jue Nov 7 19:28:28 CET 2013


Author: bmenendez
Date: 2013-11-07 19:28:27 +0100 (Thu, 07 Nov 2013)
New Revision: 1090

Added:
   trunk/src/testing/components/followBall/
   trunk/src/testing/components/followBall/.qi/
   trunk/src/testing/components/followBall/.qi/qibuild.xml
   trunk/src/testing/components/followBall/CMakeLists.txt
   trunk/src/testing/components/followBall/GenerateJderobot.cmake
   trunk/src/testing/components/followBall/README.txt
   trunk/src/testing/components/followBall/cameraview.glade
   trunk/src/testing/components/followBall/control.cpp
   trunk/src/testing/components/followBall/control.h
   trunk/src/testing/components/followBall/filter.txt
   trunk/src/testing/components/followBall/followball.cfg
   trunk/src/testing/components/followBall/handler.cpp
   trunk/src/testing/components/followBall/handler.h
   trunk/src/testing/components/followBall/interfaces/
   trunk/src/testing/components/followBall/interfaces/cpp/
   trunk/src/testing/components/followBall/interfaces/cpp/jderobot/
   trunk/src/testing/components/followBall/interfaces/slice/
   trunk/src/testing/components/followBall/interfaces/slice/jderobot/
   trunk/src/testing/components/followBall/interfaces/slice/jderobot/camera.ice
   trunk/src/testing/components/followBall/interfaces/slice/jderobot/common.ice
   trunk/src/testing/components/followBall/interfaces/slice/jderobot/containers.ice
   trunk/src/testing/components/followBall/interfaces/slice/jderobot/datetime.ice
   trunk/src/testing/components/followBall/interfaces/slice/jderobot/exceptions.ice
   trunk/src/testing/components/followBall/interfaces/slice/jderobot/image.ice
   trunk/src/testing/components/followBall/interfaces/slice/jderobot/pose3dmotors.ice
   trunk/src/testing/components/followBall/main.cpp
   trunk/src/testing/components/followBall/qibuild.cmake
   trunk/src/testing/components/followBall/qiproject.xml
   trunk/src/testing/components/followBall/sensors.cpp
   trunk/src/testing/components/followBall/sensors.h
   trunk/src/testing/components/followBall/viewer.cpp
   trunk/src/testing/components/followBall/viewer.h
Log:
Uploaded the followBall, testing first.


Added: trunk/src/testing/components/followBall/.qi/qibuild.xml
===================================================================
--- trunk/src/testing/components/followBall/.qi/qibuild.xml	                        (rev 0)
+++ trunk/src/testing/components/followBall/.qi/qibuild.xml	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,4 @@
+<qibuild version="1">
+  <defaults />
+  <build />
+</qibuild>
\ No newline at end of file

Added: trunk/src/testing/components/followBall/CMakeLists.txt
===================================================================
--- trunk/src/testing/components/followBall/CMakeLists.txt	                        (rev 0)
+++ trunk/src/testing/components/followBall/CMakeLists.txt	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,70 @@
+SET (COMPILEFORNAO FALSE)
+
+if (COMPILEFORNAO)
+    cmake_minimum_required(VERSION 2.8)
+    
+    add_definitions( -DCOMPILEFORNAO )
+    include(qibuild.cmake)
+
+    # Generar los ficheros de JdeRobot. 
+    #Los ficheros se crean los respectivos directorios
+    # en src/interfaces/cpp/ .
+    include(GenerateJderobot.cmake)
+
+    # Todos los directorios con headers
+    include_directories(
+	    interfaces/cpp/jderobot 
+	    interfaces/slice/jderobot 
+	    interfaces/cpp 
+	    interfaces/slice
+	    include
+    )
+
+    # Todas las fuentes del proyecto
+    set(_srcs
+    interfaces/cpp/jderobot/camera.cpp interfaces/cpp/jderobot/camera.h
+    interfaces/cpp/jderobot/common.cpp interfaces/cpp/jderobot/common.h
+    interfaces/cpp/jderobot/containers.cpp interfaces/cpp/jderobot/containers.h
+    interfaces/cpp/jderobot/datetime.cpp interfaces/cpp/jderobot/datetime.h
+    interfaces/cpp/jderobot/exceptions.cpp interfaces/cpp/jderobot/exceptions.h
+    interfaces/cpp/jderobot/image.cpp interfaces/cpp/jderobot/image.h
+    interfaces/cpp/jderobot/pose3dmotors.cpp interfaces/cpp/jderobot/pose3dmotors.h
+
+    sensors.cpp sensors.h
+    control.cpp control.h
+    handler.cpp handler.h
+    main.cpp
+    )
+
+    qi_create_bin(naofollowball ${_srcs})
+
+    qi_use_lib(naofollowball LIBICEE OPENCV)
+else()
+    SET( SOURCE_FILES_FOLLOWBALL viewer.cpp sensors.cpp control.cpp handler.cpp main.cpp )
+
+    SET( CMAKE_CXX_FLAGS "-lpthread -lIce" ) # Opciones para el compilador
+
+    include_directories (
+        ${INTERFACES_CPP_DIR}
+        ${LIBS_DIR}
+        ${CMAKE_CURRENT_SOURCE_DIR}
+        ${gtk20_INCLUDE_DIRS}
+        ${gtkmm_INCLUDE_DIRS}
+        ${libglademm_INCLUDE_DIRS}
+        ${OpenCV_INCLUDE_DIRS}
+    )
+
+    set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+    add_executable (followball ${SOURCE_FILES_FOLLOWBALL})
+
+    TARGET_LINK_LIBRARIES ( followball
+        JderobotInterfaces
+        jderobotutil
+        ${gtk20_LIBRARIES}
+        ${gtkmm_LIBRARIES}
+        ${libglademm_LIBRARIES}
+        ${ZeroCIce_LIBRARIES}
+        ${OpenCV_LIBRARIES}
+    )
+endif()

Added: trunk/src/testing/components/followBall/GenerateJderobot.cmake
===================================================================
--- trunk/src/testing/components/followBall/GenerateJderobot.cmake	                        (rev 0)
+++ trunk/src/testing/components/followBall/GenerateJderobot.cmake	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,20 @@
+set(SLICE2CPPE /opt/IceE-1.3.0/bin/slice2cppe) 
+
+set(JDEROBOT_ICEFILES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/slice)
+set(JDEROBOT_OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/cpp/jderobot)
+
+set (JDEROBOT_FILES
+    camera
+    common
+    containers
+    datetime
+    exceptions
+    image
+	pose3dmotors
+)
+
+foreach (file ${JDEROBOT_FILES})
+	set (jderobot_file jderobot/${file}.ice)
+	set(args --output-dir=${JDEROBOT_OUTPUT_DIR} -I. -I${JDEROBOT_ICEFILES_DIR} ${JDEROBOT_ICEFILES_DIR}/${jderobot_file})
+	execute_process(COMMAND ${SLICE2CPPE} ${args})	
+endforeach()

Added: trunk/src/testing/components/followBall/README.txt
===================================================================
--- trunk/src/testing/components/followBall/README.txt	                        (rev 0)
+++ trunk/src/testing/components/followBall/README.txt	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,11 @@
+If you want to compile for the Nao robot you have to do the same things that
+for any other component for this robot. Please, follow the guidelines at
+Aldebaran Robotics website:
+
+https://community.aldebaran-robotics.com/doc/1-12/dev/cpp/install_guide.html
+https://community.aldebaran-robotics.com/doc/1-12/dev/cpp/tutos/using_qibuild.html
+
+The project is named followball, so you have to compile like:
+
+qibuild configure -c <your_toolchain> followball
+qibuild make -c <your_toolchain> followball

Added: trunk/src/testing/components/followBall/cameraview.glade
===================================================================
--- trunk/src/testing/components/followBall/cameraview.glade	                        (rev 0)
+++ trunk/src/testing/components/followBall/cameraview.glade	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+  <widget class="GtkWindow" id="mainwindow">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">Cameraview</property>
+    <child>
+      <widget class="GtkTable" id="table1">
+        <property name="visible">True</property>
+        <property name="n_rows">2</property>
+        <property name="n_columns">1</property>
+        <child>
+          <widget class="GtkLabel" id="fpslabel">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">0 fps</property>
+          </widget>
+          <packing>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkImage" id="image">
+            <property name="visible">True</property>
+            <property name="xalign">0.68999999761581421</property>
+            <property name="stock">gtk-missing-image</property>
+          </widget>
+          <packing>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options">GTK_FILL</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>

Added: trunk/src/testing/components/followBall/control.cpp
===================================================================
--- trunk/src/testing/components/followBall/control.cpp	                        (rev 0)
+++ trunk/src/testing/components/followBall/control.cpp	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,55 @@
+/*
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "control.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+Control::Control ( Ice::CommunicatorPtr ic ) {
+    this->ic = ic;
+    Ice::PropertiesPtr prop = this->ic->getProperties();
+    
+    Ice::ObjectPrx base = ic->propertyToProxy("FollowBall.MotorsHeadSpeed.Proxy");
+    if (base == 0)
+        throw "Could not create proxy with Motors";
+    
+    this->motorsprx = jderobot::Pose3DMotorsPrx::checkedCast(base);
+    if (this->motorsprx == 0)
+        throw "Invalid Motors proxy";
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+Control::~Control () {
+    if (this->ic)
+        this->ic->destroy();
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+void Control::sendValues ( float panSpeed, float tiltSpeed ) {
+    jderobot::Pose3DMotorsDataPtr pose(new jderobot::Pose3DMotorsData);
+    pose->panSpeed = panSpeed + 0.00001;
+    pose->tiltSpeed = tiltSpeed + 0.00001;
+    this->motorsprx->setPose3DMotorsData(pose);
+}

Added: trunk/src/testing/components/followBall/control.h
===================================================================
--- trunk/src/testing/components/followBall/control.h	                        (rev 0)
+++ trunk/src/testing/components/followBall/control.h	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,56 @@
+/*
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef CONTROL_H
+#define CONTROL_H
+
+#include <iostream>
+#include <stdio.h>
+
+#ifdef COMPILEFORNAO
+// ICE
+#include <IceE/IceE.h>
+// Interfaces
+#include <pose3dmotors.h>
+#else
+// ICE
+#include <Ice/Ice.h>
+#include <IceUtil/IceUtil.h>
+// Interfaces
+#include <jderobot/pose3dmotors.h>
+#endif
+
+class Control {
+public:
+    // Constructor
+    Control ( Ice::CommunicatorPtr ic );
+    
+    // Destructor
+    virtual ~Control ();
+    
+    // Another functions
+    void sendValues ( float panSpeed, float tiltSpeed );
+
+private:
+    Ice::CommunicatorPtr ic;
+    jderobot::Pose3DMotorsPrx motorsprx;
+};
+
+#endif // CONTROL_H

Added: trunk/src/testing/components/followBall/filter.txt
===================================================================
--- trunk/src/testing/components/followBall/filter.txt	                        (rev 0)
+++ trunk/src/testing/components/followBall/filter.txt	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,3 @@
+255
+51
+51

Added: trunk/src/testing/components/followBall/followball.cfg
===================================================================
--- trunk/src/testing/components/followBall/followball.cfg	                        (rev 0)
+++ trunk/src/testing/components/followBall/followball.cfg	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,3 @@
+FollowBall.Camera.Proxy=Camera:default -h localhost -p 10000
+FollowBall.MotorsHeadSpeed.Proxy=NeckSpeed:default -h localhost -p 10000
+FollowBall.filter=1

Added: trunk/src/testing/components/followBall/handler.cpp
===================================================================
--- trunk/src/testing/components/followBall/handler.cpp	                        (rev 0)
+++ trunk/src/testing/components/followBall/handler.cpp	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,79 @@
+/*
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "handler.h"
+
+#define cycle_handler 50 // miliseconds
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+Handler::Handler ( Sensors* sensors, Control* control ) {
+    this->sensors = sensors;
+    this->control = control;
+    
+    this->panSpeed = 0.0;
+    this->tiltSpeed = 0.0;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+Handler::~Handler () {
+    delete this->sensors;
+    delete this->control;
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+void Handler::init () {
+    struct timeval a, b;
+    long diff;
+    long totalb, totala;
+    
+    while (true) {
+        gettimeofday(&a, NULL);
+        totala = a.tv_sec * 1000000 + a.tv_usec;
+        
+        // Update values
+        this->sensors->update();
+        this->analyzeAndGetValues(this->sensors->getErrorX(), this->sensors->getErrorY());
+        this->control->sendValues(this->panSpeed, this->tiltSpeed);
+        
+        //Sleep Algorithm
+        gettimeofday(&b, NULL);
+        totalb = b.tv_sec * 1000000 + b.tv_usec;
+        diff = (totalb - totala) / 1000;
+        if (diff < 0 || diff > cycle_handler)
+            diff = cycle_handler;
+        else
+            diff = cycle_handler - diff;
+
+        usleep(diff * 1000);
+        if (diff < 33)
+            usleep(33 * 1000);
+    }
+}
+
+void Handler::analyzeAndGetValues ( float errorX, float errorY ) {
+    this->panSpeed = errorX / (320 / 2.0);
+    this->tiltSpeed = -errorY / (240 / 2.0);
+}

Added: trunk/src/testing/components/followBall/handler.h
===================================================================
--- trunk/src/testing/components/followBall/handler.h	                        (rev 0)
+++ trunk/src/testing/components/followBall/handler.h	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,48 @@
+/*
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef HANDLER_H
+#define HANDLER_H
+
+#include "sensors.h"
+#include "control.h"
+
+class Handler {
+public:
+    // Constructor
+    Handler ( Sensors* sensors, Control* control );
+
+    // Destructor
+    virtual ~Handler ();
+    
+    // Another functions
+    void init ();
+    
+private:
+    Sensors* sensors;
+    Control* control;
+    
+    cv::Mat image;
+    float panSpeed, tiltSpeed;
+    
+    void analyzeAndGetValues ( float errorX, float errorY );
+};
+
+#endif // HANDLER_H

Added: trunk/src/testing/components/followBall/interfaces/slice/jderobot/camera.ice
===================================================================
--- trunk/src/testing/components/followBall/interfaces/slice/jderobot/camera.ice	                        (rev 0)
+++ trunk/src/testing/components/followBall/interfaces/slice/jderobot/camera.ice	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,68 @@
+/*
+ *
+ *  Copyright (C) 1997-2010 JDE Developers Team
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see http://www.gnu.org/licenses/. 
+ *
+ *  Author : David Lobato Bravo <dav.lobato en gmail.com>
+ *
+ */
+
+
+#ifndef CAMERA_ICE
+#define CAMERA_ICE
+
+
+#include <jderobot/image.ice>
+
+module jderobot{
+  /**
+   * Static description of a camera
+   */
+  class CameraDescription
+  {
+    string name;
+    string shortDescription;
+    string streamingUri;
+    float fdistx;
+    float fdisty;
+    float u0;
+    float v0;
+    float skew;
+    float posx;
+    float posy;
+    float posz;
+    float foax;
+    float foay;
+    float foaz;
+    float roll;
+  };
+
+  /**
+   * Camera interface
+   */
+  interface Camera extends ImageProvider
+  {
+    idempotent CameraDescription getCameraDescription();
+    int setCameraDescription(CameraDescription description);
+    
+    string startCameraStreaming();
+    
+    void stopCameraStreaming();
+    
+  };
+
+}; /*module*/
+
+#endif /*CAMERA_ICE*/

Added: trunk/src/testing/components/followBall/interfaces/slice/jderobot/common.ice
===================================================================
--- trunk/src/testing/components/followBall/interfaces/slice/jderobot/common.ice	                        (rev 0)
+++ trunk/src/testing/components/followBall/interfaces/slice/jderobot/common.ice	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,11 @@
+#ifndef COMMON_ICE
+#define COMMON_ICE
+
+#include <jderobot/datetime.ice>
+#include <jderobot/exceptions.ice>
+#include <jderobot/containers.ice>
+
+module jderobot{
+}; /*module*/
+
+#endif /*COMMON_ICE*/

Added: trunk/src/testing/components/followBall/interfaces/slice/jderobot/containers.ice
===================================================================
--- trunk/src/testing/components/followBall/interfaces/slice/jderobot/containers.ice	                        (rev 0)
+++ trunk/src/testing/components/followBall/interfaces/slice/jderobot/containers.ice	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,17 @@
+
+#ifndef CONTAINERS_ICE
+#define CONTAINERS_ICE
+
+module jderobot{
+
+  //! A sequence of bytes.
+  sequence<byte> ByteSeq;
+  
+  //! A sequence of ints.
+  sequence<int> IntSeq;
+
+	//! A sequence of floats
+	sequence<float> seqFloat;
+}; /*module*/
+
+#endif /*CONTAINERS_ICE*/

Added: trunk/src/testing/components/followBall/interfaces/slice/jderobot/datetime.ice
===================================================================
--- trunk/src/testing/components/followBall/interfaces/slice/jderobot/datetime.ice	                        (rev 0)
+++ trunk/src/testing/components/followBall/interfaces/slice/jderobot/datetime.ice	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,15 @@
+#ifndef DATETIME_ICE
+#define DATETIME_ICE
+
+module jderobot{
+
+  struct Time
+  {
+    //! Number of seconds
+    long seconds;
+    //! Number of microseconds
+    long useconds;
+  };
+}; /*module*/
+
+#endif /*DATETIME_ICE*/

Added: trunk/src/testing/components/followBall/interfaces/slice/jderobot/exceptions.ice
===================================================================
--- trunk/src/testing/components/followBall/interfaces/slice/jderobot/exceptions.ice	                        (rev 0)
+++ trunk/src/testing/components/followBall/interfaces/slice/jderobot/exceptions.ice	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,36 @@
+#ifndef EXCEPTIONS_ICE
+#define EXCEPTIONS_ICE
+
+module jderobot{
+
+  exception JderobotException
+  {
+    //! Error description.
+    string what;
+  };
+  
+  //! Server failed to configure itself as requrested by client.
+  exception ConfigurationNotExistException extends JderobotException {};
+
+  /*!
+    Raised when the server does not have the requested data.
+    
+    Typically, this is because the server has not fully initialized yet.
+  */
+  exception DataNotExistException extends JderobotException {};
+  
+  //! Indicates a problem with robot hardware, e.g. sensors and actuators.
+  exception HardwareFailedException extends JderobotException {};
+
+  //! Raised when the server is unable to return a topic for subscription.
+  exception NoTopicException extends JderobotException {};
+
+  //! Raised when the server fails to subscribe client for periodic updates.
+  exception SubscriptionFailedException extends JderobotException {};
+
+  //! Raised when the server fails to push initial data to a new subscriber.
+  exception SubscriptionPushFailedException extends JderobotException {};
+
+}; /*module*/
+
+#endif /*EXCEPTIONS_ICE*/

Added: trunk/src/testing/components/followBall/interfaces/slice/jderobot/image.ice
===================================================================
--- trunk/src/testing/components/followBall/interfaces/slice/jderobot/image.ice	                        (rev 0)
+++ trunk/src/testing/components/followBall/interfaces/slice/jderobot/image.ice	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,107 @@
+
+#ifndef IMAGE_ICE
+#define IMAGE_ICE
+
+#include <jderobot/common.ice>
+
+module jderobot {
+
+  enum FeaturesType { Detected, Filtered, Ball, BlueNet, YellowNet, Field, Lines, Regions, Segments, HSV };
+  enum ObjectsType { BallObj, BlueNetObj, YellowNetObj, FieldObj, LinesObj };
+  enum CameraType { UPPERCAMERA, LOWERCAMERA };
+    
+  /**
+   *  Static description of the image source.
+   */
+  class ImageDescription 
+  {
+    int width; /**< %Image width [pixels] */
+    int height;/**< %Image height [pixels] */
+    int size;/**< %Image size [bytes] */
+    string format; /**< %Image format string */
+  };
+  
+  /**
+  * A single image served as a sequence of bytes
+  */
+  class ImageData
+  { 
+    Time timeStamp; /**< TimeStamp of Data */
+    ImageDescription description; /**< ImageDescription of Data, for convienence purposes */
+    ByteSeq pixelData; /**< The image data itself. The structure of this byte sequence
+			  depends on the image format and compression. */
+  };
+  
+  class HSVFilter
+  {
+  	float hmin;
+  	float hmax;
+  	float smin;
+  	float smax;
+  	float vmin;
+  	float vmax;
+  };
+  
+  class CalibrationParams
+  {
+  	float robotx;
+	float roboty;
+	float robott;
+	float u0;
+	float v0;
+	float fdistx;
+	float fdisty;
+  };
+  
+    
+  /** 
+   * Interface to the image provider.
+   */
+  interface ImageProvider
+  {
+    /** 
+     * Returns the image source description.
+     */
+    idempotent ImageDescription getImageDescription();
+
+    /**
+     * Returns the latest data.
+     */
+    ["amd"] idempotent ImageData getImageData()
+      throws DataNotExistException, HardwareFailedException;
+  };
+  
+  /** 
+  * Interface to the image selector.
+  */
+  interface ImageSelector extends ImageProvider
+  {
+    /** 
+     * Changes the type of image sent (filtered, segmented, ...)
+     */
+    idempotent ImageData getImageDataWithFeatures(FeaturesType type)
+      throws DataNotExistException, HardwareFailedException;
+      
+    idempotent HSVFilter getHSVFilter (CameraType cam, ObjectsType obj);
+    idempotent void setHSVFilter (CameraType cam, ObjectsType obj, HSVFilter newFilter);
+    
+    idempotent void setCam (CameraType cam);
+  };
+  
+  /** 
+  * Interface to the calibration.
+  */
+  interface CalibrationProvider
+  {
+    /** 
+     * 
+     */
+    idempotent ImageData getCalibrationImg()
+      throws DataNotExistException, HardwareFailedException;
+    idempotent CalibrationParams getCalibrationParams();
+    idempotent void setCalibrationParams (CalibrationParams newParams);
+  };
+  
+};
+
+#endif //IMAGE_ICE

Added: trunk/src/testing/components/followBall/interfaces/slice/jderobot/pose3dmotors.ice
===================================================================
--- trunk/src/testing/components/followBall/interfaces/slice/jderobot/pose3dmotors.ice	                        (rev 0)
+++ trunk/src/testing/components/followBall/interfaces/slice/jderobot/pose3dmotors.ice	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,71 @@
+/*
+ *  Copyright (C) 1997-2010 JDE Developers Team
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see http://www.gnu.org/licenses/.
+ *
+ *  Authors : Jose María Cañas <jmplaza en gsyc.es>
+ *            Francisco Miguel Rivas Montero <fm.rivas en alumnos.urjc.es>	
+ *  		 Javier Vazquez Pereda <javiervarper en yahoo.es>
+ */
+
+#ifndef POSE3DMOTORS_ICE
+#define POSE3DMOTORS_ICE
+
+#include <jderobot/common.ice>
+
+module jderobot{  
+
+	/** 
+   * Pose3DMotorsData a class that contains the pantilt data
+   */
+	class Pose3DMotorsData
+	{
+		float x;
+		float y;
+		float z;
+		float pan;
+		float tilt;
+		float roll;
+		float panSpeed;
+		float tiltSpeed;
+	};
+
+	/** 
+   * Pose3DMotorsParams a class that contains the motors parametres.
+   */
+	class Pose3DMotorsParams
+	{
+		float maxPan;
+		float minPan;
+		float maxTilt;
+		float minTilt;
+		float maxPanSpeed;
+		float maxTiltSpeed;
+	};
+
+
+  /** 
+   * Interface to the Pose3DMotors Actuators interaction.
+   */
+	interface Pose3DMotors
+	{
+		int setPose3DMotorsData(Pose3DMotorsData data);
+		idempotent Pose3DMotorsData getPose3DMotorsData();
+		idempotent Pose3DMotorsParams getPose3DMotorsParams();
+	};
+
+
+}; //module
+
+#endif //Pose3DMOTORS_ICE

Added: trunk/src/testing/components/followBall/main.cpp
===================================================================
--- trunk/src/testing/components/followBall/main.cpp	                        (rev 0)
+++ trunk/src/testing/components/followBall/main.cpp	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,88 @@
+/*
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "handler.h"
+
+#ifndef COMPILEFORNAO
+#include "viewer.h"
+
+#define cycle_handler 50 // miliseconds
+
+void* thr_gui ( void* obj ) {
+    Sensors* sensors = (Sensors*) obj;
+    Viewer* viewer = new Viewer();
+    
+    struct timeval a, b;
+    long diff;
+    long totalb, totala;
+    
+    while (true) {
+        gettimeofday(&a, NULL);
+        totala = a.tv_sec * 1000000 + a.tv_usec;
+        
+        // Update values
+        cv::Mat image = sensors->getImage();
+        viewer->display(image, sensors->getRH(), sensors->getGS(), sensors->getBV());
+        
+        //Sleep Algorithm
+        gettimeofday(&b, NULL);
+        totalb = b.tv_sec * 1000000 + b.tv_usec;
+        diff = (totalb - totala) / 1000;
+        if (diff < 0 || diff > cycle_handler)
+            diff = cycle_handler;
+        else
+            diff = cycle_handler - diff;
+
+        usleep(diff * 1000);
+        if (diff < 33)
+            usleep(33 * 1000);
+    }
+}
+#endif
+
+int main ( int argc, char* argv[] ) {            
+    Ice::CommunicatorPtr ic;
+    try {
+        ic = Ice::initialize(argc, argv);
+        
+        Sensors* sensors = new Sensors(ic);
+        Control* control = new Control(ic);
+        #ifndef COMPILEFORNAO
+        if ( (argc == 2) && (strcmp(argv[1], "--gui") == 0) ) {
+            pthread_t t_gui;
+            pthread_create(&t_gui, NULL, &thr_gui, (void*) sensors);
+        }
+        #endif
+        Handler* handler = new Handler(sensors, control);
+        handler->init();
+
+        delete sensors;
+        delete control;
+        delete handler;
+    } catch (const Ice::Exception& ex) {
+        std::cerr << ex << std::endl;
+        exit(-1);
+    } catch (const char* msg) {
+        std::cerr << msg << std::endl;
+        exit(-1);
+    }
+    
+    return 1;
+}

Added: trunk/src/testing/components/followBall/qibuild.cmake
===================================================================
--- trunk/src/testing/components/followBall/qibuild.cmake	                        (rev 0)
+++ trunk/src/testing/components/followBall/qibuild.cmake	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,25 @@
+## Copyright (C) 2011 Aldebaran Robotics
+
+###############################################
+# Auto-generated file.                        #
+# Do not edit                                 #
+# This file is part of the qibuild project    #
+###############################################
+
+set(QIBUILD_BOOTSTRAP_VERSION 11)
+
+# Someone used qibuild and generated a dependencies.cmake
+# file (for the dependencies and where to find qibuild/cmake file),
+# so just use it.
+if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/dependencies.cmake)
+  include(${CMAKE_CURRENT_BINARY_DIR}/dependencies.cmake)
+endif()
+
+# Someone used pure qibuild make framework: find the qibild
+# cmake module
+find_package(qibuild QUIET)
+
+
+# Someone called cmake with a toolchain file that is
+# able to find qibuild/cmake code, so just include it.
+include(qibuild/general)

Added: trunk/src/testing/components/followBall/qiproject.xml
===================================================================
--- trunk/src/testing/components/followBall/qiproject.xml	                        (rev 0)
+++ trunk/src/testing/components/followBall/qiproject.xml	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1 @@
+<project name="followball"/>

Added: trunk/src/testing/components/followBall/sensors.cpp
===================================================================
--- trunk/src/testing/components/followBall/sensors.cpp	                        (rev 0)
+++ trunk/src/testing/components/followBall/sensors.cpp	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,311 @@
+/*
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "sensors.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+Sensors::Sensors ( Ice::CommunicatorPtr ic ) {
+    this->ic = ic;
+    Ice::PropertiesPtr prop = this->ic->getProperties();
+    
+    this->filter = prop->getPropertyAsInt("FollowBall.filter");
+    
+    Ice::ObjectPrx base = ic->propertyToProxy("FollowBall.Camera.Proxy");
+    if (base == 0)
+        throw "Could not create proxy with Camera";
+    
+    cameraprx = jderobot::CameraPrx::checkedCast(base);
+    if (cameraprx == 0)
+        throw "Invalid Camera proxy";
+    
+    jderobot::ImageDataPtr data = cameraprx->getImageData();
+    this->image.create(data->description->height, data->description->width, CV_8UC3);
+    
+    this->updateValues();    
+    gettimeofday(&this->a, NULL);
+    
+    pthread_mutex_init(&mutex, NULL);
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+Sensors::~Sensors () {
+    if (this->ic)
+        this->ic->destroy();
+}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+cv::Mat& Sensors::getImage () {
+    return this->image;
+}
+
+float Sensors::getErrorX () {
+    return this->errorX;
+}
+
+float Sensors::getErrorY () {
+    return this->errorY;
+}
+
+int Sensors::getRH () {
+    return this->valueRH;
+}
+
+int Sensors::getGS () {
+    return this->valueGS;
+}
+
+int Sensors::getBV () {
+    return this->valueBV;
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+void Sensors::update () {    
+    jderobot::ImageDataPtr data = cameraprx->getImageData();
+    pthread_mutex_lock(&this->mutex);
+    
+    memcpy((unsigned char *) this->image.data, &(data->pixelData[0]), this->image.cols * this->image.rows * 3);
+    
+    struct timeval b;
+    gettimeofday(&b, NULL);
+    long totala = this->a.tv_sec * 1000000 + this->a.tv_usec;
+    long totalb = b.tv_sec * 1000000 + b.tv_usec;
+    long diff = (totalb - totala) / 1000;
+    
+    if (diff > 10000) {
+        this->updateValues();
+        gettimeofday(&this->a, NULL);
+    }
+    
+    switch (this->filter) {
+    case 0: // RGB
+        break;
+    case 1: // HSV
+        cv::cvtColor(this->image, this->image, CV_RGB2HSV);
+        break;
+    default: // HSV by default
+        cv::cvtColor(this->image, this->image, CV_RGB2HSV);
+        break;
+    }
+    
+    cv::Mat imageBackGroundGRAY;
+    imageBackGroundGRAY.create(data->description->height, data->description->width, CV_8UC1);
+
+    for ( int x = 0; x < this->image.cols; x++ ) {
+        for ( int y = 0; y < this->image.rows; y++ ) {
+            int indice = y * this->image.step + x * this->image.channels();
+            int indiceGray = y * imageBackGroundGRAY.step + x * imageBackGroundGRAY.channels();
+                 
+            int imageh = (int) this->image.data[indice];
+            int images = (int) this->image.data[indice+1];
+            int imagev = (int) this->image.data[indice+2];
+            
+            if ( (imageh >= this->minValueRH) && (imageh <= this->maxValueRH)
+                && (images >= this->minValueGS) && (images <= this->maxValueGS)
+                && (imagev >= this->minValueBV) && (imagev <= this->maxValueBV) ) {
+                imageBackGroundGRAY.data[indiceGray] = 255;
+            } else {
+                imageBackGroundGRAY.data[indiceGray] = 0;
+            }
+        }
+    }
+
+    cv::Mat threshold_output;
+    int thresh = 50;
+    std::vector<std::vector<cv::Point> > contours;
+    std::vector<cv::Vec4i> hierarchy;
+
+    cv::threshold(imageBackGroundGRAY, threshold_output, thresh, 255, cv::THRESH_BINARY);
+    cv::findContours(threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
+
+    /// Approximate contours to polygons + get bounding rects and circles
+    std::vector<std::vector<cv::Point> > contours_poly(contours.size());
+    std::vector<cv::Rect> boundRect;
+    std::vector<cv::Point2f>center(1);
+    std::vector<float>radius(1);
+
+    cv::Mat contoursAux;
+    for ( unsigned i = 0; i < contours.size(); i++ ) {
+        contoursAux = cv::Mat(contours[i]);
+        cv::approxPolyDP(contoursAux, contours_poly[i], 3, true);
+    }
+
+    int maximo = 0;
+    int indice_maximo = 0;
+    for ( unsigned i= 0; i < contours_poly.size(); i++ ) {
+        contoursAux = cv::Mat(contours_poly[i]);
+        double area0 = cv::contourArea(contoursAux);
+        if (area0 > maximo) {
+            maximo = area0;
+            indice_maximo = i;
+        }
+    }
+
+    if (contours_poly.size() > 0){
+        contoursAux = cv::Mat(contours_poly[indice_maximo]);
+        boundRect.push_back(boundingRect(cv::Mat(contours_poly[indice_maximo])));
+        cv::minEnclosingCircle( (cv::Mat)contours_poly[indice_maximo], center[0], radius[0] );
+    }
+    
+    /// Draw polygonal contour + bonding rects + circles
+    for ( unsigned i = 0; i < boundRect.size(); i++ ) {
+        cv::Scalar color = cv::Scalar(255, 0, 0);
+        cv::circle(this->image, center[i], (int)radius[i], color, 2, 8, 0);
+    }
+
+    if (boundRect.size() > 0) {
+        this->errorX = 320/2 - center[0].x;
+        this->errorY = 240/2 - center[0].y;
+    } else {
+        this->errorX = 0.0;
+        this->errorY = 0.0;
+    }
+
+    #ifndef COMPILEFORNAO
+    cv::line(this->image, cv::Point(320/2, 0), cv::Point(320/2, 240), cv::Scalar(0, 0, 255), 1);
+    cv::line(this->image, cv::Point(0, 240/2), cv::Point(320, 240/2), cv::Scalar(0, 0, 255), 1);
+    #endif
+
+    pthread_mutex_unlock(&this->mutex);
+    
+    imageBackGroundGRAY.release();
+    threshold_output.release();
+    contoursAux.release();
+    
+    contours.clear();
+    hierarchy.clear();
+    contours_poly.clear();
+    boundRect.clear();
+    center.clear();
+    radius.clear();
+}
+
+void Sensors::updateValues () {
+    std::ifstream infile("filter.txt");
+    std::string line;
+    int i = 0;
+    
+    while ( std::getline(infile, line) ) {
+        std::istringstream iss(line);
+        int n;
+        iss >> n;
+        
+        switch (i) {
+        case 0: // R/H
+            this->valueRH = n;
+            break;
+        case 1: // G/S
+            this->valueGS = n;
+            break;
+        case 2: // B/V
+            this->valueBV = n;
+            break;
+        }
+        i++;
+    }
+    
+    int restRH, restGS, restBV;
+    
+    if (this->valueRH + 25 > 255) {
+        this->maxValueRH = 255;
+        restRH = this->valueRH + 25 - 255;
+    } else {
+        this->maxValueRH = this->valueRH + 25;
+        restRH = 0;
+    }
+    if (this->valueRH - 25 < 0) {
+        this->minValueRH = 0;
+        restRH = -(this->valueRH - 25);
+        this->maxValueRH += restRH;
+    } else {
+        this->minValueRH = this->valueRH - 25;
+        if (restRH != 0)
+            this->minValueRH -= restRH;
+    }
+    
+    if (this->valueGS + 25 > 255) {
+        this->maxValueGS = 255;
+        restGS = this->valueGS + 25 - 255;
+    } else {
+        this->maxValueGS = this->valueGS + 25;
+        restGS = 0;
+    }
+    if (this->valueGS - 25 < 0) {
+        this->minValueGS = 0;
+        restGS = -(this->valueGS - 25);
+        this->maxValueGS += restGS;
+    } else {
+        this->minValueGS = this->valueGS - 25;
+        if (restGS != 0)
+            this->minValueGS -= restGS;
+    }
+    
+    if (this->valueBV + 25 > 255) {
+        this->maxValueBV = 255;
+        restBV = this->valueBV + 25 - 255;
+    } else {
+        this->maxValueBV = this->valueBV + 25;
+        restBV = 0;
+    }
+    if (this->valueBV - 25 < 0) {
+        this->minValueBV = 0;
+        restBV = -(this->valueBV - 25);
+        this->maxValueBV += restBV;
+    } else {
+        this->minValueBV = this->valueBV - 25;
+        if (restBV != 0)
+            this->minValueBV -= restBV;
+    }
+}
+
+void Sensors::RGBtoHSV ( double r, double g, double b, double *h, double *s, double *v ) {
+	double max = (r > g && r > b)? r : (g > b)? g : b;
+	double min = (r < g && r < b)? r : (g < b)? g : b;
+	
+	*h = 0;
+	*s = 0;
+	*v = max;
+	
+	if (*v != 0)
+	    *s = (*v - min) / *v;
+	else
+	    *s = 0;
+
+	if (*v == r)
+	    *h = 60 * (g - b) / (*v - min);
+	if (*v == g)
+	    *h = 120 + 60 * (b - r) / (*v - min);
+    if (*v == b)
+        *h = 240 + 60 * (r - g) / (*v - min);
+        
+    if (*h < 0)
+        *h += 360;
+    
+//    *v *= 255;
+    *s *= 255;
+    *h /= 2;
+}

Added: trunk/src/testing/components/followBall/sensors.h
===================================================================
--- trunk/src/testing/components/followBall/sensors.h	                        (rev 0)
+++ trunk/src/testing/components/followBall/sensors.h	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,85 @@
+/*
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef SENSORS_H
+#define SENSORS_H
+
+#include <iostream>
+#include <stdio.h>
+
+#include <fstream>
+#include <sstream>
+
+#ifdef COMPILEFORNAO
+// ICE
+#include <IceE/IceE.h>
+// OpenCV
+#include <opencv/cv.h>
+#include <opencv/cv.hpp>
+// Interfaces
+#include <camera.h>
+#else
+// ICE
+#include <Ice/Ice.h>
+#include <IceUtil/IceUtil.h>
+// OpenCV
+#include <opencv2/core/core.hpp>
+#include <opencv2/imgproc/imgproc.hpp>
+// Interfaces
+#include <jderobot/camera.h>
+#endif
+
+class Sensors {
+public:
+    // Constructor
+    Sensors ( Ice::CommunicatorPtr ic );
+    
+    // Destructor
+    virtual ~Sensors ();
+    
+    // Getters
+    float getErrorX ();
+    float getErrorY ();
+    cv::Mat& getImage ();
+    
+    int getRH ();
+    int getGS ();
+    int getBV ();
+    
+    // Another functions
+    void update ();
+    
+private:
+    Ice::CommunicatorPtr ic;
+    jderobot::CameraPrx cameraprx;
+    cv::Mat image;
+    float errorX, errorY;
+    int valueRH, valueGS, valueBV;
+    int minValueRH, minValueGS, minValueBV, maxValueRH, maxValueGS, maxValueBV;
+    struct timeval a;
+    int filter; // 0: RGB, 1: HSV
+    
+    void updateValues ();
+    void RGBtoHSV ( double r, double g, double b, double *h, double *s, double *v );
+    
+    pthread_mutex_t mutex;
+};
+
+#endif // SENSORS_H

Added: trunk/src/testing/components/followBall/viewer.cpp
===================================================================
--- trunk/src/testing/components/followBall/viewer.cpp	                        (rev 0)
+++ trunk/src/testing/components/followBall/viewer.cpp	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,107 @@
+/*
+ *
+ *  Copyright (C) 1997-2009 JDERobot Developers Team
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see http://www.gnu.org/licenses/. 
+ *
+ *  Authors : David Lobato Bravo <dav.lobato en gmail.com>
+ *
+ */
+
+#include "viewer.h" 
+#include <iostream>
+#include <cmath>
+
+  const std::string gladepath = std::string("./cameraview.glade");
+
+  Viewer::Viewer() 
+    : gtkmain(0,0),frameCount(0) {
+
+    std::cout << "Loading glade\n";
+    refXml = Gnome::Glade::Xml::create(gladepath);
+    refXml->get_widget("image", gtkimage);
+    refXml->get_widget("mainwindow", mainwindow);
+    refXml->get_widget("fpslabel", fpslabel);
+
+    this->mainwindow->add_events(Gdk::BUTTON_PRESS_MASK);
+    this->mainwindow->signal_event().connect(
+                sigc::mem_fun(*this, &Viewer::on_window_event));
+        
+    this->mainwindow->show_all_children();
+
+    // start the timer for calculating the number of frames per second
+    // the images are being displayed at
+    oldFrameTime = IceUtil::Time::now();
+  }
+    
+
+  Viewer::~Viewer() {}
+  
+  bool Viewer::on_window_event ( GdkEvent* event ) {
+    if (event->button.button == 1) {
+        int indice = event->button.y * this->myImage.step + event->button.x * this->myImage.channels();
+        this->r = this->myImage.data[indice];
+        this->g = this->myImage.data[indice+1];
+        this->b = this->myImage.data[indice+2];
+    }
+  }
+
+  bool Viewer::isVisible(){
+    return mainwindow->is_visible();
+  }
+
+  void Viewer::display( cv::Mat& image, int rf, int gf, int bf )
+  {
+    this->rF = rf;
+    this->gF = gf;
+    this->bF = bf;
+    this->myImage = image;
+    Glib::RefPtr<Gdk::Pixbuf> imgBuff = 
+            Gdk::Pixbuf::create_from_data((const guint8*)image.data,
+				                          Gdk::COLORSPACE_RGB,
+				                          false,
+				                          8,
+				                          image.cols,
+				                          image.rows,
+				                          image.step); 
+    
+    gtkimage->clear();
+    gtkimage->set(imgBuff);
+    displayFrameRate();
+    mainwindow->resize(1,1);
+    while (gtkmain.events_pending())
+      gtkmain.iteration();
+  }
+    
+  void
+  Viewer::displayFrameRate()
+  {
+    double diff;
+    IceUtil::Time diffT;
+
+    currentFrameTime = IceUtil::Time::now();
+    diff = (currentFrameTime - oldFrameTime).toMilliSecondsDouble();
+    if (diff < 1000.0)
+      frameCount++;
+    else{
+      oldFrameTime = currentFrameTime;
+      fps = frameCount*1000.0/diff;
+      frameCount=0;
+      // Display the frame rate
+      std::stringstream fpsString;
+      fpsString << "fps = " << int(fps) << "; R/H = " << this->r << "; G/S = " << this->g << "; B/V = " << this->b << std::endl;
+      fpsString << "filtering: R/H = " << this->rF << "; G/S = " << this->gF << "; B/V = " << this->bF << std::endl;
+      fpslabel->set_label(fpsString.str());
+    }
+  }

Added: trunk/src/testing/components/followBall/viewer.h
===================================================================
--- trunk/src/testing/components/followBall/viewer.h	                        (rev 0)
+++ trunk/src/testing/components/followBall/viewer.h	2013-11-07 18:28:27 UTC (rev 1090)
@@ -0,0 +1,66 @@
+/*
+ *
+ *  Copyright (C) 1997-2009 JDERobot Developers Team
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see http://www.gnu.org/licenses/. 
+ *
+ *  Authors : David Lobato Bravo <dav.lobato en gmail.com>
+ *
+ */
+
+#ifndef CAMERAVIEW_VIEWER_H
+#define CAMERAVIEW_VIEWER_H
+
+#include <gtkmm.h>
+#include <libglademm.h>
+#include <IceUtil/Thread.h>
+#include <IceUtil/Time.h>
+#include <string>
+#include <opencv2/core/core.hpp>
+
+  class Viewer
+  {
+  public:
+    Viewer();
+    ~Viewer();
+  
+    bool isVisible();
+
+    //! function that actually displays the image in a window
+    void display( cv::Mat& image, int rf, int gf, int bf );
+
+  private:
+    Glib::RefPtr<Gnome::Glade::Xml> refXml;
+    Gtk::EventBox* eventbox;
+    Gtk::Image* gtkimage;
+    Gtk::Window* mainwindow;
+    Gtk::Label* fpslabel;
+    Gtk::Main gtkmain;
+  
+    //! display the frame rate of the received images
+    void displayFrameRate();
+    
+    bool on_window_event ( GdkEvent* event );
+    
+    cv::Mat myImage;
+    int r, g, b;
+    int rF, gF, bF;
+      
+    //! time variables for calculating number of frames per second 
+    IceUtil::Time currentFrameTime,oldFrameTime;
+    double fps;
+    int frameCount;
+  };
+
+#endif //CAMERAVIEW_VIEWER_H



More information about the Jderobot-admin mailing list