Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rosjava_actionlib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Ebert
rosjava_actionlib
Commits
6e967a1d
Commit
6e967a1d
authored
9 years ago
by
Ernesto Corbellini
Browse files
Options
Downloads
Patches
Plain Diff
Added timeout to the wait for server.
parent
16e33d40
Branches
master
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/rosjava_actionlib/rosjava_actionlib/src/main/java/com/github/ekumen/rosjava_actionlib/ActionClient.java
+27
-2
27 additions, 2 deletions
...ava/com/github/ekumen/rosjava_actionlib/ActionClient.java
with
27 additions
and
2 deletions
src/rosjava_actionlib/rosjava_actionlib/src/main/java/com/github/ekumen/rosjava_actionlib/ActionClient.java
+
27
−
2
View file @
6e967a1d
...
@@ -25,6 +25,8 @@ import org.ros.node.topic.SubscriberListener;
...
@@ -25,6 +25,8 @@ import org.ros.node.topic.SubscriberListener;
import
org.ros.internal.node.topic.PublisherIdentifier
;
import
org.ros.internal.node.topic.PublisherIdentifier
;
import
org.ros.node.topic.DefaultSubscriberListener
;
import
org.ros.node.topic.DefaultSubscriberListener
;
import
org.ros.message.MessageListener
;
import
org.ros.message.MessageListener
;
import
org.ros.message.Duration
;
import
org.ros.message.Time
;
import
org.ros.internal.message.Message
;
import
org.ros.internal.message.Message
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.List
;
import
java.util.List
;
...
@@ -332,20 +334,37 @@ public class ActionClient<T_ACTION_GOAL extends Message,
...
@@ -332,20 +334,37 @@ public class ActionClient<T_ACTION_GOAL extends Message,
/**
/**
* Wait for an actionlib server to connect.
* Wait for an actionlib server to connect.
* @param timeout The maximum amount of time to wait for an action server. If
* this value is less than or equal to zero, it will wait forever until a
* server is detected.
* @return True if the action server was detected before the timeout and
* false otherwise.
*/
*/
public
boolean
waitForActionServerToStart
()
{
public
boolean
waitForActionServerToStart
(
Duration
timeout
)
{
boolean
res
=
false
;
boolean
res
=
false
;
boolean
gotTime
=
true
;
Time
finalTime
=
node
.
getCurrentTime
().
add
(
timeout
);
while
(!
res
)
{
while
(!
res
&&
gotTime
)
{
res
=
goalPublisher
.
hasSubscribers
()
&&
res
=
goalPublisher
.
hasSubscribers
()
&&
cancelPublisher
.
hasSubscribers
()
&&
cancelPublisher
.
hasSubscribers
()
&&
feedbackPublisherFlag
&&
feedbackPublisherFlag
&&
resultPublisherFlag
&&
resultPublisherFlag
&&
statusReceivedFlag
;
statusReceivedFlag
;
if
(
timeout
.
isPositive
())
{
gotTime
=
(
node
.
getCurrentTime
().
compareTo
(
finalTime
)
<
0
);
}
}
}
return
res
;
return
res
;
}
}
/**
* Wait indefinately until an actionlib server is connected.
*/
public
void
waitForActionServerToStart
()
{
waitForActionServerToStart
(
new
Duration
(
0
));
}
@Override
@Override
public
void
onNewPublisher
(
Subscriber
subscriber
,
PublisherIdentifier
publisherIdentifier
)
{
public
void
onNewPublisher
(
Subscriber
subscriber
,
PublisherIdentifier
publisherIdentifier
)
{
//public void onNewFeedbackPublisher(Subscriber<T_ACTION_FEEDBACK> subscriber, PublisherIdentifier publisherIdentifier) {
//public void onNewFeedbackPublisher(Subscriber<T_ACTION_FEEDBACK> subscriber, PublisherIdentifier publisherIdentifier) {
...
@@ -360,9 +379,15 @@ public class ActionClient<T_ACTION_GOAL extends Message,
...
@@ -360,9 +379,15 @@ public class ActionClient<T_ACTION_GOAL extends Message,
}
}
}
}
/**
* Get the current state of the action goal as being tracked by the client.
* @return The state of the goal.
* @see ClientStateMachine.ClientStates
*/
public
int
getGoalState
()
{
public
int
getGoalState
()
{
return
goalManager
.
getGoalState
();
return
goalManager
.
getGoalState
();
}
}
/**
/**
* Finish the action client. Unregister publishers and listeners.
* Finish the action client. Unregister publishers and listeners.
*/
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment