Revision 8db9ba4f
include/humotion/timestamp.h | ||
---|---|---|
37 | 37 |
public: |
38 | 38 |
Timestamp(void); |
39 | 39 |
Timestamp(int32_t _sec, int32_t _nsec); |
40 |
Timestamp(double dsec); |
|
41 |
|
|
40 | 42 |
void set(int32_t _sec, int32_t _nsec); |
43 |
void set(Timestamp a); |
|
44 |
|
|
45 |
static Timestamp now(void); |
|
41 | 46 |
|
42 | 47 |
double to_seconds(void); |
43 | 48 |
|
src/server/middleware_rsb.cpp | ||
---|---|---|
46 | 46 |
using namespace rsb; |
47 | 47 |
using namespace rsb::patterns; |
48 | 48 |
|
49 |
WARNING: RSB interface might be deprtecated and needs some backporting |
|
50 |
from the ROS code. [todo] |
|
51 |
|
|
49 | 52 |
//! constructor |
50 | 53 |
MiddlewareRSB::MiddlewareRSB(string scope, Controller *c) : Middleware(scope, c){ |
51 | 54 |
printf("> using RSB middleware\n"); |
... | ... | |
114 | 117 |
|
115 | 118 |
GazeState gaze_state; |
116 | 119 |
|
117 |
if (msg->type() == rst::robot::HumotionGazeTarget::ABSOLUTE){ |
|
118 |
gaze_state.type = GazeState::ABSOLUTE; |
|
120 |
if (msg->gaze_type() == rst::robot::HumotionGazeTarget::ABSOLUTE){
|
|
121 |
gaze_state.gaze_type = GazeState::ABSOLUTE;
|
|
119 | 122 |
}else{ |
120 |
gaze_state.type = GazeState::RELATIVE; |
|
123 |
gaze_state.gaze_type = GazeState::RELATIVE;
|
|
121 | 124 |
} |
122 | 125 |
|
123 | 126 |
gaze_state.pan = msg->pan(); |
... | ... | |
138 | 141 |
gaze_state.eyeblink_request_left = msg->eyeblink_request_left(); |
139 | 142 |
gaze_state.eyeblink_request_right = msg->eyeblink_request_right(); |
140 | 143 |
|
141 |
gaze_state.timestamp = event->getMetaData().getCreateTime() / 1000.0; //createTime() returns milliseconds -> convert to seconds |
|
144 |
gaze_state.timestamp = msg->gaze_timestamp(); FIXME: convert RSB timestamp to our representation |
|
145 |
//event->getMetaData().getCreateTime() / 1000.0; //createTime() returns milliseconds -> convert to seconds |
|
142 | 146 |
|
143 | 147 |
controller->set_gaze_target(gaze_state); |
144 | 148 |
} |
src/timestamp.cpp | ||
---|---|---|
1 | 1 |
#include "timestamp.h" |
2 |
#include <math.h> |
|
2 | 3 |
|
3 | 4 |
using namespace std; |
4 | 5 |
using namespace humotion; |
5 | 6 |
|
6 | 7 |
Timestamp::Timestamp(void){ |
7 | 8 |
//init of an empty timestamp will be assigned to the current system time |
8 |
struct timespec tp; |
|
9 |
clock_gettime(CLOCK_REALTIME, &tp); |
|
10 |
sec = tp.tv_sec; |
|
11 |
nsec = tp.tv_nsec; |
|
9 |
set(now()); |
|
12 | 10 |
} |
13 | 11 |
|
14 | 12 |
Timestamp::Timestamp(int32_t _sec, int32_t _nsec){ |
15 | 13 |
set(_sec, _nsec); |
16 | 14 |
} |
17 | 15 |
|
16 |
Timestamp::Timestamp(double dsec){ |
|
17 |
double fsec, fnsec; |
|
18 |
fnsec = modf (dsec , &fsec); |
|
19 |
sec = fsec; |
|
20 |
nsec = fnsec * 1000000000.0; |
|
21 |
} |
|
22 |
|
|
23 |
Timestamp Timestamp::now(void){ |
|
24 |
Timestamp res; |
|
25 |
struct timespec tp; |
|
26 |
clock_gettime(CLOCK_REALTIME, &tp); |
|
27 |
res.set(tp.tv_sec, tp.tv_nsec); |
|
28 |
return res; |
|
29 |
} |
|
30 |
|
|
18 | 31 |
void Timestamp::set(int32_t _sec, int32_t _nsec){ |
19 | 32 |
sec = _sec; |
20 | 33 |
nsec = _nsec; |
21 | 34 |
} |
22 | 35 |
|
36 |
void Timestamp::set(Timestamp a){ |
|
37 |
set(a.sec, a.nsec); |
|
38 |
} |
|
39 |
|
|
23 | 40 |
double Timestamp::to_seconds(void){ |
24 | 41 |
return sec + ((double)nsec)/1000000000.0; |
25 | 42 |
} |
Also available in: Unified diff