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
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Merge requests
!157
armem/dev => master
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
armem/dev => master
armem/dev
into
master
Overview
3
Commits
202
Pipelines
0
Changes
2
Merged
Fabian Reister
requested to merge
armem/dev
into
master
3 years ago
Overview
3
Commits
202
Pipelines
0
Changes
2
Expand
0
0
Merge request reports
Viewing commit
a5015bf1
Prev
Next
Show latest version
2 files
+
33
−
31
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
a5015bf1
periodic task instead of runnnig task
· a5015bf1
Fabian Reister
authored
3 years ago
source/RobotAPI/components/armem/client/VirtualRobotReaderExampleClient/VirtualRobotReaderExampleClient.cpp
+
24
−
30
Options
@@ -19,6 +19,7 @@
#include
<ArmarXCore/core/time/CycleUtil.h>
#include
<ArmarXCore/core/logging/Logging.h>
#include
<ArmarXCore/core/time/TimeUtil.h>
#include
<ArmarXCore/core/services/tasks/PeriodicTask.h>
#include
<RobotAPI/libraries/armem/client/query/Builder.h>
#include
<RobotAPI/libraries/armem/client/query/query_fns.h>
@@ -39,6 +40,9 @@ namespace armarx::robot_state
defs
->
topic
(
debugObserver
);
defs
->
optional
(
p
.
robotName
,
"robotName"
);
defs
->
optional
(
p
.
updateFrequency
,
"updateFrequency"
);
virtualRobotReader
.
registerPropertyDefinitions
(
defs
);
return
defs
;
@@ -55,7 +59,9 @@ namespace armarx::robot_state
{
virtualRobotReader
.
connect
();
task
=
new
RunningTask
<
VirtualRobotReaderExampleClient
>
(
this
,
&
VirtualRobotReaderExampleClient
::
run
);
ARMARX_IMPORTANT
<<
"Running virtual robot synchronization example."
;
task
=
new
PeriodicTask
<
VirtualRobotReaderExampleClient
>
(
this
,
&
VirtualRobotReaderExampleClient
::
run
,
1000
/
p
.
updateFrequency
);
task
->
start
();
}
@@ -68,44 +74,32 @@ namespace armarx::robot_state
void
VirtualRobotReaderExampleClient
::
run
()
{
ARMARX_IMPORTANT
<<
"Running virtual robot synchronization example."
;
std
::
shared_ptr
<
VirtualRobot
::
Robot
>
virtualRobot
{
nullptr
};
CycleUtil
cycle
(
IceUtil
::
Time
::
milliSeconds
(
100
));
IceUtil
::
Time
start
=
TimeUtil
::
GetTime
();
// initialize if needed
if
(
virtualRobot
==
nullptr
)
{
TIMING_START
(
getRobot
);
CycleUtil
c
(
100
);
virtualRobot
=
virtualRobotReader
.
getRobot
(
p
.
robotName
,
IceUtil
::
Time
::
now
()
);
while
(
not
task
->
isStopped
())
{
// initialize
if
(
virtualRobot
==
nullptr
)
if
(
virtualRobot
==
nullptr
)
{
TIMING_START
(
getRobot
);
virtualRobot
=
virtualRobotReader
.
getRobot
(
"Armar6"
,
IceUtil
::
Time
::
now
());
if
(
virtualRobot
==
nullptr
)
{
ARMARX_WARNING
<<
"Could not create virtual robot."
;
c
.
waitForCycleDuration
();
continue
;
}
// only print timing once the robot is loadable & loaded
TIMING_END_STREAM
(
getRobot
,
ARMARX_INFO
);
ARMARX_WARNING
<<
deactivateSpam
(
1
)
<<
"Could not create virtual robot."
;
return
;
}
// only print timing once the robot is loadable & loaded
TIMING_END_STREAM
(
getRobot
,
ARMARX_INFO
);
}
ARMARX_INFO
<<
"Synchronizing robot"
;
ARMARX_INFO
<<
deactivateSpam
(
10
)
<<
"Synchronizing robot"
;
const
IceUtil
::
Time
now
=
TimeUtil
::
GetTime
();
const
IceUtil
::
Time
now
=
TimeUtil
::
GetTime
();
TIMING_START
(
synchronizeRobot
);
virtualRobotReader
.
synchronizeRobot
(
*
virtualRobot
,
now
);
TIMING_END_STREAM
(
synchronizeRobot
,
ARMARX_INFO
);
TIMING_START
(
synchronizeRobot
);
virtualRobotReader
.
synchronizeRobot
(
*
virtualRobot
,
now
);
TIMING_END_STREAM
(
synchronizeRobot
,
ARMARX_INFO
);
c
.
waitForCycleDuration
();
}
}
}
// namespace armarx::robot_state
Loading