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
0d830274
Commit
0d830274
authored
Dec 2, 2015
by
Ernesto Corbellini
Browse files
Options
Downloads
Patches
Plain Diff
First tests of the client.
Publishing a goal and suscribing to the result using the Fibonacci example.
parent
2c956a78
No related branches found
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
+79
-7
79 additions, 7 deletions
...ava/com/github/ekumen/rosjava_actionlib/ActionClient.java
with
79 additions
and
7 deletions
src/rosjava_actionlib/rosjava_actionlib/src/main/java/com/github/ekumen/rosjava_actionlib/ActionClient.java
+
79
−
7
View file @
0d830274
public
class
ActionClient
{
private
void
publishClient
()
{
package
com.github.ekumen.rosjava_actionlib
;
import
org.ros.namespace.GraphName
;
import
org.ros.node.AbstractNodeMain
;
import
org.ros.node.ConnectedNode
;
import
org.ros.node.topic.Subscriber
;
import
org.ros.node.topic.Publisher
;
import
org.ros.message.MessageListener
;
public
class
ActionClient
extends
AbstractNodeMain
{
//actionlib_tutorials.FibonacciActionGoal actionGoal;
Publisher
<
actionlib_tutorials
.
FibonacciActionGoal
>
clientGoal
;
//Publisher<actionlib_msgs.cancel> clientCancel;
//Suscriber<actionlib_msgs.status> serverStatus;
Subscriber
<
actionlib_tutorials
.
FibonacciActionResult
>
serverResult
;
//Suscriber<actionlib_tutorials.FibonacciActionFeedback> serverFeedback;
private
void
publishClient
(
ConnectedNode
node
)
{
clientGoal
=
node
.
newPublisher
(
"fibonacci/goal"
,
actionlib_tutorials
.
FibonacciActionGoal
.
_TYPE
);
//clientCancel = connectedNode.newPublisher("fibonacci/cancel",
// actionlib_msgs.cancel._TYPE);
}
private
void
suscribeServer
()
{
private
void
suscribeServer
(
ConnectedNode
node
)
{
serverResult
=
node
.
newSubscriber
(
"fibonacci/result"
,
actionlib_tutorials
.
FibonacciActionResult
.
_TYPE
);
serverResult
.
addMessageListener
(
new
MessageListener
<
actionlib_tutorials
.
FibonacciActionResult
>()
{
@Override
public
void
onNewMessage
(
actionlib_tutorials
.
FibonacciActionResult
message
)
{
gotResult
(
message
);
}
});
/*serverStatus = node.newSubscriber("fibonacci/status",
actionlib_msgs.status._TYPE);
serverFeedback = node.newSubscriber("fibonacci/feedback",
actionlib_tutorials.FibonacciActionFeedback._TYPE);*/
}
public
void
gotResult
(
actionlib_tutorials
.
FibonacciActionResult
message
)
{
actionlib_tutorials
.
FibonacciResult
result
=
message
.
getResult
();
int
[]
sequence
=
result
.
getSequence
();
int
i
;
System
.
out
.
print
(
"Got Fibonacci result sequence! "
);
for
(
i
=
0
;
i
<
sequence
.
length
;
i
++)
System
.
out
.
print
(
Integer
.
toString
(
sequence
[
i
])
+
" "
);
System
.
out
.
print
(
"\n"
);
}
/**
* Publishes the client's topics and suscribes to the server's topics.
*/
public
void
connect
()
{
publishClient
();
suscribeServer
();
public
void
connect
(
ConnectedNode
node
)
{
publishClient
(
node
);
//suscribeServer(node);
}
@Override
public
GraphName
getDefaultNodeName
()
{
return
GraphName
.
of
(
"fibonacci_client"
);
}
@Override
public
void
onStart
(
ConnectedNode
node
)
{
connect
(
node
);
suscribeServer
(
node
);
// publish a goal message
actionlib_tutorials
.
FibonacciActionGoal
goalMessage
=
clientGoal
.
newMessage
();
actionlib_tutorials
.
FibonacciGoal
fibonacciGoal
=
goalMessage
.
getGoal
();
// set Fibonacci parameter
fibonacciGoal
.
setOrder
(
6
);
goalMessage
.
setGoal
(
fibonacciGoal
);
while
(
true
)
{
clientGoal
.
publish
(
goalMessage
);
try
{
Thread
.
sleep
(
10000
);
}
catch
(
InterruptedException
ex
)
{
;
}
}
}
}
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