<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to WheeledRobots</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>Recent changes to WheeledRobots</description><atom:link href="https://sourceforge.net/p/farsa/wiki/WheeledRobots/feed" rel="self"/><language>en</language><lastBuildDate>Fri, 20 Nov 2015 10:22:21 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/farsa/wiki/WheeledRobots/feed" rel="self" type="application/rss+xml"/><item><title>WheeledRobots modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Fri, 20 Nov 2015 10:22:21 -0000</pubDate><guid>https://sourceforge.net9cb2dd59030c657fbd5c9917dce7a3dd5e1628c4</guid></item><item><title>WheeledRobots modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Tue, 17 Nov 2015 13:59:48 -0000</pubDate><guid>https://sourceforge.net6d1431e0e11bef166f4ab59a8fc32d0d97a0e82a</guid></item><item><title>WheeledRobots modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v12
+++ v13
@@ -1,4 +1,4 @@
-[Prev: Using robots]([CustomizingRobots]) | [Up: Using robots]([CustomizingRobots]) | [Next: iCub robots]([iCubRobot])
+[Prev: Using robots]([CustomizingRobots]) | [Up: Using robots]([CustomizingRobots]) | [Next: The iCub robot]([iCubRobot])
  -------|--------|----------
         |        |

@@ -9,40 +9,38 @@
 Wheeled Robots
 ======

-The following function shows how you can inizialize the position and the orientation of a single wheeled robot in the environment, and how you can access the robot's variables. Here we assume that the user want to initialize the position of the robot within the 40x40cm central portion of the Arena. 
+The following function shows how you can inizialize the position and the orientation of a single wheeled robot in the environment, and how you can access the robot's variables. Here we assume that the user want to initialize the position of the robot within the 40x40cm central portion of the arena. *RobotOnPlane* is the base class for wheeled robots that live in the *Arena*. It has some useful functions that allow to use bi-dimensional coordinates and orientation in place of the tri-dimensional ones. The example assumes that *MyExperiment* is a subclass of *EvoRobotExperiment*.

 ~~~~~~~
 :::C++
 /*
- * This example code illustrate how you can initialize and position and the orientation of a wheeled robot
- * in the case of experiment involving only a single robot (i.e. NAgents = 1)
+ * This example code illustrates how you can initialize and position and the orientation of a wheeled robot
+ * in the case of experiment involving only a single robot (i.e. nagents = 1)
  */
 void MyExperiment::initTrial(int /*trial*/)
 {
+    // lock the resource so to enable the function to access the arena and world component
+    farsa::ResourcesLocker locker(this);

-//lock the resource so to enable the function to access the arena and world component
-farsa::ResourcesLocker locker(this);
+    // get the arena component
+    farsa::Arena* arena = getResource&amp;lt;farsa::Arena&amp;gt;("arena");

-// get the arena component
-farsa::Arena* arena = getResource&amp;lt;farsa::Arena&amp;gt;("arena");
-       
-// get the robot component
-farsa::RobotOnPlane* robot = getResource&amp;lt;farsa::RobotOnPlane&amp;gt;("agent[0]:robot");
+    // get the robot component
+    farsa::RobotOnPlane* robot = getResource&amp;lt;farsa::RobotOnPlane&amp;gt;("agent[0]:robot");

-// set the position of the robot by selecting a random location in the xy range [-20,20]cm
-robot-&amp;gt;setPosition(arena-&amp;gt;getPlane(), farsa::globalRNG-&amp;gt;getDouble(-0.2f, 0.2f), farsa::globalRNG-&amp;gt;getDouble(-0.2f, 0.2f));
+    // set the position of the robot by selecting a random location in the xy range [-20,20]cm
+    robot-&amp;gt;setPosition(arena-&amp;gt;getPlane(), farsa::globalRNG-&amp;gt;getDouble(-0.2f, 0.2f), farsa::globalRNG-&amp;gt;getDouble(-0.2f, 0.2f));

-// set the orientation of the robot randomly within a 360 degrees interval
-robot-&amp;gt;setOrientation(arena-&amp;gt;getPlane(), farsa::globalRNG-&amp;gt;getDouble(-PI_GRECO, PI_GRECO));
+    // set the orientation of the robot randomly within a 360 degrees interval
+    robot-&amp;gt;setOrientation(arena-&amp;gt;getPlane(), farsa::globalRNG-&amp;gt;getDouble(-PI_GRECO, PI_GRECO));

-// display the robot position, orientation, radius, and color on the logger windows
-Logger::info(QString("Robot:%1, pos:%2, orien:%3, radius:%4, color:%5 ").arg(0).arg(robot-&amp;gt;position()).arg(robot-&amp;gt;orientation(arena-&amp;gt;getPlane())).arg(robot-&amp;gt;robotRadius()).arg(robot-&amp;gt;robotColor().name()));
-
+    // display the robot position, orientation, radius, and color on the logger windows
+    Logger::info(QString("Robot:%1, pos:%2, orien:%3, radius:%4, color:%5 ").arg(0).arg(robot-&amp;gt;position()).arg(robot-&amp;gt;orientation(arena-&amp;gt;getPlane())).arg(robot-&amp;gt;robotRadius()).arg(robot-&amp;gt;robotColor().name()));
 }
 ~~~~~~~

-In the case of collective experiments in which the environment containt multiple robots, the experimental plugin might include a *resourceChanged()* function like the one shown below that creates and maintains the list of robot that can be accessed by a pointer (the *m_robot* pointer, in this case). 
-The *initTrial()* function enclosed below show how the position and the orientation of the robots can be initialized for all define robots. Notice that this example we do not check whether the chosen position of the robots' overlap. 
+In the case of collective experiments in which the environment containt multiple robots, the experimental plugin might include a *resourceChanged()* function like the one shown below that creates and updates a list of robots so that they can be accessed directly (using the *m_robot* vector, in this case).
+The *initTrial()* function below shows how the position and the orientation of the robots can be initialized for all defined robots. Notice that this example we do not check whether the chosen positions of the robots' overlap.

 ~~~~~~~
 :::C++
@@ -52,33 +50,30 @@
  */
 void MyExperiment::resourceChanged(QString resourceName, ResourceChangeType changeType)
 {
+    // Calling parent function
+    farsa::EvoRobotExperiment::resourceChanged(resourceName, changeType);

-// Calling parent function
-farsa::EvoRobotExperiment::resourceChanged(resourceName, changeType);
+    // Here we are only interested in robots, so we build a regular expression to only check when
+    // a robot changes
+    QRegExp checkRobots("agent\\[(\\d)\\]:robot");
+    if (checkRobots.indexIn(resourceName) != -1) {
+        // Getting the index
+        int index = checkRobots.cap(1).toUInt();

-// Here we are only interested in robots, so we build a regular expression to only check when
-// a robot changes
-QRegExp checkRobots("agent\\[(\\d)\\]:robot");
-if (checkRobots.indexIn(resourceName) != -1) {
-   // Getting the index
-   int index = checkRobots.cap(1).toUInt();
+        if (changeType == Deleted) {
+            // Removing robot
+            m_robots[index] = NULL;
+        } else {
+            // Adding the robot to our list
+            farsa::RobotOnPlane* const robot = getResource&amp;lt;farsa::RobotOnPlane&amp;gt;();

-   // The code below should work as expected. If there is a crash, then there is probably a bug
-   // in resource management
-   if (changeType == Deleted) {
-       // Removing robot
-       m_robots[index] = NULL;
-       } else {
-       // Adding the robot to our list
-       farsa::RobotOnPlane* const robot = getResource&amp;lt;farsa::RobotOnPlane&amp;gt;();
-
-       if (m_robots.size() == index) {
-           m_robots.append(robot);
-           } else {
-           m_robots[index] = robot;
-       }
-       }
-   }
+            if (m_robots.size() == index) {
+                m_robots.append(robot);
+            } else {
+                m_robots[index] = robot;
+            }
+        }
+    }
 }

 /*
@@ -87,21 +82,18 @@
  */
 void MyExperiment::initTrial(int /*trial*/)
 {
+    //lock the resource so to enable the function to access the arena and world component
+    farsa::ResourcesLocker locker(this);

-//lock the resource so to enable the function to access the arena and world component
-farsa::ResourcesLocker locker(this);
+    // get the arena component
+    farsa::Arena* arena = getResource&amp;lt;farsa::Arena&amp;gt;("arena");

-// get the arena component
-farsa::Arena* arena = getResource&amp;lt;farsa::Arena&amp;gt;("arena");
-
-// randomly set the position and the orientation of the robots 
-// and display the robot's state on the logger window
-for (int i = 0; i &amp;lt; m_robots.size(); i++) 
-    {
-    m_robots[i]-&amp;gt;setPosition(arena-&amp;gt;getPlane(), farsa::globalRNG-&amp;gt;getDouble(-0.2f, 0.2f), farsa::globalRNG-&amp;gt;getDouble(-0.2f, 0.2f));
-    m_robots[i]-&amp;gt;setOrientation(arena-&amp;gt;getPlane(), farsa::globalRNG-&amp;gt;getDouble(-PI_GRECO, PI_GRECO));
-    Logger::info(QString("Robot:%1, posx:%2, posy:%3, posz:%4, orien:%5, radius:%6, color:%7 ").arg(i).arg(m_robots[i]-&amp;gt;position().x).arg(m_robots[i]-&amp;gt;position().y).arg(m_robots[i]-&amp;gt;position().z).arg(m_robots[i]-&amp;gt;orientation(arena-&amp;gt;getPlane())).arg(m_robots[i]-&amp;gt;robotRadius()).arg(m_robots[i]-&amp;gt;robotColor().name()));
+    // randomly set the position and the orientation of the robots
+    // and display the robot's state on the logger window
+    for (int i = 0; i &amp;lt; m_robots.size(); i++) {
+        m_robots[i]-&amp;gt;setPosition(arena-&amp;gt;getPlane(), farsa::globalRNG-&amp;gt;getDouble(-0.2f, 0.2f), farsa::globalRNG-&amp;gt;getDouble(-0.2f, 0.2f));
+        m_robots[i]-&amp;gt;setOrientation(arena-&amp;gt;getPlane(), farsa::globalRNG-&amp;gt;getDouble(-PI_GRECO, PI_GRECO));
+        Logger::info(QString("Robot:%1, posx:%2, posy:%3, posz:%4, orien:%5, radius:%6, color:%7 ").arg(i).arg(m_robots[i]-&amp;gt;position().x).arg(m_robots[i]-&amp;gt;position().y).arg(m_robots[i]-&amp;gt;position().z).arg(m_robots[i]-&amp;gt;orientation(arena-&amp;gt;getPlane())).arg(m_robots[i]-&amp;gt;robotRadius()).arg(m_robots[i]-&amp;gt;robotColor().name()));
     }
- 
 }
 ~~~~~~~
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Sat, 14 Nov 2015 08:53:29 -0000</pubDate><guid>https://sourceforge.netb209ca6091a1e0722064e520c6766c5e9318506c</guid></item><item><title>WheeledRobots modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Fri, 13 Nov 2015 10:32:04 -0000</pubDate><guid>https://sourceforge.neta3bc5c1e6f793bb55871b6525c2a25230ad6e3cc</guid></item><item><title>WheeledRobots modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Thu, 12 Nov 2015 10:37:02 -0000</pubDate><guid>https://sourceforge.net3c9241e7e40c4068a5db34159aa017b410806ca4</guid></item><item><title>WheeledRobots modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v9
+++ v10
@@ -1,3 +1,11 @@
+[Prev: Using robots]([CustomizingRobots]) | [Up: Using robots]([CustomizingRobots]) | [Next: iCub robots]([iCubRobot])
+ -------|--------|----------
+        |        |
+
+**Table of contents**
+
+[TOC]
+
 Wheeled Robots
 ======

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Thu, 12 Nov 2015 10:22:06 -0000</pubDate><guid>https://sourceforge.netb3579666edf4f23e28ccb63ee9d096392c1d451b</guid></item><item><title>WheeledRobots modified by Stefano Nolfi</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v8
+++ v9
@@ -1,7 +1,7 @@
 Wheeled Robots
 ======

-The following function shows how you can inizialize the position and the orientation of a wheeled robot in the environment, and how you can access the robot's variables. Here we assume that the user want to initialize the position of the robot within the 40x40cm central portion of the Arena. 
+The following function shows how you can inizialize the position and the orientation of a single wheeled robot in the environment, and how you can access the robot's variables. Here we assume that the user want to initialize the position of the robot within the 40x40cm central portion of the Arena. 

 ~~~~~~~
 :::C++
@@ -33,8 +33,8 @@
 }
 ~~~~~~~

-In the case of experiment that can work with multiple robots, the source code should include a
-resourceChanged() function like the one described below that create and maintain the list of robot (that can be accessed with the m_robot pointer). The initTrial function reported below exemplifies how the position and the orientation of the robot can be initialized for all define robots. Notice that this exemplificative code does not check whether the positioned robots overlap in space.
+In the case of collective experiments in which the environment containt multiple robots, the experimental plugin might include a *resourceChanged()* function like the one shown below that creates and maintains the list of robot that can be accessed by a pointer (the *m_robot* pointer, in this case). 
+The *initTrial()* function enclosed below show how the position and the orientation of the robots can be initialized for all define robots. Notice that this example we do not check whether the chosen position of the robots' overlap. 

 ~~~~~~~
 :::C++
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefano Nolfi</dc:creator><pubDate>Wed, 28 Oct 2015 12:58:28 -0000</pubDate><guid>https://sourceforge.netdecb57ed38c156bd27bc92982bdf3e5582d2215f</guid></item><item><title>WheeledRobots modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v7
+++ v8
@@ -1,4 +1,4 @@
-Initializing Wheeled Robots
+Wheeled Robots
 ======

 The following function shows how you can inizialize the position and the orientation of a wheeled robot in the environment, and how you can access the robot's variables. Here we assume that the user want to initialize the position of the robot within the 40x40cm central portion of the Arena. 
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Wed, 21 Oct 2015 14:10:37 -0000</pubDate><guid>https://sourceforge.net8e3f6657556be87e0fae276b05eb0bf495d47e16</guid></item><item><title>WheeledRobots modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v6
+++ v7
@@ -3,7 +3,8 @@

 The following function shows how you can inizialize the position and the orientation of a wheeled robot in the environment, and how you can access the robot's variables. Here we assume that the user want to initialize the position of the robot within the 40x40cm central portion of the Arena. 

-~~~~~~~~~~~~~~~~
+~~~~~~~
+:::C++
 /*
  * This example code illustrate how you can initialize and position and the orientation of a wheeled robot
  * in the case of experiment involving only a single robot (i.e. NAgents = 1)
@@ -30,13 +31,13 @@
 Logger::info(QString("Robot:%1, pos:%2, orien:%3, radius:%4, color:%5 ").arg(0).arg(robot-&amp;gt;position()).arg(robot-&amp;gt;orientation(arena-&amp;gt;getPlane())).arg(robot-&amp;gt;robotRadius()).arg(robot-&amp;gt;robotColor().name()));

 }
-~~~~~~~~~~~~~~~~
-
+~~~~~~~

 In the case of experiment that can work with multiple robots, the source code should include a
 resourceChanged() function like the one described below that create and maintain the list of robot (that can be accessed with the m_robot pointer). The initTrial function reported below exemplifies how the position and the orientation of the robot can be initialized for all define robots. Notice that this exemplificative code does not check whether the positioned robots overlap in space.

-~~~~~~~~~~~~~~~~
+~~~~~~~
+:::C++
 /*
  *  We use this private function to build a list of the robots in the experiment.
  *  The list can be retrived with the m_robot pointer
@@ -95,48 +96,4 @@
     }

 }
-~~~~~~~~~~~~~~~~
-
-Please notice that, when used, the resourceChanged() function and the m_robots pointer should be declared in the private section of the include file of the experimental plugin as shown below:
-
-~~~~~~~~~~~~~~~~
-
-/**
- * \brief An experiment that enable to design and experiment with Braintenberg vehicles
- *
- * The resources used by this experiment are the same as the ones of the parent
- * class (EvoRobotExperiment)
- *
- */
-class MyExperiment : public farsa::EvoRobotExperiment
-{
-   Q_OBJECT
-
-public:
-  // ......
-  // The description of public methods and variable has been removed from this example
-  //.......
-
-private:
-
-   /**
-    * \brief The list of robots in the experiment
-    *
-    * This list is built in resourceChanged(), adding robots as they are
-    * added as resources
-    */
-   QVector&amp;lt;farsa::RobotOnPlane*&amp;gt; m_robots;
-
-   /**
-    * \brief Called to notify changes in resources
-    *
-    * We use this function to build a list of the robots in the experiment.
-    * \param resourceName the name of the resource that has changed.
-    * \param chageType the type of change the resource has gone through
-    *                  (whether it was created, modified or deleted)
-    */
-   virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
-
-};
-
-~~~~~~~~~~~~~~~~
+~~~~~~~
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Tue, 13 Oct 2015 07:27:09 -0000</pubDate><guid>https://sourceforge.net23c55330bc7b601d60d5697d4d37a78de595ca70</guid></item><item><title>WheeledRobots modified by Tomassino Ferrauto</title><link>https://sourceforge.net/p/farsa/wiki/WheeledRobots/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tomassino Ferrauto</dc:creator><pubDate>Wed, 07 Oct 2015 14:52:40 -0000</pubDate><guid>https://sourceforge.net38acdf4d3d5d16f7cacb12d84f57899f9998ea54</guid></item></channel></rss>