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
e22cc28e
Commit
e22cc28e
authored
9 years ago
by
Ernesto Corbellini
Browse files
Options
Downloads
Patches
Plain Diff
Added goal ID generator class.
parent
856d7f58
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/GoalIDGenerator.java
+82
-0
82 additions, 0 deletions
.../com/github/ekumen/rosjava_actionlib/GoalIDGenerator.java
with
82 additions
and
0 deletions
src/rosjava_actionlib/rosjava_actionlib/src/main/java/com/github/ekumen/rosjava_actionlib/GoalIDGenerator.java
0 → 100644
+
82
−
0
View file @
e22cc28e
/*
* Copyright (C) 2011 Alexander Perzylo, Technische Universität München
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package
com.github.ekumen.rosjava_actionlib
;
import
org.ros.message.Time
;
import
actionlib_msgs.GoalID
;
import
org.ros.node.ConnectedNode
;
import
org.ros.node.NodeConfiguration
;
import
org.ros.message.MessageFactory
;
import
java.util.concurrent.atomic.AtomicLong
;
/**
* The GoalIDGenerator may be used to create unique GoalIDs.
*
* <p>
* The node's nodeName will be used and the time on the node.
*
* @author Alexander C. Perzylo, perzylo@cs.tum.edu
*/
public
class
GoalIDGenerator
{
/**
* A global ID which provide a count for each goal id.
*/
private
static
AtomicLong
goalCount
=
new
AtomicLong
(
0
);
/**
* Unique nodeName to prepend to the goal id. This will generally be a fully
* qualified node nodeName.
*/
private
ConnectedNode
node
;
/**
* Constructor to create a GoalIDGenerator using a unique nodeName to prepend to
* the goal id. This will generally be a fully qualified node nodeName.
*
* @param node
* The node used to generate IDs. The node's full nodeName should be
* unique in the system.
*/
public
GoalIDGenerator
(
ConnectedNode
node
)
{
this
.
node
=
node
;
}
/**
* Creates a GoalID object with an unique id and a timestamp of the current
* time.
*
* @return GoalID object
*/
public
String
generateID
(
ConnectedNode
node
,
GoalID
goal
)
{
String
id
;
Time
t
=
node
.
getCurrentTime
();
//NodeConfiguration nc = NodeConfiguration.newPrivate();
//MessageFactory mf = nc.getTopicMessageFactory();
//GoalID id = mf.newFromType(GoalID._TYPE);
//StringBuilder sb = new StringBuilder(node.getName().toString());
//sb.append("-").append(goalCount.incrementAndGet()).append("-").append(t.secs).append(".").append(t.nsecs);
id
=
node
.
getName
().
toString
()
+
"-"
+
goalCount
.
incrementAndGet
()
+
"-"
+
t
.
secs
+
"."
+
t
.
nsecs
;
goal
.
setId
(
id
);
goal
.
setStamp
(
t
);
return
id
;
}
}
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