Skip to content

Commit 1b59765

Browse files
committed
Support wall-time and ROS-time timers (osrf#39)
* Support wall-time and ROS-time timers Add a new method to Node for creating ROS timers. Refactor timer implementation to account for the two different types of timers. Deprecate WallTimer interface and WallTimerImpl and replace with unified Timer interface and TimerImpl. Signed-off-by: Jacob Perron <[email protected]> * Add test Signed-off-by: Jacob Perron <[email protected]> * Log error if failed to dispose timer Signed-off-by: Jacob Perron <[email protected]>
1 parent 4f279ce commit 1b59765

File tree

12 files changed

+407
-297
lines changed

12 files changed

+407
-297
lines changed

rcljava/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ set(${PROJECT_NAME}_jni_sources
7575
"src/main/cpp/org_ros2_rcljava_subscription_statuses_RequestedDeadlineMissed.cpp"
7676
"src/main/cpp/org_ros2_rcljava_subscription_statuses_RequestedQosIncompatible.cpp"
7777
"src/main/cpp/org_ros2_rcljava_time_Clock.cpp"
78-
"src/main/cpp/org_ros2_rcljava_timer_WallTimerImpl.cpp"
78+
"src/main/cpp/org_ros2_rcljava_timer_TimerImpl.cpp"
7979
)
8080

8181
foreach(_jni_source ${${PROJECT_NAME}_jni_sources})
@@ -193,6 +193,7 @@ set(${PROJECT_NAME}_sources
193193
"src/main/java/org/ros2/rcljava/time/ClockType.java"
194194
"src/main/java/org/ros2/rcljava/time/TimeSource.java"
195195
"src/main/java/org/ros2/rcljava/timer/Timer.java"
196+
"src/main/java/org/ros2/rcljava/timer/TimerImpl.java"
196197
"src/main/java/org/ros2/rcljava/timer/WallTimer.java"
197198
"src/main/java/org/ros2/rcljava/timer/WallTimerImpl.java"
198199
)
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Copyright 2017-2018 Esteve Fernandez <[email protected]>
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <jni.h>
16+
/* Header for class org_ros2_rcljava_timer_TimerImpl */
17+
18+
#ifndef ORG_ROS2_RCLJAVA_TIMER_TIMERIMPL_H_
19+
#define ORG_ROS2_RCLJAVA_TIMER_TIMERIMPL_H_
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
/*
25+
* Class: org_ros2_rcljava_timer_TimerImpl
26+
* Method: nativeDispose
27+
* Signature: (J)V
28+
*/
29+
JNIEXPORT void
30+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeDispose(JNIEnv *, jclass, jlong);
31+
32+
/*
33+
* Class: org_ros2_rcljava_timer_TimerImpl
34+
* Method: nativeIsReady
35+
* Signature: (J)Z
36+
*/
37+
JNIEXPORT jboolean
38+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeIsReady(JNIEnv *, jclass, jlong);
39+
40+
/*
41+
* Class: org_ros2_rcljava_timer_TimerImpl
42+
* Method: nativeIsCanceled
43+
* Signature: (J)Z
44+
*/
45+
JNIEXPORT jboolean
46+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeIsCanceled(JNIEnv *, jclass, jlong);
47+
48+
/*
49+
* Class: org_ros2_rcljava_timer_TimerImpl
50+
* Method: nativeReset
51+
* Signature: (J)Z
52+
*/
53+
JNIEXPORT void
54+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeReset(JNIEnv *, jclass, jlong);
55+
56+
/*
57+
* Class: org_ros2_rcljava_timer_TimerImpl
58+
* Method: nativeCancel
59+
* Signature: (J)Z
60+
*/
61+
JNIEXPORT void
62+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeCancel(JNIEnv *, jclass, jlong);
63+
64+
/*
65+
* Class: org_ros2_rcljava_timer_TimerImpl
66+
* Method: nativeTimeUntilNextCall
67+
* Signature: (J)J
68+
*/
69+
JNIEXPORT jlong
70+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeTimeUntilNextCall(JNIEnv *, jclass, jlong);
71+
72+
/*
73+
* Class: org_ros2_rcljava_timer_TimerImpl
74+
* Method: nativeTimeSinceLastCall
75+
* Signature: (J)J
76+
*/
77+
JNIEXPORT jlong
78+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeTimeSinceLastCall(JNIEnv *, jclass, jlong);
79+
80+
/*
81+
* Class: org_ros2_rcljava_timer_TimerImpl
82+
* Method: nativeGetTimerPeriodNS
83+
* Signature: (J)J
84+
*/
85+
JNIEXPORT jlong
86+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeGetTimerPeriodNS(JNIEnv *, jclass, jlong);
87+
88+
/*
89+
* Class: org_ros2_rcljava_timer_TimerImpl
90+
* Method: nativeSetTimerPeriodNS
91+
* Signature: (JJ)Z
92+
*/
93+
JNIEXPORT void
94+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeSetTimerPeriodNS(
95+
JNIEnv *, jclass, jlong, jlong);
96+
97+
/*
98+
* Class: org_ros2_rcljava_timer_TimerImpl
99+
* Method: nativeCallTimer
100+
* Signature: (J)Z
101+
*/
102+
JNIEXPORT void
103+
JNICALL Java_org_ros2_rcljava_timer_TimerImpl_nativeCallTimer(JNIEnv *, jclass, jlong);
104+
105+
#ifdef __cplusplus
106+
}
107+
#endif
108+
#endif // ORG_ROS2_RCLJAVA_TIMER_TIMERIMPL_H_

rcljava/include/org_ros2_rcljava_timer_WallTimerImpl.h

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)