Revision 62aeb8ce

View differences:

client/cpp/examples/random_gaze/main.cpp
57 57
			gaze.roll = 0.0;
58 58
			gaze.vergence = 0.0;
59 59

  
60
            //absolute mode
61
            gaze.type = RobotGaze::ABSOLUTE;
62
            gaze.timestamp = RobotGaze::now();
63

  
60 64
            //robot_controller->set_current_emotion(RobotEmotion(RobotEmotion::ANGRY));
61 65

  
62 66
			//reset counter
client/cpp/include/RobotGaze.h
27 27
*/
28 28

  
29 29
#pragma once
30
#include <time.h>
31

  
30 32
class RobotGaze{
31 33
public:
32 34
    RobotGaze(){
......
36 38
        vergence = 0.0;
37 39
        pan_offset = 0.0;
38 40
        tilt_offset = 0.0;
41
        type = ABSOLUTE;
39 42
    }
40 43

  
44
    static double now(){
45
        //fetch time
46
        struct timespec tp;
47
        clock_gettime(CLOCK_REALTIME, &tp);
48
        return tp.tv_sec+tp.tv_nsec/1000000000.0;
49
    };
50

  
51
    enum {
52
        RELATIVE = 0,
53
        ABSOLUTE = 1
54
    };
55

  
56
    double timestamp;
57

  
58
    int type;
59

  
41 60
    float pan, tilt, roll, vergence;
42 61
    float pan_offset, tilt_offset;
43 62
};
client/cpp/src/MiddlewareROS.cpp
153 153
    goal.tilt_offset = target.tilt_offset;
154 154
    goal.pan_offset = target.pan_offset;
155 155

  
156
    //timestamp:
157
    //ts = t.sec + t.nsec/1000000000.0;
158
    uint32_t sec  = (uint32_t) target.timestamp;
159
    uint32_t nsec = (uint32_t)((target.timestamp - sec)*1000000000);
160
    goal.timestamp = ros::Time(sec, nsec);
161

  
162
    if (target.type == RobotGaze::ABSOLUTE){
163
        goal.gaze_type = hlrc_server::gazetargetGoal::GAZETARGET_ABSOLUTE;
164
    }else{
165
        goal.gaze_type = hlrc_server::gazetargetGoal::GAZETARGET_RELATIVE;
166
    }
167

  
156 168
    //send
157 169
    gazetarget_ac->sendGoal(goal);
158 170

  
server/action/gazetarget.action
17 17
#relative or absolute gaze target?
18 18
uint8 GAZETARGET_RELATIVE  = 0
19 19
uint8 GAZETARGET_ABSOLUTE  = 0
20
uint8 type
20
uint8 gaze_type
21 21

  
22 22
#timestamp of the target (important in case of relative targets)
23 23
time timestamp
server/include/ROS/GazeCallbackWrapperROS.h
63 63

  
64 64
        //use timestamp from request
65 65
        gaze_state.timestamp = convert_ros_to_timestamp_ms(request->timestamp); //get_timestamp();
66
        if (request->type == hlrc_server::gazetargetGoal::GAZETARGET_RELATIVE){
67
            gaze_state.type = humotion::GazeState::RELATIVE;
68
        }else{
66
        if (request->gaze_type == hlrc_server::gazetargetGoal::GAZETARGET_ABSOLUTE){
69 67
            gaze_state.type = humotion::GazeState::ABSOLUTE;
68
        }else{
69
            gaze_state.type = humotion::GazeState::RELATIVE;
70 70
        }
71 71

  
72 72
        //default:

Also available in: Unified diff