commit 10cae48574970c8e87400d822290e463a8117902
Author: Sebastian Meyer zu Borgsen <semeyerz@techfak.uni-bielefeld.de>
Date:   Thu Dec 3 13:52:59 2015 +0100

    take care of limits for eye targets

diff --git a/examples/meka/include/mekajointinterface.h b/examples/meka/include/mekajointinterface.h
index f2f3da6..2dadb8e 100644
--- a/examples/meka/include/mekajointinterface.h
+++ b/examples/meka/include/mekajointinterface.h
@@ -19,31 +19,6 @@ public:
     //void fetch_speed(int id, double value, double timestamp);
     void run();
 
-    enum JOINT_ID_ENUM{
-        ICUB_ID_NECK_TILT = 0,
-        ICUB_ID_NECK_ROLL = 1,
-        ICUB_ID_NECK_PAN  = 2,
-        ICUB_ID_EYES_BOTH_UD = 3,
-        ICUB_ID_EYES_PAN = 4,
-        ICUB_ID_EYES_VERGENCE = 5,
-        //the following ids are used for remapping:
-        ICUB_ID_EYES_LEFT_LR,
-        ICUB_ID_EYES_RIGHT_LR,
-        ICUB_ID_EYES_LEFT_LID_LOWER,
-        ICUB_ID_EYES_LEFT_LID_UPPER,
-        ICUB_ID_EYES_RIGHT_LID_LOWER,
-        ICUB_ID_EYES_RIGHT_LID_UPPER,
-        ICUB_ID_EYES_LEFT_BROW,
-        ICUB_ID_EYES_RIGHT_BROW,
-        ICUB_ID_LIP_LEFT_UPPER,
-        ICUB_ID_LIP_LEFT_LOWER,
-        ICUB_ID_LIP_CENTER_UPPER,
-        ICUB_ID_LIP_CENTER_LOWER,
-        ICUB_ID_LIP_RIGHT_UPPER,
-        ICUB_ID_LIP_RIGHT_LOWER,
-        ICUB_JOINT_ID_ENUM_SIZE
-    };
-
     static const int MAIN_LOOP_FREQUENCY = 50;
 
 protected:
@@ -59,10 +34,7 @@ private:
     ros::Subscriber joint_state_subscriber;
     ros::Publisher target_publisher;
 
-
     double get_timestamp_s();
-    double target_angle[ICUB_JOINT_ID_ENUM_SIZE];
-    double target_angle_previous[ICUB_JOINT_ID_ENUM_SIZE];
 
     void set_eyelid_angle(double angle);
     void set_eyebrow_angle(int id);
diff --git a/examples/meka/src/mekajointinterface.cpp b/examples/meka/src/mekajointinterface.cpp
index 3f4c3bd..056b133 100644
--- a/examples/meka/src/mekajointinterface.cpp
+++ b/examples/meka/src/mekajointinterface.cpp
@@ -124,7 +124,8 @@ void MekaJointInterface::execute_motion(){
 
     trajectory_msgs::JointTrajectoryPoint p;
     p.positions.push_back(joint_target[ID_NECK_TILT] * M_PI / 180.0);
-    p.positions.push_back(joint_target[ID_NECK_PAN] * M_PI / 180.0);
+    p.positions.push_back(joint_target[ID_NECK_PAN] * M_PI / 180.0 +0.314);
+    printf("targets pan=%4.1f tilt=%4.1f (eye p %4.1f t %4.2f)\n",joint_target[ID_NECK_TILT],joint_target[ID_NECK_PAN],joint_target[ID_EYES_LEFT_LR],joint_target[ID_EYES_BOTH_UD]);
 
     p.time_from_start = ros::Duration(1.2 * 1.0 / humotion::server::Server::MOTION_UPDATERATE);
 
@@ -202,8 +203,8 @@ void MekaJointInterface::store_min_max(int id, float min, float max){
 }
 
 void MekaJointInterface::init_joints(){
-    store_min_max(ID_NECK_TILT, -10, 10);
-    store_min_max(ID_NECK_PAN, -10, 10);
+    store_min_max(ID_NECK_TILT, -18, 1);
+    store_min_max(ID_NECK_PAN, -56, 56);
 
     store_min_max(ID_NECK_ROLL, -1, 1);
     store_min_max(ID_EYES_BOTH_UD, -1, 1);
diff --git a/src/server/controller.cpp b/src/server/controller.cpp
index 69a3d74..d2e943f 100644
--- a/src/server/controller.cpp
+++ b/src/server/controller.cpp
@@ -131,10 +131,12 @@ void Controller::set_activated(void){
 void Controller::set_gaze_target(GazeState new_gaze_target){
     if (!activated){
         //not yet initialized, ignore incoming targets
+	printf("not activated\n");
         return;
     }
 
     GazeState target_gaze;
+    new_gaze_target.dump();
 
     //relative or absolute gaze update?
     if (new_gaze_target.gaze_type == GazeState::GAZETYPE_RELATIVE){
diff --git a/src/server/eye_motion_generator.cpp b/src/server/eye_motion_generator.cpp
index 155ed4a..6aa9799 100644
--- a/src/server/eye_motion_generator.cpp
+++ b/src/server/eye_motion_generator.cpp
@@ -86,6 +86,11 @@ void EyeMotionGenerator::calculate_targets(){
         eye_tilt_target  = 0.0;
     }
 
+    //check and take care of limits
+    eye_pan_l_target = limit_target(JointInterface::ID_EYES_LEFT_LR, eye_pan_l_target);
+    eye_pan_r_target = limit_target(JointInterface::ID_EYES_RIGHT_LR, eye_pan_r_target);
+    eye_tilt_target = limit_target(JointInterface::ID_EYES_BOTH_UD, eye_tilt_target);
+
     //fetch current angles:
     float eye_pan_l_now = get_current_position(JointInterface::ID_EYES_LEFT_LR);
     float eye_pan_r_now = get_current_position(JointInterface::ID_EYES_RIGHT_LR);
