Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warnings for upcoming ROS Galactic release #631

Merged
merged 6 commits into from
Mar 22, 2021
Merged

Fix deprecation warnings for upcoming ROS Galactic release #631

merged 6 commits into from
Mar 22, 2021

Conversation

jacobperron
Copy link
Contributor

Building against the latest version of rclcpp produces some deprecation warnings. This PR fixes warnings related to rclcpp::Duration construction (6b36efd) and rclcpp::Node::declare_parameter (7055b82).

Related tickets upstream, deprecating usage:

The second commit (7055b82) related to declare_parameter is not compatible with Foxy, so I recommend creating a new galactic-devel branch and we can retarget this PR.

If we are constructing from nanoseconds we must be explicit about the units.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
If a default value is not provided, then we must specify the parameter type.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
src/ros_filter.cpp Outdated Show resolved Hide resolved
@@ -604,7 +604,7 @@ void RosFilter<T>::integrateMeasurements(const rclcpp::Time & current_time)
const std::string first_measurement_topic =
first_measurement->topic_name_;
// revertTo may invalidate first_measurement
if (!revertTo(first_measurement_time - rclcpp::Duration(1))) {
if (!revertTo(first_measurement_time - rclcpp::Duration(1ns))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ayrton04 should this be 1ns, 1s, ...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I meant to ask the same question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the equivalent ROS 1 code, it is also subtracting 1 nanosecond:

if (!revertTo(firstMeasurementTime - 1e-9)) // revertTo may invalidate firstMeasurement

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the PRs involved here are

https://github.com/cra-ros-pkg/robot_localization/pull/266/files

and

https://github.com/cra-ros-pkg/robot_localization/pull/279/files

The only reason we subtract any time at all is to ensure that we go to a measurement (presumably the first) that is before first_measurement_time. But we could also just change this to use >=:

while (!filter_state_history_.empty() &&
filter_state_history_.back()->last_measurement_time_ > time)

If I had to guess (I didn't dig too far), the measurement times were likely stored as doubles originally, and the 1e-9 thing was just me being careful with floating point numbers. But ROS times have exact representations, so I think the 1e-9 could go, and we can change the revertTo reverse iteration to check for >= instead of just >.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, that change could be outside of scope for this. It was meant to be 1 nanosecond, yes.

@SteveMacenski
Copy link
Collaborator

@jacobperron I opened a ros2 branch to target it to since those from_XYZ's aren't in foxy

@jacobperron jacobperron changed the base branch from foxy-devel to ros2 March 17, 2021 22:53
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Contributor Author

Hold up, there's more warnings in other files I've overlooked.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Contributor Author

Hold up, there's more warnings in other files I've overlooked.

Okay, I think I got them all.

@SteveMacenski
Copy link
Collaborator

Otherwise LGTM, waiting for Tom's response on that one comment

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
src/ros_filter.cpp Outdated Show resolved Hide resolved
When there is a NoParameterOverrideProvided exception, the parameter
is not declared so we don't need to undeclare it.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@ayrton04 ayrton04 requested a review from SteveMacenski March 22, 2021 10:20
@ayrton04
Copy link
Collaborator

@SteveMacenski, feel free to merge. I know you said LGTM, but your review still had comments requested, so I re-requested your review.

@SteveMacenski SteveMacenski merged commit 9fba3e8 into cra-ros-pkg:ros2 Mar 22, 2021
@jacobperron jacobperron deleted the fix_deprecation_warnings branch March 22, 2021 18:48
SteveMacenski pushed a commit that referenced this pull request May 21, 2021
Try-catches were added in #631 due to a new rclcpp feature enforcing static parameter.
The behavior was later patched for this particular use-case in ros2/rclcpp#1673, so now we can avoid having to try-catch.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
SteveMacenski pushed a commit that referenced this pull request May 24, 2021
Try-catches were added in #631 due to a new rclcpp feature enforcing static parameter.
The behavior was later patched for this particular use-case in ros2/rclcpp#1673, so now we can avoid having to try-catch.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
SteveMacenski added a commit that referenced this pull request May 24, 2021
* Add missing message_filters dependency (#666)

Headers from message_filters are included here:
https://github.com/cra-ros-pkg/robot_localization/blob/67098c2341b5d1ccbcceb8eede60e79db74814a6/include/robot_localization/ros_robot_localization_listener.h\#L41-L42

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Remove try-catch blocks around declare_parameter (#663)

Try-catches were added in #631 due to a new rclcpp feature enforcing static parameter.
The behavior was later patched for this particular use-case in ros2/rclcpp#1673, so now we can avoid having to try-catch.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

Co-authored-by: Jacob Perron <jacob@openrobotics.org>
SteveMacenski pushed a commit that referenced this pull request May 25, 2021
* Remove try-catch blocks around declare_parameter (#663)

Try-catches were added in #631 due to a new rclcpp feature enforcing static parameter.
The behavior was later patched for this particular use-case in ros2/rclcpp#1673, so now we can avoid having to try-catch.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add missing message_filters dependency (#666)

Headers from message_filters are included here:
https://github.com/cra-ros-pkg/robot_localization/blob/67098c2341b5d1ccbcceb8eede60e79db74814a6/include/robot_localization/ros_robot_localization_listener.h\#L41-L42

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Revert "Enable QoS overrides (#657)"

This reverts commit 2816e92.

Co-authored-by: Jacob Perron <jacob@openrobotics.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants