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
b21bdcfd
Commit
b21bdcfd
authored
9 years ago
by
Ernesto Corbellini
Browse files
Options
Downloads
Patches
Plain Diff
Added goal tracker to the server.
parent
5d7186b6
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
+32
-5
32 additions, 5 deletions
...ava/com/github/ekumen/rosjava_actionlib/ActionServer.java
with
32 additions
and
5 deletions
src/rosjava_actionlib/rosjava_actionlib/src/main/java/com/github/ekumen/rosjava_actionlib/ActionServer.java
+
32
−
5
View file @
b21bdcfd
...
...
@@ -10,6 +10,8 @@ import org.ros.internal.message.Message;
import
java.util.concurrent.TimeUnit
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.HashMap
;
import
java.lang.reflect.Method
;
import
actionlib_msgs.GoalStatusArray
;
import
actionlib_msgs.GoalID
;
...
...
@@ -17,6 +19,15 @@ public class ActionServer<T_ACTION_GOAL extends Message,
T_ACTION_FEEDBACK
extends
Message
,
T_ACTION_RESULT
extends
Message
>
{
private
class
ServerGoal
{
T_ACTION_GOAL
goal
;
ServerStateMachine
state
=
new
ServerStateMachine
();
ServerGoal
(
T_ACTION_GOAL
g
)
{
goal
=
g
;
}
}
private
T_ACTION_GOAL
actionGoal
;
private
String
actionGoalType
;
private
String
actionResultType
;
...
...
@@ -31,6 +42,8 @@ public class ActionServer<T_ACTION_GOAL extends Message,
private
String
actionName
;
private
ActionServerListener
callbackTarget
=
null
;
private
Timer
statusTick
=
new
Timer
();
private
HashMap
<
String
,
ServerGoal
>
goalTracker
=
new
HashMap
<
String
,
ServerGoal
>(
1
);
ActionServer
(
ConnectedNode
node
,
String
actionName
,
String
actionGoalType
,
String
actionFeedbackType
,
String
actionResultType
)
{
...
...
@@ -116,17 +129,18 @@ public class ActionServer<T_ACTION_GOAL extends Message,
}
}
public
void
gotGoal
(
T_ACTION_GOAL
message
)
{
public
void
gotGoal
(
T_ACTION_GOAL
goal
)
{
goalTracker
.
put
(
getGoalId
(
goal
).
getId
(),
new
ServerGoal
(
goal
));
// Propagate the callback
if
(
callbackTarget
!=
null
)
{
callbackTarget
.
goalReceived
(
message
);
callbackTarget
.
goalReceived
(
goal
);
}
}
public
void
gotCancel
(
GoalID
message
)
{
public
void
gotCancel
(
GoalID
gid
)
{
// Propagate the callback
if
(
callbackTarget
!=
null
)
{
callbackTarget
.
cancelReceived
(
message
);
callbackTarget
.
cancelReceived
(
gid
);
}
}
...
...
@@ -143,6 +157,19 @@ public class ActionServer<T_ACTION_GOAL extends Message,
return
feedbackPublisher
.
newMessage
();
}
public
GoalID
getGoalId
(
T_ACTION_GOAL
goal
)
{
GoalID
gid
=
null
;
try
{
Method
m
=
goal
.
getClass
().
getMethod
(
"getGoalId"
);
m
.
setAccessible
(
true
);
// workaround for known bug http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6924232
gid
=
(
GoalID
)
m
.
invoke
(
goal
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
System
.
out
);
}
return
gid
;
}
/**
* 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