Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Hofmann
RobotAPI
Commits
c22c1b2d
Commit
c22c1b2d
authored
1 year ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Add convenience functions for calling sub skills
parent
fbac38ee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/RobotAPI/libraries/skills/core/Skill.cpp
+33
-0
33 additions, 0 deletions
source/RobotAPI/libraries/skills/core/Skill.cpp
source/RobotAPI/libraries/skills/core/Skill.h
+64
-4
64 additions, 4 deletions
source/RobotAPI/libraries/skills/core/Skill.h
with
97 additions
and
4 deletions
source/RobotAPI/libraries/skills/core/Skill.cpp
+
33
−
0
View file @
c22c1b2d
...
...
@@ -37,6 +37,39 @@ namespace armarx
return
eid
;
}
std
::
optional
<
TerminatedSkillStatusUpdate
>
Skill
::
callSubskillWithParameters
(
const
SkillID
&
skillId
,
const
aron
::
data
::
DictPtr
&
parameters
)
{
SkillProxy
proxy
(
manager
,
skillId
);
return
callSubskill
(
proxy
,
parameters
);
}
std
::
optional
<
TerminatedSkillStatusUpdate
>
Skill
::
callSubskillBasedOnDefaultParameters
(
const
SkillID
&
skillId
,
std
::
function
<
void
(
aron
::
data
::
DictPtr
&
)
>
parametersFunction
)
{
SkillProxy
proxy
(
manager
,
skillId
);
aron
::
data
::
DictPtr
parameters
=
proxy
.
getRootProfileParameters
();
if
(
not
parameters
)
{
parameters
=
armarx
::
aron
::
make_dict
();
}
parametersFunction
(
parameters
);
return
callSubskill
(
proxy
,
parameters
);
}
std
::
optional
<
TerminatedSkillStatusUpdate
>
Skill
::
callSubskillWithDefaultParameters
(
const
SkillID
&
skillId
)
{
auto
parametersFn
=
[](
aron
::
data
::
DictPtr
&
)
{};
return
callSubskillBasedOnDefaultParameters
(
skillId
,
parametersFn
);
}
void
Skill
::
updateParameters
(
const
aron
::
data
::
DictPtr
&
d
)
{
...
...
This diff is collapsed.
Click to expand it.
source/RobotAPI/libraries/skills/core/Skill.h
+
64
−
4
View file @
c22c1b2d
#pragma once
// std/stl
#include
<functional>
#include
<mutex>
#include
<queue>
#include
<thread>
// base class
#include
<ArmarXCore/core/logging/Logging.h>
// ArmarX
#include
<ArmarXCore/core/time/DateTime.h>
#include
<ArmarXCore/core/time/Metronome.h>
...
...
@@ -194,6 +190,70 @@ namespace armarx
skills
::
SkillExecutionID
callSubskillAsync
(
const
skills
::
SkillProxy
&
prx
,
const
aron
::
data
::
DictPtr
&
=
nullptr
);
/**
* @brief Call a subskill with the given ID and parameters.
* @param skillId The subskill's ID.
* @param parameters The parameters.
* @return The terminated skill status update.
*/
std
::
optional
<
TerminatedSkillStatusUpdate
>
callSubskillWithParameters
(
const
SkillID
&
skillId
,
const
aron
::
data
::
DictPtr
&
parameters
);
/**
* @brief Call a subskill with parameters based on the default parameters.
*
* Creates the skill's default parameters, and calls `parametersFunction` on them.
* This allows the caller to modify the parameters before executing the skill.
*
* @param skillId The subskill's ID.
* @param parametersFunction Function which edits the parameters.
* @return The terminated skill status update.
*/
std
::
optional
<
TerminatedSkillStatusUpdate
>
callSubskillBasedOnDefaultParameters
(
const
SkillID
&
skillId
,
std
::
function
<
void
(
aron
::
data
::
DictPtr
&
parameters
)
>
parametersFunction
);
/**
* @brief Call a subskill with its default parameters.
* @param skillId The subskill's ID.
* @return The terminated skill status update.
*/
std
::
optional
<
TerminatedSkillStatusUpdate
>
callSubskillWithDefaultParameters
(
const
SkillID
&
skillId
);
/**
* @brief Call a subskill with parameters based on the default parameters.
*
* Creates the skill's default parameters, converts them to `ParameterT`,
* and calls `parametersFunction` on them.
* This allows the caller to modify the parameters as `ParameterT` before executing
* the skill.
*
* @param skillId The subskill's ID.
* @param parametersFunction Function which edits the parameters.
* @return The terminated skill status update.
*/
template
<
class
ParameterT
>
std
::
optional
<
TerminatedSkillStatusUpdate
>
callSubskillBasedOnDefaultParameters
(
const
SkillID
&
skillId
,
std
::
function
<
void
(
ParameterT
&
parameters
)
>
parametersFunction
)
{
SkillProxy
proxy
(
manager
,
skillId
);
ParameterT
parameters
;
if
(
auto
parametersAron
=
proxy
.
getRootProfileParameters
())
{
parameters
=
ParameterT
::
FromAron
(
parametersAron
);
}
parametersFunction
(
parameters
);
return
callSubskill
(
proxy
,
parameters
.
toAron
());
}
public
:
// running params
armarx
::
core
::
time
::
DateTime
started
=
armarx
::
core
::
time
::
DateTime
::
Now
();
...
...
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