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
0831e8af
Commit
0831e8af
authored
9 years ago
by
Ernesto Corbellini
Browse files
Options
Downloads
Patches
Plain Diff
Added heartbeat publishing in status topic.
Also added functions to create new result and feedback messages.
parent
1cf7e7ad
Branches
Branches containing commit
Tags
Tags containing commit
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/ActionServer.java
+36
-18
36 additions, 18 deletions
...ava/com/github/ekumen/rosjava_actionlib/ActionServer.java
with
36 additions
and
18 deletions
src/rosjava_actionlib/rosjava_actionlib/src/main/java/com/github/ekumen/rosjava_actionlib/ActionServer.java
+
36
−
18
View file @
0831e8af
...
...
@@ -8,6 +8,8 @@ import org.ros.node.topic.Publisher;
import
org.ros.message.MessageListener
;
import
org.ros.internal.message.Message
;
import
java.util.concurrent.TimeUnit
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
actionlib_msgs.GoalStatusArray
;
import
actionlib_msgs.GoalID
;
...
...
@@ -15,19 +17,20 @@ public class ActionServer<T_ACTION_GOAL extends Message,
T_ACTION_FEEDBACK
extends
Message
,
T_ACTION_RESULT
extends
Message
>
{
T_ACTION_GOAL
actionGoal
;
String
actionGoalType
;
String
actionResultType
;
String
actionFeedbackType
;
Subscriber
<
T_ACTION_GOAL
>
goalSuscriber
=
null
;
Subscriber
<
GoalID
>
cancelSuscriber
=
null
;
Publisher
<
T_ACTION_RESULT
>
resultPublisher
=
null
;
Publisher
<
T_ACTION_FEEDBACK
>
feedbackPublisher
=
null
;
Publisher
<
GoalStatusArray
>
statusPublisher
=
null
;
ConnectedNode
node
=
null
;
String
actionName
;
ActionServerListener
callbackTarget
=
null
;
private
T_ACTION_GOAL
actionGoal
;
private
String
actionGoalType
;
private
String
actionResultType
;
private
String
actionFeedbackType
;
private
Subscriber
<
T_ACTION_GOAL
>
goalSuscriber
=
null
;
private
Subscriber
<
GoalID
>
cancelSuscriber
=
null
;
private
Publisher
<
T_ACTION_RESULT
>
resultPublisher
=
null
;
private
Publisher
<
T_ACTION_FEEDBACK
>
feedbackPublisher
=
null
;
private
Publisher
<
GoalStatusArray
>
statusPublisher
=
null
;
private
ConnectedNode
node
=
null
;
private
String
actionName
;
private
ActionServerListener
callbackTarget
=
null
;
private
Timer
statusTick
=
new
Timer
();
ActionServer
(
ConnectedNode
node
,
String
actionName
,
String
actionGoalType
,
String
actionFeedbackType
,
String
actionResultType
)
{
...
...
@@ -60,6 +63,12 @@ public class ActionServer<T_ACTION_GOAL extends Message,
statusPublisher
=
node
.
newPublisher
(
actionName
+
"/status"
,
GoalStatusArray
.
_TYPE
);
feedbackPublisher
=
node
.
newPublisher
(
actionName
+
"/feedback"
,
actionFeedbackType
);
resultPublisher
=
node
.
newPublisher
(
actionName
+
"/result"
,
actionResultType
);
statusTick
.
scheduleAtFixedRate
(
new
TimerTask
()
{
@Override
public
void
run
()
{
sendStatusTick
();
}
},
2000
,
1000
);
}
private
void
unpublishServer
()
{
...
...
@@ -77,10 +86,6 @@ public class ActionServer<T_ACTION_GOAL extends Message,
}
}
/*public T_ACTION_GOAL newGoalMessage() {
return goalPublisher.newMessage();
}*/
private
void
subscribeToClient
(
ConnectedNode
node
)
{
goalSuscriber
=
node
.
newSubscriber
(
actionName
+
"/goal"
,
actionGoalType
);
cancelSuscriber
=
node
.
newSubscriber
(
actionName
+
"/cancel"
,
GoalID
.
_TYPE
);
...
...
@@ -125,6 +130,19 @@ public class ActionServer<T_ACTION_GOAL extends Message,
}
}
public
void
sendStatusTick
()
{
GoalStatusArray
status
=
statusPublisher
.
newMessage
();
sendStatus
(
status
);
}
public
T_ACTION_RESULT
newResultMessage
()
{
return
resultPublisher
.
newMessage
();
}
public
T_ACTION_FEEDBACK
newFeedbackMessage
()
{
return
feedbackPublisher
.
newMessage
();
}
/**
* Publishes the server's topics and suscribes to the client's topics.
*/
...
...
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