commit 5d7ba19c375be3b91d09cacd4d8e449da0a9be24
Author: Simon Schulz <sschulz@cit-ec.uni-bielefeld.de>
Date:   Wed Dec 2 10:43:49 2015 +0100

    fixed target generation on no incoming joint states

diff --git a/examples/meka/src/mekajointinterface.cpp b/examples/meka/src/mekajointinterface.cpp
index 2e87f76..4a30adb 100644
--- a/examples/meka/src/mekajointinterface.cpp
+++ b/examples/meka/src/mekajointinterface.cpp
@@ -143,7 +143,6 @@ void MekaJointInterface::execute_motion(){
     p.positions.push_back(joint_target[ID_NECK_PAN] * M_PI / 180.0);
 
     p.time_from_start = ros::Duration(1.2 * 1.0 / humotion::server::Server::MOTION_UPDATERATE);
-    p.time_from_start = ros::Duration(1.2 * 1.0 / humotion::server::Server::MOTION_UPDATERATE);
 
     msg.points.push_back(p);
 
diff --git a/include/humotion/server/controller.h b/include/humotion/server/controller.h
index 91bb40e..afc9eee 100644
--- a/include/humotion/server/controller.h
+++ b/include/humotion/server/controller.h
@@ -46,8 +46,10 @@ public:
 
     void set_gaze_target(GazeState s);
     void set_mouth_target(MouthState s);
+    void set_activated(void);
 
 private:
+    bool activated;
     void add_motion_generator(MotionGenerator *m);
     GazeState relative_gaze_to_absolute_gaze(GazeState relative);
 
diff --git a/src/server/controller.cpp b/src/server/controller.cpp
index 67126d6..5c961f1 100644
--- a/src/server/controller.cpp
+++ b/src/server/controller.cpp
@@ -37,7 +37,7 @@ using namespace humotion;
 using namespace humotion::server;
 
 //! constructor
-Controller::Controller(JointInterface *j){
+Controller::Controller(JointInterface *j) : activated(false) {
     joint_interface = j;
 }
 
@@ -121,11 +121,19 @@ GazeState Controller::relative_gaze_to_absolute_gaze(GazeState relative){
     return absolute_gaze;
 }
 
-
+//! activate controller
+void Controller::set_activated(void){
+    activated = true;
+}
 
 //! update gaze target:
 //! \param GazeState with target values for the overall gaze
 void Controller::set_gaze_target(GazeState new_gaze_target){
+    if (!activated){
+        //not yet initialized, ignore incoming targets
+        return;
+    }
+
     GazeState target_gaze;
 
     //relative or absolute gaze update?
@@ -146,6 +154,11 @@ void Controller::set_gaze_target(GazeState new_gaze_target){
 //! update mouth state:
 //! \param MouthState with target values for the mouth joints
 void Controller::set_mouth_target(MouthState s){
+    if (!activated){
+        //not yet initialized, ignore incoming targets
+        return;
+    }
+
     for(motion_generator_vector_t::iterator it = motion_generator_vector.begin(); it<motion_generator_vector.end(); it++){
         (*it)->set_mouth_target(s);
     }
diff --git a/src/server/middleware_ros.cpp b/src/server/middleware_ros.cpp
index 8c6ceaa..365637d 100644
--- a/src/server/middleware_ros.cpp
+++ b/src/server/middleware_ros.cpp
@@ -37,9 +37,10 @@ using namespace humotion;
 using namespace humotion::server;
 
 //! constructor
-MiddlewareROS::MiddlewareROS(string scope, Controller *c) : Middleware(scope, c){
-    printf("> using ROS middleware\n");
+MiddlewareROS::MiddlewareROS(string scope, Controller *c)
+    : Middleware(scope, c){
 
+    printf("> using ROS middleware\n");
     //start ros core?
     if (ros::isInitialized()){
         //oh another process is doing ros comm, fine, we do not need to call it
@@ -104,8 +105,8 @@ double MiddlewareROS::convert_ros_to_timestamp_ms(ros::Time t){
 
 //! callback to handle incoming gaze  target
 void MiddlewareROS::incoming_gaze_target(const humotion::gaze::ConstPtr& msg){
-    ///printf("> incoming gaze_target [P:%3.1f, T:%3.1f, R:%3.1f] %s\n", msg->pan, msg->tilt, msg->roll, msg->type==humotion::gaze::ABSOLUTE?"ABSOLUTE":"RELATIVE");
     GazeState gaze_state;
+    ///printf("> incoming gaze_target [P:%3.1f, T:%3.1f, R:%3.1f] %s\n", msg->pan, msg->tilt, msg->roll, msg->type==humotion::gaze::ABSOLUTE?"ABSOLUTE":"RELATIVE");
 
     gaze_state.type = msg->type;
     gaze_state.pan  = msg->pan;
diff --git a/src/server/server.cpp b/src/server/server.cpp
index 4f66ead..ea81ecf 100644
--- a/src/server/server.cpp
+++ b/src/server/server.cpp
@@ -100,6 +100,8 @@ void Server::motion_generation_thread(){
 
     printf("> one loop = %3.1fms\n",loop_delay);
 
+    printf("> waiting for incoming joint states\n");
+
     //wait for incoming joint data:
     while (middleware->ok()){
         //mw tick
@@ -122,6 +124,7 @@ void Server::motion_generation_thread(){
     }
 
     printf("> joint data arrived, control loop active.\n");
+    controller->set_activated();
 
     //fine, data is arriving, activate and run control loop:
     while (middleware->ok()){
