File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Assets/UnitySensorsROS/Runtime/Scripts Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -28,18 +28,28 @@ public void Init(string frame_id)
28
28
{
29
29
_header = new HeaderMsg ( ) ;
30
30
_header . frame_id = frame_id ;
31
+ #if ROS2
32
+ #else
31
33
_header . seq = 0 ;
34
+ #endif
32
35
}
33
36
34
37
/// <summary>
35
38
/// シリアライズ関数
36
39
/// </summary>
37
40
public void Serialize ( float time )
38
41
{
42
+ #if ROS2
43
+ int sec = ( int ) Math . Truncate ( time ) ;
44
+ #else
39
45
uint sec = ( uint ) Math . Truncate ( time ) ;
46
+ # endif
40
47
_header . stamp . sec = sec ;
41
48
_header . stamp . nanosec = ( uint ) ( ( time - sec ) * 1e+9 ) ;
49
+ #if ROS2
50
+ #else
42
51
_header . seq ++ ;
52
+ #endif
43
53
}
44
54
}
45
55
}
Original file line number Diff line number Diff line change @@ -28,7 +28,11 @@ void Start()
28
28
void Update ( )
29
29
{
30
30
float time = Time . time ;
31
+ #if ROS2
32
+ int sec = ( int ) Math . Truncate ( time ) ;
33
+ #else
31
34
uint sec = ( uint ) Math . Truncate ( time ) ;
35
+ # endif
32
36
uint nanosec = ( uint ) ( ( time - sec ) * 1e+9 ) ;
33
37
_message . clock . sec = sec ;
34
38
_message . clock . nanosec = nanosec ;
You can’t perform that action at this time.
0 commit comments