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

ROS2 Navsat_transform_node in Dashing #476

Merged
merged 24 commits into from
Nov 19, 2019
Merged

ROS2 Navsat_transform_node in Dashing #476

merged 24 commits into from
Nov 19, 2019

Conversation

klintan
Copy link
Contributor

@klintan klintan commented Aug 5, 2019

I saw there was already an issue and a fork (#473) for Dashing, but made some changes remove all the deprecation warnings.

There might be some declare_parameters which could go back to get_parameter.

Also I guess it makes sense to create a new branch dashing-devel and if these changes makes sense, I'll change the PR to that branch instead.

@ayrton04
Copy link
Collaborator

ayrton04 commented Aug 8, 2019

Please see my notes on that issue.

src/navsat_transform.cpp Outdated Show resolved Hide resolved
src/ros_filter.cpp Outdated Show resolved Hide resolved
@klintan
Copy link
Contributor Author

klintan commented Aug 9, 2019

It now compiles with navsat_transform_node. However there is one major issue, trying to run I get problems with the dynamically linked stuff:

dyld: Library not loaded: @loader_path/libnddsc.dylib
  Referenced from: /ros2/ros2-osx/lib/librosidl_typesupport_connext_c.dylib
  Reason: image not found

Which is really strange, because I couldn't see anything in particular in the CMakeLists file that would make a hard dependency on anything from connext (as it is an optional middleware).

I'll continue my research, but any input on that is welcome :). However I think its ready for some major PR feedback now.

Edit: Fixed!

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
#find_package(geographic_msgs REQUIRED)
find_package(geographic_msgs REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Happy to see this was released.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's released yet though. I saw the comment in the issue. Right now it needs to be cloned manually and activate that workspace. This is kind of important as well ros-geographic-info/geographic_info#26 which hasn't been approved yet :(

Copy link
Collaborator

Choose a reason for hiding this comment

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

uh, then we cant merge this @klintan, it'll not build in CI or on releasing debians

Copy link
Contributor Author

@klintan klintan Aug 10, 2019

Choose a reason for hiding this comment

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

No worries, I'll try to push to get the geographic_msgs released, maybe we can keep this PR open until then (hopefully won't be months) and as soon as it's there, this will be mergeable.

edit: Sidenote, recently ROS2 converted ros-driver package for velodyne depends on the angles package https://github.com/ros/angles.git which is also not a part of the official release yet. But I get that different packages see this differently (of course regardless the geographic_info package at least needs the latest fixes in the ros2 branch)

Copy link
Collaborator

Choose a reason for hiding this comment

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

sigh ok, now, weeks later, I have lobbied all the parties required to merge the ROS2 port PR, it will be released in the next dashing sync assuming I didnt mess it up. But now I have a new shiny GitHub organization on my profile, so not a total loss of time :-)
ros/rosdistro#22324

CMakeLists.txt Show resolved Hide resolved
include/robot_localization/navsat_transform.hpp Outdated Show resolved Hide resolved
src/navsat_transform.cpp Outdated Show resolved Hide resolved
src/navsat_transform.cpp Outdated Show resolved Hide resolved
src/navsat_transform_node.cpp Outdated Show resolved Hide resolved
@rotu
Copy link

rotu commented Aug 9, 2019

It now compiles with navsat_transform_node. However there is one major issue, trying to run I get problems with the dynamically linked stuff:

I'm experiencing these issues as well with an unrelated package. I suspect this is caused by something upstream.

@klintan
Copy link
Contributor Author

klintan commented Aug 10, 2019

I'm experiencing these issues as well with an unrelated package. I suspect this is caused by something upstream.

Let me know if you find the/a solution, I'm going to try just removing the dynamic links using otool/install_name_tool . I'll let you know if I figure it out.

@rotu the issue was indeed upstream, it seems that geographic_msgs was exporting all of these dependencies

ament_export_dependencies(ament_cmake)
ament_export_dependencies(std_msgs)
ament_export_dependencies(geometry_msgs)
ament_export_dependencies(unique_identifier_msgs)
ament_export_dependencies(rosidl_default_generators)
ament_export_dependencies(rosidl_default_runtime)

Removing all of them except
ament_export_dependencies(rosidl_default_runtime)
fixes that.

@klintan klintan changed the title ROS2 Dashing updates ROS2 Navsat_transform_node in Dashing Aug 10, 2019
@IanTheEngineer
Copy link

To test this PR, I made a vcstools file to include the unreleased upstream dependencies and open PR's:

navsat_transform_node.repos :

repositories:
  diagnostics:
    type: git
    url: git@github.com:ros/diagnostics.git
    version: ros2-devel
  geographic_info:
    type: git
    url: git@github.com:PickNikRobotics/geographic_info.git
    version: unique_identifier_msgs
  robot_localization:
    type: git
    url: git@github.com:klintan/robot_localization.git
    version: dashing-devel

After installing ROS Dashing, and python3-vcstools,

$ mkdir -p ~/ros2_ws/src
$ cd ~/ros2_ws
$ vcs import src < navsat_transform_node.repos
$ source /opt/ros/dashing/setup.bash
$ colcon build

@IanTheEngineer
Copy link

IanTheEngineer commented Aug 21, 2019

The package.xml isn't in this PR, but it needs to have geographic_msgs uncommented for this PR to begin to build with colcon :

-  <!--<depend>geographic_msgs</depend>-->
+  <depend>geographic_msgs</depend>

@klintan
Copy link
Contributor Author

klintan commented Aug 22, 2019

To test this PR, I made a vcstools file to include the unreleased upstream dependencies and open PR's:

navsat_transform_node.repos :

repositories:
  diagnostics:
    type: git
    url: git@github.com:ros/diagnostics.git
    version: ros2-devel
  geographic_info:
    type: git
    url: git@github.com:PickNikRobotics/geographic_info.git
    version: unique_identifier_msgs
  robot_localization:
    type: git
    url: git@github.com:klintan/robot_localization.git
    version: dashing-devel

After installing ROS Dashing, and python3-vcstools,

$ mkdir -p ~/ros2_ws/src
$ cd ~/ros2_ws
$ vcs import src < navsat_transform_node.repos
$ source /opt/ros/dashing/setup.bash
$ colcon build

That's awesome, thanks!

@ayrton04
Copy link
Collaborator

Wow, thanks for all the effort here. I'll keep an eye out for the Dashing sync and merge afterwards, assuming nothing else needs to be done here.

@SteveMacenski
Copy link
Collaborator

I still see some issues, will do another pass through this afternoon.

Copy link
Collaborator

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

Biggest issues around the queue_size & ros2 conventions

@@ -35,6 +39,7 @@ include_directories(
include
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm going to point you to one of my other packages for ros2 cmakelist best practices, this is really not easily maintainable with all the include / link dirs. If you set a variable with all the dependencies and you use ament, you can get rid of most of this code.

https://github.com/ros-planning/navigation2/blob/master/nav2_planner/CMakeLists.txt

@@ -57,7 +57,7 @@ class NavSatTransform
/**
* @brief Constructor
*/
NavSatTransform();
NavSatTransform(std::shared_ptr<rclcpp::Node> node);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Best practices for this is that the NavSatTransform node should derive from rclcpp::Node, and when you make the shared_ptr of it in main that will deal with this, then all of your calls are working with methods available vs storing your node_. The ros nodehandle methodology is depreciated in ros2, its preferred to derive from the node to best make use of lifecycle and components, which is important for this package in particular

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually tried to use that convention here as well, but I couldn't get it to work, always got the bad_weak_ptr exception during runtime because of the TF2 package (I think). The initializer lists wants a shared, and since there is now owner when it's passed I got that exception. However it could have been the way I used image_transport the "old" way, instead of the image_transport::create_subscription/create_publisher that made it fail, I can't fully recall I'll need to retest it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you make_shared the NavSatTransform object in main that will fix that. You get an issue with shared_ptrs if there's not already the reference counter set

src/navsat_transform.cpp Outdated Show resolved Hide resolved
include/robot_localization/ros_filter.hpp Outdated Show resolved Hide resolved
src/navsat_transform.cpp Outdated Show resolved Hide resolved
src/navsat_transform.cpp Outdated Show resolved Hide resolved
src/ros_filter.cpp Outdated Show resolved Hide resolved
src/ros_filter.cpp Outdated Show resolved Hide resolved
src/ros_filter.cpp Outdated Show resolved Hide resolved
src/navsat_transform.cpp Outdated Show resolved Hide resolved
@klintan
Copy link
Contributor Author

klintan commented Sep 23, 2019

I thought some of the changes from the last PR was going to conflict with this one? Regardless I'll try to adopt the same style as that one for some of the changes here as well (and of course all of the review remarks)

Thanks for the very thorough review, I appreciate it and I appreciate your patience.

@SteveMacenski
Copy link
Collaborator

thorough

I think some of my colleagues would use another, less kind, word in its place, but thanks for baring with me 😸

@klintan
Copy link
Contributor Author

klintan commented Oct 2, 2019

Fixed a bunch of stuff, I will give the inherit from rclcpp::Node another try as well, hopefully I'll have time to get to that tomorrow night.

@klintan
Copy link
Contributor Author

klintan commented Oct 5, 2019

@SteveMacenski Now compiling and working using the ROS2 node-style.

Made most of the std::outs to RCLCPP style logging. On of the old std::outs outputted the pose though, which is kind of tricky to log using RCLCPP style. I don't think that one is necessary though, but maybe long term for debugging purposes/brevity we want to get it in there.

Let me know if you find anything, any and all feedback is welcome :)

Copy link
Collaborator

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

Some small fish changes needed

src/navsat_transform_node.cpp Outdated Show resolved Hide resolved
src/navsat_transform.cpp Outdated Show resolved Hide resolved
rclcpp::Rate rate(frequency);
while (rclcpp::ok()) {
rclcpp::spin_some(node_);
int interval = (1/frequency) * 1000;
Copy link
Collaborator

@SteveMacenski SteveMacenski Oct 8, 2019

Choose a reason for hiding this comment

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

you have frequency defaulted to 10, so this would be... 100 hz? I think you mean to move s to ms but the variable name didnt make that clear, can you change the name or do the ms conversion in the chrono call? Or better yet, use chrono::seconds(interval)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good catch. I'll keep the variable name, but I like the approach of chrono::seconds(interval)
to make it more clear.

@klintan
Copy link
Contributor Author

klintan commented Oct 23, 2019

@SteveMacenski fixed the things you noted (I hope :) ). However I noticed another issue when fixing that, line 954 in ros_filter.cpp (same thing in 2 other places in ros_filter), perhaps you can take an extra look at that so it looks sane. I'm open to any other approach.

Sorry for the delay.

@reso1
Copy link

reso1 commented Oct 23, 2019

Hello @klintan, I've been using your "beta version" of the navsat_transform node, and I found a problem when using a dual_ekf_navsat configurations, a local ekf node and a global ekf node with GPS (following the yaml below: dual_ekf_navsat_example.yaml

SO here is the problem, the navsat_transform node subscribes to "/odometry/filtered" topic msgs, and because both "ekf_se_odom"(local) node and "ekf_se_map"(global) node will publish "/odometry/filtered" topic msg, it will cause the "/odometry/gps" topic msg published by navsat_transform node jump between 2 values, each calculated based on the msg published by "ekf_se_odom"(local) node or and "ekf_se_map"(global) node, respectively.

image

from this workflow figure, the navsat_transfrom_node only takes the "/odometry/filtered" msg published by *kf_localization_node(map)“ into account.

But anyway I've made a workaround, by only executing "odomCallback" function when the frame_id of the "/odometry/filtered" msg header eqauls to "map"(i.e. published by "ekf_se_map"(global) node).

I'm wondering that whether I'm not correctly using the "dual_ekf_navsat" configurations with GPS info, or is there a better solution for this problem? Thanks!

@ayrton04
Copy link
Collaborator

@reso1, the two EKFs should not be publishing on the same topic. Remap the tier 1 (odom) frame one to something else.

@SteveMacenski
Copy link
Collaborator

@klintan I’ll take a look this afternoon.

I (still, frustratingly, annoyingly, {other more colorful words}) do not have a robot to meaningfully test this on, so by in large I’m trusting beyond the code semantics that this actually works.

I’m not sure if Tom has a ROS2-able robot to have a quick third party check, or @reso1 other than your topic remapping (see Tom’s comment), is this working for you? Have you tried all the params getting to you & outputs as expected?

Copy link
Collaborator

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

Themes:

  • still need queue sizes
  • A few more updates to CMakeList still necessary
  • Member variable naming
  • Just making sure defaults are same as in ROS1

CMakeLists.txt Outdated
@@ -19,37 +23,60 @@ find_package(tf2_geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(Eigen3 REQUIRED)

set(includes
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't necessary anymore, use ament_target_dependencies see examples here https://github.com/ros-planning/navigation2/blob/master/nav2_planner/CMakeLists.txt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm I think I might have missed something, because couldn't get it to find some includes (eigen3 and diagnostics_updated without adding them).

See my changes, I think I need some help on that one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure let me know

Copy link
Collaborator

Choose a reason for hiding this comment

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

Of everything I'm the least concerned by the CMake stuff, give it another shot and if not I can take care of it for you after the fact

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
include/robot_localization/navsat_transform.hpp Outdated Show resolved Hide resolved
src/navsat_transform.cpp Outdated Show resolved Hide resolved
src/ros_filter.cpp Outdated Show resolved Hide resolved
src/ros_filter.cpp Outdated Show resolved Hide resolved
src/ros_filter.cpp Show resolved Hide resolved
@@ -1436,7 +1445,7 @@ void RosFilter::loadParams()
deceleration_gains);

control_sub_ = node_->create_subscription<geometry_msgs::msg::Twist>(
"cmd_vel",
"cmd_vel", 10,
Copy link
Collaborator

Choose a reason for hiding this comment

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

queue size

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This parameter would be outside the scope of odom, twist, pose and imu. Do we want to declare a separate parameter for this one?

Copy link
Collaborator

@SteveMacenski SteveMacenski Oct 24, 2019

Choose a reason for hiding this comment

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

Oh sorry this one is fine. I went a little trigger happy when I saw the number 10 😉 Though I think 1 is also the ROS1 default, if you see how its used, there's no benefit to storing anything except the most recent one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha :) ok I'll change this to 1 as well.

src/ros_filter.cpp Outdated Show resolved Hide resolved
@reso1
Copy link

reso1 commented Oct 24, 2019

@ayrton04 @SteveMacenski
Thanks for your advices, I've tried the remapping solution and now it works fine :)

@klintan
Copy link
Contributor Author

klintan commented Oct 24, 2019

@ayrton04 @SteveMacenski
Thanks for your advices, I've tried the remapping solution and now it works fine :)

Happy to hear it's working for you :)

@SteveMacenski
Copy link
Collaborator

Wow that was quick, ok I think the last thing is just the conversation on the parameters for checking _N+1

I'm not buying this set(libraries ...) call as necessary,but if that's the worst thing in here, I can live with that.

Copy link
Collaborator

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

With that, I give this my (fairly meaningless) thumbs up.

Lets see what Tom says on the undeclare thing. Otherwise, assuming that you've sufficiently tested this since it doesn't appear the automated testing pipeline is in good shape, I would be OK merging this.

Thanks with sticking with my rounds-and-rounds of nitpicks

@@ -1849,11 +1881,11 @@ void RosFilter::run()

double diag_duration = (cur_time - last_diag_time).nanoseconds();
if (print_diagnostics_ &&
(diag_duration >= diagnostic_updater_.getPeriod() ||
diag_duration < 0.0))
(diag_duration >= diagnostic_updater_.getPeriod() ||

Choose a reason for hiding this comment

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

diagnostic_updater_.getPeriod().nanoseconds()
?

Copy link
Contributor Author

@klintan klintan Oct 26, 2019

Choose a reason for hiding this comment

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

getPeriod() is already returning nanoseconds :)

edit: as seen below, I didn't have the latest diagnostics_updater, thanks for pointing this out!

Copy link
Contributor

Choose a reason for hiding this comment

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

I am looking at the diagnostic repo, and getPeriod() returns a rcl_duration_value_t in the head of the crystal branch , but returns a rclcpp::Duration at the head of the dashing branch. rclcpp::Duration does need a .nanoseconds() to get the types matching

Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like the type change came in with c272eb276d of the diagnostic repo dashing branch and is in the released debian for dashing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aah ok, yes I did not pull the absolute latest, I'll do that and re-run. I think the one I had was at least dashing, so maybe that commit was aimed at one of the patch-releases.

@klintan
Copy link
Contributor Author

klintan commented Nov 19, 2019

Resolving merge conflicts. I glanced through about half of them, they're really easy, just alot of them

Thanks for your patience, took a while to knock it out. Fixed a bunch of linting issues that failed in the tests. Let me know if you see anything I missed after/during the rebase.

@SteveMacenski
Copy link
Collaborator

@Jconn are your concerns resolved?

@Jconn
Copy link
Contributor

Jconn commented Nov 19, 2019

@Jconn are your concerns resolved?

No more concerns, good work @klintan

@SteveMacenski SteveMacenski merged commit d471205 into cra-ros-pkg:dashing-devel Nov 19, 2019
@SteveMacenski
Copy link
Collaborator

I dont believe it. Its finally in!

@ayrton04
Copy link
Collaborator

Epic. Thanks to everyone involved!

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.

None yet

8 participants