Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wolf_ros_node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
mobile_robotics
wolf_projects
wolf_ros
wolf_ros_node
Commits
74df86e4
Commit
74df86e4
authored
4 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
avoid 2 consec publish to compensate after 2 periods not publishing
parent
a250b702
No related branches found
No related tags found
3 merge requests
!11
new release
,
!10
new release
,
!4
Gauss
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/publisher.h
+11
-6
11 additions, 6 deletions
include/publisher.h
with
11 additions
and
6 deletions
include/publisher.h
+
11
−
6
View file @
74df86e4
...
@@ -49,7 +49,7 @@ class Publisher
...
@@ -49,7 +49,7 @@ class Publisher
const
ProblemPtr
_problem
)
:
const
ProblemPtr
_problem
)
:
problem_
(
_problem
),
problem_
(
_problem
),
first_publish_time_
(
ros
::
Time
(
0
)),
first_publish_time_
(
ros
::
Time
(
0
)),
n_publishe
d_
(
0
),
last_n_perio
d_
(
0
),
prefix_
(
"ROS publisher/"
+
_unique_name
)
prefix_
(
"ROS publisher/"
+
_unique_name
)
{
{
period_
=
_server
.
getParam
<
double
>
(
prefix_
+
"/period"
);
period_
=
_server
.
getParam
<
double
>
(
prefix_
+
"/period"
);
...
@@ -74,24 +74,29 @@ class Publisher
...
@@ -74,24 +74,29 @@ class Publisher
ros
::
Publisher
publisher_
;
ros
::
Publisher
publisher_
;
double
period_
;
double
period_
;
ros
::
Time
first_publish_time_
;
ros
::
Time
first_publish_time_
;
long
unsigned
int
n_publishe
d_
;
long
unsigned
int
last_n_perio
d_
;
std
::
string
prefix_
;
std
::
string
prefix_
;
std
::
string
topic_
;
std
::
string
topic_
;
};
};
inline
void
Publisher
::
publish
()
inline
void
Publisher
::
publish
()
{
{
if
(
n_publishe
d_
==
0
)
if
(
last_n_perio
d_
==
0
)
first_publish_time_
=
ros
::
Time
::
now
();
first_publish_time_
=
ros
::
Time
::
now
();
n_published_
++
;
publishDerived
();
publishDerived
();
}
}
inline
bool
Publisher
::
ready
()
inline
bool
Publisher
::
ready
()
{
{
long
unsigned
int
n_pub
=
(
long
unsigned
int
)((
ros
::
Time
::
now
()
-
first_publish_time_
).
toSec
()
/
period_
);
long
unsigned
int
n_period
=
(
long
unsigned
int
)((
ros
::
Time
::
now
()
-
first_publish_time_
).
toSec
()
/
period_
);
return
n_pub
>
n_published_
;
if
(
n_period
>
last_n_period_
)
{
last_n_period_
=
n_period
;
return
true
;
}
return
false
;
}
}
inline
std
::
string
Publisher
::
getTopic
()
const
inline
std
::
string
Publisher
::
getTopic
()
const
...
...
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