Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OLD CCF - The CeTI Cobotic Framework
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
CeTI
ROS
CeTI Cobotic Framework
OLD CCF - The CeTI Cobotic Framework
Commits
76650ff4
Commit
76650ff4
authored
3 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
add method for getting private parameters
parent
ae40e919
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
include/ccf/util/NodeUtil.h
+28
-0
28 additions, 0 deletions
include/ccf/util/NodeUtil.h
with
28 additions
and
0 deletions
include/ccf/util/NodeUtil.h
+
28
−
0
View file @
76650ff4
...
@@ -44,6 +44,34 @@ namespace CetiRosToolbox {
...
@@ -44,6 +44,34 @@ namespace CetiRosToolbox {
return
fallback
;
return
fallback
;
}
}
/// Gets a private parameter from the parameter server. If the parameter does not exist, the fallback is used.
/// If no fallback value is specified, an empty string is returned.
///
/// If the parameter is \a not on the parameter server, a warning is issued at \c ROS_WARN.
///
/// Usually, when using the method, the template parameter can be omitted if a fallback value is provided. This does
/// \a not work when providing \c const \c char* as fallback (i.e., string constants). In this case, the template
/// parameter must be provided:
/// \code{.cpp}
/// auto intValue1 = getParameter<int>(n, "foo"); // no fallback means no automatic matching
/// auto intValue2 = getParameter(n, "foo", 42); // the compiler matches T with int, this is okay
/// auto stringValue = getParameter<std::string>(n, "bar", "fourtytwo"); // const char* requires the std::string template parameter
/// \endcode
/// \tparam T a type supported by the parameter server.
/// The parameter server supports \c std::string double \c float \c int \c bool
/// and \c std::vector and \std::map of these types.
/// Additionally, also \c XmlRpc::XmlRpcValue is supported, though not as a vector or map.
/// \param key the name of the parameter
/// \param fallback the default value
/// \return the parameter (if it exists), otherwise the fallback value (if it exists), otherwise the default
/// instance of the respective object
/// \warning Currently, this is a header-only library, but this might change in the future
template
<
class
T
>
T
getPrivateParameter
(
const
std
::
string
&
key
,
T
fallback
=
T
())
{
ros
::
NodeHandle
n
(
"~"
);
// a private node handle
return
getParameter
(
n
,
key
,
fallback
);
}
/** @cond */
// the specializations are required to print the warning correctly
/** @cond */
// the specializations are required to print the warning correctly
template
<
>
template
<
>
XmlRpc
::
XmlRpcValue
getParameter
(
const
ros
::
NodeHandle
&
n
,
const
std
::
string
&
key
,
XmlRpc
::
XmlRpcValue
fallback
)
{
XmlRpc
::
XmlRpcValue
getParameter
(
const
ros
::
NodeHandle
&
n
,
const
std
::
string
&
key
,
XmlRpc
::
XmlRpcValue
fallback
)
{
...
...
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