Revision 1c758459

View differences:

CMakeLists.txt
132 132
## Specify additional locations of header files
133 133
## Your package locations should be listed before other locations
134 134
include_directories (BEFORE ${Boost_INCLUDE_DIRS} ${REFLEXXES_INCLUDE_DIRS})
135
include_directories(include/humotion)
136
include_directories( ${catkin_INCLUDE_DIRS})
135
include_directories(BEFORE include)
136
include_directories(BEFORE include/humotion)
137
#make sure to use ros messages from current build
138
include_directories(BEFORE ${CATKIN_DEVEL_PREFIX}/include)
139
#this should be appended:
140
include_directories(${catkin_INCLUDE_DIRS})
137 141
#link_directories (${Boost_LIBRARY_DIRS} ${REFLEXXES_LIBRARY_DIRS} ${catkin_LIBRARY_DIRS})
138 142

  
139

  
140 143
#####################
141 144
# PLEASE DO NOT REMOVE THIS! This is a hack necessary for qtcreator to show cmake header files in the project view!
142 145
file(GLOB DUMMY_HEADER_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/humotion/*.h  include/humotion/client/*.h  include/humotion/server/*.h srv/*.srv msg/*.msg etc/*)
include/humotion/gaze_state.h
46 46
        float roll_offset;
47 47

  
48 48
        //pan,tilt,roll can be relative or absolute
49
        int type;
49
        int gaze_type;
50 50

  
51 51
        //when was this target requested?
52 52
        double timestamp;
53 53

  
54 54
        //is this relative or
55 55
        enum GAZE_STATE_TYPE{
56
            ABSOLUTE=0,
57
            RELATIVE=1,
58
            OVERRIDE=2
56
            GAZETYPE_ABSOLUTE=0,
57
            GAZETYPE_RELATIVE=1,
58
            GAZETYPE_OVERRIDE=2
59 59
        };
60 60

  
61 61
        //
msg/gaze.msg
1 1
Header header
2 2

  
3 3
#type of pan/tilt/roll targets
4
int32 type
5
int32 ABSOLUTE=0
6
int32 RELATIVE=1
4
int32 gaze_type
5
int32 GAZETYPE_ABSOLUTE=0
6
int32 GAZETYPE_RELATIVE=1
7 7

  
8 8
float32 pan
9 9
float32 tilt
src/client/middleware_ros.cpp
29 29

  
30 30
#ifdef ROS_SUPPORT
31 31

  
32
#include <humotion/mouth.h>
33
#include <humotion/gaze.h>
32
#include "humotion/mouth.h"
33
#include "humotion/gaze.h"
34 34
#include <boost/range/algorithm/remove_if.hpp>
35 35
#include <boost/algorithm/string/classification.hpp>
36 36

  
......
131 131
    msg.eyeblink_request_left = gaze_state.eyeblink_request_left;
132 132
    msg.eyeblink_request_right = gaze_state.eyeblink_request_right;
133 133

  
134
    if (gaze_state.type == GazeState::ABSOLUTE){
135
        msg.type = humotion::gaze::ABSOLUTE;
134
    if (gaze_state.gaze_type == GazeState::GAZETYPE_ABSOLUTE){
135
        msg.gaze_type = humotion::gaze::GAZETYPE_ABSOLUTE;
136 136
    }else{
137
        msg.type = humotion::gaze::RELATIVE;
137
        msg.gaze_type = humotion::gaze::GAZETYPE_RELATIVE;
138 138
    }
139 139

  
140 140
    //add position to send queue
src/gaze_state.cpp
45 45
    eyebrow_left   = -3.0;
46 46
    eyebrow_right  = 3.0;
47 47

  
48
    type = ABSOLUTE;
48
    gaze_type = GAZETYPE_ABSOLUTE;
49 49

  
50 50
    eyeblink_request_right = 0;
51 51
    eyeblink_request_left  = 0;
......
60 60
           pan, pan_offset, tilt, tilt_offset, roll, roll_offset, vergence,
61 61
           eyelid_opening_upper,eyelid_opening_lower,
62 62
           eyebrow_left, eyebrow_right,
63
           (type==ABSOLUTE?"absolute":(type==RELATIVE?"relative":(type==OVERRIDE?"override":"!INVALID!"))),
63
           (gaze_type==GAZETYPE_ABSOLUTE?"absolute":(gaze_type==GAZETYPE_RELATIVE?"relative":(gaze_type==GAZETYPE_OVERRIDE?"override":"!INVALID!"))),
64 64
           eyeblink_request_left, eyeblink_request_right
65 65
           );
66 66
}
src/server/controller.cpp
107 107
    double roll      = joint_interface->get_ts_position(JointInterface::ID_NECK_ROLL).get_interpolated_value(relative_target_timestamp);
108 108

  
109 109
    //build up absolute target:
110
    absolute_gaze.type  = GazeState::ABSOLUTE;
110
    absolute_gaze.gaze_type  = GazeState::GAZETYPE_ABSOLUTE;
111 111
    absolute_gaze.pan   = pan + relative.pan;
112 112
    absolute_gaze.tilt  = tilt + relative.tilt;
113 113
    absolute_gaze.roll  = roll + relative.roll;
......
137 137
    GazeState target_gaze;
138 138

  
139 139
    //relative or absolute gaze update?
140
    if (new_gaze_target.type == GazeState::RELATIVE){
140
    if (new_gaze_target.gaze_type == GazeState::GAZETYPE_RELATIVE){
141 141
        //relative gaze target -> calculate target angles
142 142
        target_gaze = relative_gaze_to_absolute_gaze(new_gaze_target);
143 143
    }else{
src/server/gaze_motion_generator.cpp
52 52
//! update gaze target:
53 53
//! \param GazeState with target values for the overall gaze
54 54
void GazeMotionGenerator::set_gaze_target(GazeState new_gaze_target){
55
    if (requested_gaze_state.type == GazeState::RELATIVE){
56
        //relative gaze target -> calculate target angle:
57
        printf("> FIXME: add code to interpolate the current position based on timestamp of gaze correction\n");
58
        exit(0);
55
    if (requested_gaze_state.gaze_type == GazeState::GAZETYPE_RELATIVE){
56
        printf("> ERROR: gaze targets should be converted to absolute before calling this\n");
57
        exit(EXIT_FAILURE);
59 58
    }
60 59

  
61 60
    //check magnitude of gaze change to detect eye-neck saccades:
src/server/middleware_ros.cpp
108 108
    GazeState gaze_state;
109 109
    ///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");
110 110

  
111
    gaze_state.type = msg->type;
112 111
    gaze_state.pan  = msg->pan;
113 112
    gaze_state.tilt = msg->tilt;
114 113
    gaze_state.roll = msg->roll;
......
127 126
    gaze_state.eyeblink_request_left = msg->eyeblink_request_left;
128 127
    gaze_state.eyeblink_request_right = msg->eyeblink_request_right;
129 128

  
129
    if (msg->gaze_type == humotion::gaze::GAZETYPE_ABSOLUTE){
130
        gaze_state.gaze_type = GazeState::GAZETYPE_ABSOLUTE;
131
    }else{
132
        gaze_state.gaze_type = GazeState::GAZETYPE_RELATIVE;
133
    }
130 134
    gaze_state.timestamp = convert_ros_to_timestamp_ms(msg->header.stamp);
131 135

  
132 136
    controller->set_gaze_target(gaze_state);
src/server/neck_motion_generator.cpp
181 181
    float max_speed = (CONST_GUITTON87_A * distance_abs + CONST_GUITTON87_B);
182 182

  
183 183
    //max accel: 	assuming linear acceleration we have
184
    // v ^
185
    //   |  / \
186
    //   | /   \
187
    //   |/_____\___> t
188
    //
184
    /* v ^
185
    *   |  / \
186
    *   | /   \
187
    *   |/_____\___> t
188
    */
189 189
    // d_total = 2 * 1/2 * a * (t_total/2)^2 = 1/4 * a * t_total^2
190 190
    // as we use linear accel we have
191 191
    // v_max = a * t_total/2  --> t_total = 2*v_max / a

Also available in: Unified diff