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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Ebert
rosjava_actionlib
Commits
4e616144
Commit
4e616144
authored
9 years ago
by
Ernesto Corbellini
Browse files
Options
Downloads
Patches
Plain Diff
Added finish function for the client.
parent
1da83d81
Branches
Branches containing commit
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
+28
-4
28 additions, 4 deletions
...ava/com/github/ekumen/rosjava_actionlib/ActionClient.java
with
28 additions
and
4 deletions
src/rosjava_actionlib/rosjava_actionlib/src/main/java/com/github/ekumen/rosjava_actionlib/ActionClient.java
+
28
−
4
View file @
4e616144
...
...
@@ -8,6 +8,7 @@ import org.ros.node.topic.Subscriber;
import
org.ros.node.topic.Publisher
;
import
org.ros.message.MessageListener
;
import
org.ros.internal.message.Message
;
import
java.util.concurrent.TimeUnit
;
public
class
ActionClient
<
T_ACTION_GOAL
extends
Message
,
T_ACTION_FEEDBACK
extends
Message
,
...
...
@@ -17,12 +18,12 @@ public class ActionClient<T_ACTION_GOAL extends Message,
String
actionGoalType
;
String
actionResultType
;
String
actionFeedbackType
;
Publisher
<
T_ACTION_GOAL
>
goalPublisher
;
Publisher
<
T_ACTION_GOAL
>
goalPublisher
=
null
;
//Publisher<actionlib_msgs.cancel> clientCancel;
//Suscriber<actionlib_msgs.status> serverStatus;
Subscriber
<
T_ACTION_RESULT
>
serverResult
;
Subscriber
<
T_ACTION_FEEDBACK
>
serverFeedback
;
ConnectedNode
node
;
Subscriber
<
T_ACTION_RESULT
>
serverResult
=
null
;
Subscriber
<
T_ACTION_FEEDBACK
>
serverFeedback
=
null
;
ConnectedNode
node
=
null
;
String
actionName
;
ActionClientListener
callbackTarget
=
null
;
...
...
@@ -51,6 +52,12 @@ public class ActionClient<T_ACTION_GOAL extends Message,
// actionlib_msgs.cancel._TYPE);
}
private
void
unpublishClient
()
{
if
(
goalPublisher
!=
null
)
{
goalPublisher
.
shutdown
(
5
,
TimeUnit
.
SECONDS
);
}
}
public
T_ACTION_GOAL
newGoalMessage
()
{
return
goalPublisher
.
newMessage
();
}
...
...
@@ -86,6 +93,15 @@ public class ActionClient<T_ACTION_GOAL extends Message,
actionlib_tutorials.FibonacciActionFeedback._TYPE);*/
}
private
void
unsubscribeToServer
()
{
if
(
serverFeedback
!=
null
)
{
serverFeedback
.
shutdown
(
5
,
TimeUnit
.
SECONDS
);
}
if
(
serverResult
!=
null
)
{
serverResult
.
shutdown
(
5
,
TimeUnit
.
SECONDS
);
}
}
public
void
gotResult
(
T_ACTION_RESULT
message
)
{
// Propagate the callback
if
(
callbackTarget
!=
null
)
{
...
...
@@ -108,4 +124,12 @@ public class ActionClient<T_ACTION_GOAL extends Message,
subscribeToServer
(
node
);
}
/**
* Finish the action client. Unregister publishers and listeners.
*/
public
void
finish
()
{
callbackTarget
=
null
;
unpublishClient
();
unsubscribeToServer
();
}
}
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