Patches regarding slave_activity and TaskContext

Matthias Goldhoorn <[email protected]> Fri, 10 Jan 2014 17:00:33 +0100
Newsgroups gmane.science.robotics.orocos.devel
Organization University of Bremen
Message-ID <[email protected]>
Please find both patches attached, please reply any comments and if you 
accept the patches.

The main problem was that in case of SlaceActivity the slave tasks could 
not handle operation called because they were never executed.

Have a nice weekend,
Matthias

-- 
  Dipl.-Inf. Matthias Goldhoorn
  Space and Underwater Robotic

  Universität Bremen
  FB 3 - Mathematik und Informatik
  AG Robotik
  Robert-Hooke-Straße 5
  28359 Bremen, Germany

  Tel.:     +49 421 178 45-4193
  Zentrale: +49 421 178 45-6550
  Fax:      +49 421 178 45-4150
  E-Mail:   [email protected]

  Weitere Informationen: http://www.informatik.uni-bremen.de/robotik

-- 
Orocos-Dev mailing list
[email protected]
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev
0002-TaskContext-fixed-zero-pointer-fault.patch (text/x-patch, 1.1 KB)
>From fc978818dbce81502759bd7b23645d0a2c26b5ac Mon Sep 17 00:00:00 2001
From: Matthias Goldhoorn <[email protected]>
Date: Fri, 10 Jan 2014 16:17:08 +0100
Subject: [PATCH 2/2] TaskContext: fixed zero pointer fault

The our_act could be nil if there is a parent task given for execution.
In this case our_act->stop() will defnilty fail.
---
 rtt/TaskContext.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/rtt/TaskContext.cpp b/rtt/TaskContext.cpp
index 298a927..e795786 100644
--- a/rtt/TaskContext.cpp
+++ b/rtt/TaskContext.cpp
@@ -352,7 +352,9 @@ namespace RTT
 #endif
         }
         new_act->stop();
-        our_act->stop();
+        if(our_act){
+            our_act->stop();
+        }
         new_act->run( this->engine() );
         our_act = ActivityInterface::shared_ptr( new_act );
         our_act->start();
@@ -364,7 +366,9 @@ namespace RTT
     	if (!new_act)
     		return;
     	new_act->stop();
-        our_act->stop();
+        if(our_act){
+            our_act->stop();
+        }
         our_act.reset( new_act );
         our_act->run( this->engine() );
         our_act->start();
-- 
1.8.5.1
0001-SlaveActivity.patch (text/x-patch, 2.7 KB)
>From 3ae584a2e18d7069442fbceadf5dae3d01716b4a Mon Sep 17 00:00:00 2001
From: Matthias Goldhoorn <[email protected]>
Date: Fri, 10 Jan 2014 16:16:04 +0100
Subject: [PATCH 1/2] SlaveActivity

Fixed bug in which case operations within Task's were not called anymore
if the task is not running, and a slave of another one.
---
 rtt/ExecutionEngine.cpp        | 7 +++++--
 rtt/ExecutionEngine.hpp        | 3 ++-
 rtt/base/RunnableInterface.hpp | 2 +-
 rtt/extras/SlaveActivity.cpp   | 4 +++-
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/rtt/ExecutionEngine.cpp b/rtt/ExecutionEngine.cpp
index 89cf477..1f6d81f 100644
--- a/rtt/ExecutionEngine.cpp
+++ b/rtt/ExecutionEngine.cpp
@@ -318,12 +318,15 @@ namespace RTT
         }
     }
 
-    void ExecutionEngine::step() {
+    void ExecutionEngine::step(bool onlyInternal) {
         processMessages();
         processFunctions();
-        processChildren(); // aren't these ExecutableInterfaces ie functions ?
+        if(!onlyInternal){
+            processChildren(); // aren't these ExecutableInterfaces ie functions ?
+        }
     }
 
+
     void ExecutionEngine::processChildren() {
         // only call updateHook in the Running state.
         if ( taskc ) {
diff --git a/rtt/ExecutionEngine.hpp b/rtt/ExecutionEngine.hpp
index e55bcd4..2a37e76 100644
--- a/rtt/ExecutionEngine.hpp
+++ b/rtt/ExecutionEngine.hpp
@@ -255,8 +255,9 @@ namespace RTT
         /**
          * Executes (in that order) Messages, Functions and updateHook()
          * functions of this TaskContext and its children.
+         * The updateHook's will not be executed if false is passed for onlyInternal
          */
-        virtual void step();
+        virtual void step(bool onlyInternal = false);
 
         virtual bool breakLoop();
 
diff --git a/rtt/base/RunnableInterface.hpp b/rtt/base/RunnableInterface.hpp
index 7c2b299..929d620 100644
--- a/rtt/base/RunnableInterface.hpp
+++ b/rtt/base/RunnableInterface.hpp
@@ -99,7 +99,7 @@ namespace RTT
          * The method that will be periodically executed when this
          * class is run in a periodic thread.
          */
-        virtual void step() = 0;
+        virtual void step(bool onlyInternal = false) = 0;
 
         /**
          * The method that will be executed once when this
diff --git a/rtt/extras/SlaveActivity.cpp b/rtt/extras/SlaveActivity.cpp
index 0c17f6f..8ad88cc 100644
--- a/rtt/extras/SlaveActivity.cpp
+++ b/rtt/extras/SlaveActivity.cpp
@@ -178,8 +178,10 @@ namespace RTT {
 
     bool SlaveActivity::trigger()
     {
-        if (mmaster)
+        if (mmaster){
+            runner->step(true);
             return mmaster->trigger();
+        }
         return false;
     }
 
-- 
1.8.5.1