Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Port AMCL to ROS 2 (and tf2) - #9

Merged
dhood merged 80 commits into
ros2from
ros2_amcl
Jun 16, 2017
Merged

dhood merged 80 commits into
ros2from
ros2_amcl

Conversation

@dhood

@dhood dhood commented Jun 14, 2017 •

Copy link
Copy Markdown
Member

connects to #5

Currently the parameters aren't really exposed but you can get around initial pose and map with external topics/services, and you can remap topic names in ROS 1.

Usage with ROS 1 launch file of cartographer rosbag from here with appropriate tf remapping (e.g. it takes /odom not /odom_combined):

roslaunch examples/amcl_ros1_bringup.launch bag_filename:=${HOME}/Downloads/2011-09-15-08-32-46.bag

dynamic_bridge

amcl

note that using that launch file with the bridge requires a custom bridge with this remapping of the tf_remap output to tf2 msgs (or just modify the tf_remap node to use tf2 messages)

This is working correctly (same as ROS 1 version) but there are still some things to finish e.g. a launch file in ROS 2

@dhood dhood removed the in progress Actively being worked on (Kanban column) label Jun 15, 2017

@mikaelarguedas mikaelarguedas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!
A few questions about the libraries (shared vs static) and potential todo to add but nothing preventing from moving forward.

I made style comments but only in places where it was diverging from upstream and not matching our styleguide

Comment thread amcl/CMakeLists.txt Outdated
${sensor_msgs_INCLUDE_DIRS}
${geometry_msgs_INCLUDE_DIRS}
${nav_msgs_INCLUDE_DIRS}
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this necessary ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Because ament_target_dependencies does it for you AFAIK. Maybe that's what the "*TODO: explain how ament_target_dependencies() simplifies the above steps and is also better (also handling _DEFINITIONS, doing target-specific include directories, etc.) " is for.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah ok, thanks: 105fcb3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I misunderstood you, thanks for pointing it out: e34e097

Comment thread amcl/CMakeLists.txt Outdated
${nav_msgs_INCLUDE_DIRS}
)

ament_auto_add_library(amcl_pf SHARED

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that to enable static or dynamic linking we try to use ament_cmake_ros rather than forcing compiling it as shared (same for all libraries in this package)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks! dd5a552

Comment thread amcl/CMakeLists.txt
"rclcpp"
"rcutils"
"tf2_geometry_msgs"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: alphabetical order

Comment thread amcl/package.xml
<build_depend>std_srvs</build_depend>
<build_depend>tf</build_depend>
<build_depend>tf2</build_depend>
<build_depend>tf2_ros</build_depend>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: alphabetical order, same below

Comment thread amcl/src/amcl/sensors/amcl_sensor.cpp Outdated
////////////////////////////////////////////////////////////////////////////////
// Apply the action model
bool AMCLSensor::UpdateAction(pf_t *pf, AMCLSensorData *data)
bool AMCLSensor::UpdateAction(pf_t * /* pf */, AMCLSensorData * /* data */)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should warning fixes be PR'd upstream?

Comment thread amcl/src/amcl_node.cpp Outdated
init_cov_[2] = tmp_pos;
else
ROS_WARN("ignoring NAN in initial covariance AA");
ROS_WARN("ignoring NAN in initial covariance AA");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Not sure what this change is about

Comment thread amcl/src/amcl_node.cpp Outdated
d.toSec(),
ros::names::resolve(scan_topic_).c_str());
tf2::durationToSec(d),
//ros::names::resolve(scan_topic_).c_str());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this be removed?

Comment thread amcl/src/amcl_node.cpp Outdated
{
this->tf_->transformPose(odom_frame_id_, ident, odom_pose);
geometry_msgs::msg::TransformStamped odom_pose_msg;
this->tf2_buffer_->transform(tf2::toMsg<tf2::Stamped<tf2::Transform>, geometry_msgs::msg::TransformStamped>(ident), odom_pose_msg, odom_frame_id_, tf2::durationFromSec(3.0));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Wrap?

Comment thread amcl/src/amcl_node.cpp Outdated
transform_expiration,
global_frame_id_, odom_frame_id_);
tf2::TimePoint transform_expiration = tf2_ros::fromMsg(laser_scan->header.stamp) +
transform_tolerance_;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: indent

Comment thread amcl/src/amcl_node.cpp Outdated
AmclNode::stripLeadingSlash(const std::string& frame_name)
{
if (frame_name.size() > 0)
if (frame_name[0] == '/')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like a useful function, maybe put a TODO so that we move it to a place available for all packages using frames

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It turns out that TF2 removes them for you https://github.com/ros2/geometry2/blob/c5b4d4738ec1f824af364c9e55fb35239de3f1c6/tf2/src/buffer_core.cpp#L228
This was added pretty early in the porting process so it might have been for ROS 1. It seems to work fine without so I removed in 3b804a3

@tfoote tfoote left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

My comments have been addressed lgtm once @mikaelarguedas 's comments are addressed.

@dhood

dhood commented Jun 16, 2017

Copy link
Copy Markdown
Member Author

linux arm turtlebot Build Status
linux turtlebot Build Status

@mikaelarguedas mikaelarguedas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🍏 💚 👍

@wjwwood

wjwwood commented Jun 16, 2017

Copy link
Copy Markdown
Member

@dhood does this need re-review, or does @mikaelarguedas' review still good enough? If so, can this be merged?

@dhood

dhood commented Jun 16, 2017

Copy link
Copy Markdown
Member Author

Good to merge thanks all!

@dhood
dhood merged commit 851f483 into ros2 Jun 16, 2017
@dhood dhood removed the in review Waiting for review (Kanban column) label Jun 16, 2017
@dhood
dhood deleted the ros2_amcl branch June 16, 2017 21:10
@dhood dhood mentioned this pull request Jun 16, 2017
allenh1 pushed a commit that referenced this pull request Aug 1, 2017
* Remove dynamic reconfigure

* Remove rosbag functionality

* Remove message filter use

* tf -> tf2

* Strip leading / from frame IDs

* Re-enable message filter

* Don't use deperecated quaternion constructor

* Revert "Re-enable message filter"

This reverts commit c4160c2.

* Fix test failures by increasing transform timeouts

* WIP ros1->ros2

* Namespace of ::msg or ::srv

* ConstPtr -> ::ConstPtr

* ros::Time -> tf2::TimePoint

* ros::Duration -> tf2::Duration

* ros -> rclcpp

* ros2 timer

* Disable sigint handler

* Not using boost::shared_ptr

* Appropriate boost header for recursive_mutex

* Shared ptrs everywhere

* Use new durationFromSec tf2 function

* Subscribers using qos settings

* Leftover missing ::msg

* Use new tf2_ros::fromMsg

* Reinstate node ptr

* Disable most logging

* chrono fix

* 'msg.' -> 'msg->'

* Store node

* Create services properly

* Set parameters

* Comment more logging

* tf2 fixes

* fix service callback signatures

* tf2 changes

* misc

* only callbacks use shared_ptr

* map request service

* Fix boost link error

* Comment these for now just to move forward

* Use ament_auto_package

* tf2::Duration -> tf2::durationFromSec

* Re-enable "logging"

* Prevent node already added to executor crash

* (hack) use 'latest' TF info

* Debug

* Fixup (whitespace etc)

* Use rate for map request

* Don't use tf2 time for checkLaserReceived timer

* Clarify which TODOs are for before merge

* Add wait_for_service

* Restore initial qos choices

* Restore tolerance

* Demo ROS 1 launch file to be used with bridge

* [hack] Use map from topic instead of service

* Remove debug prints

* It probably won't be the map server publishing the map topic in that case (or we'd use the service)

* Expose use_map_topic as command line option

* Put initial pose back to 0 (can be set on 'initialpose' topic)

* Use tf2 time because ROS times can't be subtracted a.t.m.

* Revert test tolerance increase (needed for use without message filters)

* Remove commented delete that will never be re-enabled

* Tidy up workaround for 'latest' TF data

If the timestamp of the requested transform is 0 it will get latest

* Remove most workarounds for 'latest' TF data

* Prevent unused variable warnings

* Remove boost dependency

* Use CMAKE_CXX_STANDARD

* Alphabetical ordering

* Whitespace fixup

* Leftover debug prints

* Restore original default d_thresh

* Revert "Prevent unused variable warnings"

This reverts commit e624b1f.

* Prevent unused variable warnings

* Let ament_cmake_ros have control over the BUILD_SHARED_LIBS cmake flag

* Pedantic is a bit much

* simplify ament_target_dependencies call

* Correct usage of ament_target_dependencies

* Remove custom leading forward slash removal

Not necessary in ROS 2

* Remove ROS 1 testing launch file

* Avoid race condition with map_server topic usage

Issue with large services using fastrtps
allenh1 pushed a commit that referenced this pull request Aug 1, 2017
* Remove dynamic reconfigure

* Remove rosbag functionality

* Remove message filter use

* tf -> tf2

* Strip leading / from frame IDs

* Re-enable message filter

* Don't use deperecated quaternion constructor

* Revert "Re-enable message filter"

This reverts commit c4160c2.

* Fix test failures by increasing transform timeouts

* WIP ros1->ros2

* Namespace of ::msg or ::srv

* ConstPtr -> ::ConstPtr

* ros::Time -> tf2::TimePoint

* ros::Duration -> tf2::Duration

* ros -> rclcpp

* ros2 timer

* Disable sigint handler

* Not using boost::shared_ptr

* Appropriate boost header for recursive_mutex

* Shared ptrs everywhere

* Use new durationFromSec tf2 function

* Subscribers using qos settings

* Leftover missing ::msg

* Use new tf2_ros::fromMsg

* Reinstate node ptr

* Disable most logging

* chrono fix

* 'msg.' -> 'msg->'

* Store node

* Create services properly

* Set parameters

* Comment more logging

* tf2 fixes

* fix service callback signatures

* tf2 changes

* misc

* only callbacks use shared_ptr

* map request service

* Fix boost link error

* Comment these for now just to move forward

* Use ament_auto_package

* tf2::Duration -> tf2::durationFromSec

* Re-enable "logging"

* Prevent node already added to executor crash

* (hack) use 'latest' TF info

* Debug

* Fixup (whitespace etc)

* Use rate for map request

* Don't use tf2 time for checkLaserReceived timer

* Clarify which TODOs are for before merge

* Add wait_for_service

* Restore initial qos choices

* Restore tolerance

* Demo ROS 1 launch file to be used with bridge

* [hack] Use map from topic instead of service

* Remove debug prints

* It probably won't be the map server publishing the map topic in that case (or we'd use the service)

* Expose use_map_topic as command line option

* Put initial pose back to 0 (can be set on 'initialpose' topic)

* Use tf2 time because ROS times can't be subtracted a.t.m.

* Revert test tolerance increase (needed for use without message filters)

* Remove commented delete that will never be re-enabled

* Tidy up workaround for 'latest' TF data

If the timestamp of the requested transform is 0 it will get latest

* Remove most workarounds for 'latest' TF data

* Prevent unused variable warnings

* Remove boost dependency

* Use CMAKE_CXX_STANDARD

* Alphabetical ordering

* Whitespace fixup

* Leftover debug prints

* Restore original default d_thresh

* Revert "Prevent unused variable warnings"

This reverts commit e624b1f.

* Prevent unused variable warnings

* Let ament_cmake_ros have control over the BUILD_SHARED_LIBS cmake flag

* Pedantic is a bit much

* simplify ament_target_dependencies call

* Correct usage of ament_target_dependencies

* Remove custom leading forward slash removal

Not necessary in ROS 2

* Remove ROS 1 testing launch file

* Avoid race condition with map_server topic usage

Issue with large services using fastrtps
mikaelarguedas pushed a commit that referenced this pull request May 24, 2018
* remove AMENT_IGNORE and vestigial files

* style fixes, trailing whitespace and typos

* port to ROS 2

* use existing rclcpp syntax for now

fix package.xml (#2)

use updated rclcpp syntax for get_parameter_or (#4)

Export map_server libraries (#7)

* Export libraries

* Use name of library

* ament_export_libraries takes list of strings

* Revert "ament_export_libraries takes list of strings"

This reverts commit 630312b.

Switch use of rcl_system_time_now to rcutils_system_time_now. (#8)

Signed-off-by: Chris Lalancette <[email protected]>

Port AMCL to ROS 2 (and tf2) (#9)

* Remove dynamic reconfigure

* Remove rosbag functionality

* Remove message filter use

* tf -> tf2

* Strip leading / from frame IDs

* Re-enable message filter

* Don't use deperecated quaternion constructor

* Revert "Re-enable message filter"

This reverts commit c4160c2.

* Fix test failures by increasing transform timeouts

* WIP ros1->ros2

* Namespace of ::msg or ::srv

* ConstPtr -> ::ConstPtr

* ros::Time -> tf2::TimePoint

* ros::Duration -> tf2::Duration

* ros -> rclcpp

* ros2 timer

* Disable sigint handler

* Not using boost::shared_ptr

* Appropriate boost header for recursive_mutex

* Shared ptrs everywhere

* Use new durationFromSec tf2 function

* Subscribers using qos settings

* Leftover missing ::msg

* Use new tf2_ros::fromMsg

* Reinstate node ptr

* Disable most logging

* chrono fix

* 'msg.' -> 'msg->'

* Store node

* Create services properly

* Set parameters

* Comment more logging

* tf2 fixes

* fix service callback signatures

* tf2 changes

* misc

* only callbacks use shared_ptr

* map request service

* Fix boost link error

* Comment these for now just to move forward

* Use ament_auto_package

* tf2::Duration -> tf2::durationFromSec

* Re-enable "logging"

* Prevent node already added to executor crash

* (hack) use 'latest' TF info

* Debug

* Fixup (whitespace etc)

* Use rate for map request

* Don't use tf2 time for checkLaserReceived timer

* Clarify which TODOs are for before merge

* Add wait_for_service

* Restore initial qos choices

* Restore tolerance

* Demo ROS 1 launch file to be used with bridge

* [hack] Use map from topic instead of service

* Remove debug prints

* It probably won't be the map server publishing the map topic in that case (or we'd use the service)

* Expose use_map_topic as command line option

* Put initial pose back to 0 (can be set on 'initialpose' topic)

* Use tf2 time because ROS times can't be subtracted a.t.m.

* Revert test tolerance increase (needed for use without message filters)

* Remove commented delete that will never be re-enabled

* Tidy up workaround for 'latest' TF data

If the timestamp of the requested transform is 0 it will get latest

* Remove most workarounds for 'latest' TF data

* Prevent unused variable warnings

* Remove boost dependency

* Use CMAKE_CXX_STANDARD

* Alphabetical ordering

* Whitespace fixup

* Leftover debug prints

* Restore original default d_thresh

* Revert "Prevent unused variable warnings"

This reverts commit e624b1f.

* Prevent unused variable warnings

* Let ament_cmake_ros have control over the BUILD_SHARED_LIBS cmake flag

* Pedantic is a bit much

* simplify ament_target_dependencies call

* Correct usage of ament_target_dependencies

* Remove custom leading forward slash removal

Not necessary in ROS 2

* Remove ROS 1 testing launch file

* Avoid race condition with map_server topic usage

Issue with large services using fastrtps

use CMAKE_X_STANDARD and check compiler rather than platform

Remove dependency on rostest. (#10)

amcl integration: best effort QoS for laser scan subscription (#11)

* Make laser subscription best effort

Otherwise it can't subscribe to best effort publishers (and is generally more appropriate)

* Use rcutils logging macros

* Start a parameter server for external nodes to interact with

* Reduce diff with upstream

Move map server executables to libexec directory (#12)

use new namespace (#13)

Exporting the map_server include directory (#14)

disable everything for now with AMENT_IGNORE files

ROS 2 port of map_server (#1)

* remove AMENT_IGNORE and vestigial files

* style fixes, trailing whitespace and typos

* port to ROS 2

* use existing rclcpp syntax for now

fix package.xml (#2)

use updated rclcpp syntax for get_parameter_or (#4)

Switch use of rcl_system_time_now to rcutils_system_time_now. (#8)

Signed-off-by: Chris Lalancette <[email protected]>

Port AMCL to ROS 2 (and tf2) (#9)

* Remove dynamic reconfigure

* Remove rosbag functionality

* Remove message filter use

* tf -> tf2

* Strip leading / from frame IDs

* Re-enable message filter

* Don't use deperecated quaternion constructor

* Revert "Re-enable message filter"

This reverts commit c4160c2.

* Fix test failures by increasing transform timeouts

* WIP ros1->ros2

* Namespace of ::msg or ::srv

* ConstPtr -> ::ConstPtr

* ros::Time -> tf2::TimePoint

* ros::Duration -> tf2::Duration

* ros -> rclcpp

* ros2 timer

* Disable sigint handler

* Not using boost::shared_ptr

* Appropriate boost header for recursive_mutex

* Shared ptrs everywhere

* Use new durationFromSec tf2 function

* Subscribers using qos settings

* Leftover missing ::msg

* Use new tf2_ros::fromMsg

* Reinstate node ptr

* Disable most logging

* chrono fix

* 'msg.' -> 'msg->'

* Store node

* Create services properly

* Set parameters

* Comment more logging

* tf2 fixes

* fix service callback signatures

* tf2 changes

* misc

* only callbacks use shared_ptr

* map request service

* Fix boost link error

* Comment these for now just to move forward

* Use ament_auto_package

* tf2::Duration -> tf2::durationFromSec

* Re-enable "logging"

* Prevent node already added to executor crash

* (hack) use 'latest' TF info

* Debug

* Fixup (whitespace etc)

* Use rate for map request

* Don't use tf2 time for checkLaserReceived timer

* Clarify which TODOs are for before merge

* Add wait_for_service

* Restore initial qos choices

* Restore tolerance

* Demo ROS 1 launch file to be used with bridge

* [hack] Use map from topic instead of service

* Remove debug prints

* It probably won't be the map server publishing the map topic in that case (or we'd use the service)

* Expose use_map_topic as command line option

* Put initial pose back to 0 (can be set on 'initialpose' topic)

* Use tf2 time because ROS times can't be subtracted a.t.m.

* Revert test tolerance increase (needed for use without message filters)

* Remove commented delete that will never be re-enabled

* Tidy up workaround for 'latest' TF data

If the timestamp of the requested transform is 0 it will get latest

* Remove most workarounds for 'latest' TF data

* Prevent unused variable warnings

* Remove boost dependency

* Use CMAKE_CXX_STANDARD

* Alphabetical ordering

* Whitespace fixup

* Leftover debug prints

* Restore original default d_thresh

* Revert "Prevent unused variable warnings"

This reverts commit e624b1f.

* Prevent unused variable warnings

* Let ament_cmake_ros have control over the BUILD_SHARED_LIBS cmake flag

* Pedantic is a bit much

* simplify ament_target_dependencies call

* Correct usage of ament_target_dependencies

* Remove custom leading forward slash removal

Not necessary in ROS 2

* Remove ROS 1 testing launch file

* Avoid race condition with map_server topic usage

Issue with large services using fastrtps

use CMAKE_X_STANDARD and check compiler rather than platform

Remove dependency on rostest. (#10)

amcl integration: best effort QoS for laser scan subscription (#11)

* Make laser subscription best effort

Otherwise it can't subscribe to best effort publishers (and is generally more appropriate)

* Use rcutils logging macros

* Start a parameter server for external nodes to interact with

* Reduce diff with upstream

Move map server executables to libexec directory (#12)

use new namespace (#13)

Exporting the map_server include directory (#14)

Fixed GCC 8.0 compiler warning.

Fix compilation, as well as remove more warnings.

Fix GCC 8 warnings for map_server.

Add rcutils debug macros to map_server. (#18)

* Add rcutils debug macros to map_server.

* Addresses comments by @wjwwood

* Updated package.xml and CMakeLists.txt to add rcutils dependency.

* Remove ';' from the ends of macro calls.

* Address comments by @mikaelarguedas

Remove extra newline (#19)

use ament_cmake_pytest instead of ament_cmake_nose (#22)

Make amcl compile again with the recent changes to rclcpp::Time. (#23)

* Make amcl compile again with the recent changes to rclcpp::Time.

Signed-off-by: Chris Lalancette <[email protected]>

* Initialize the timesource and clock in the AmclNode constructor.

Then just call "clock->now()" where we need it.

Signed-off-by: Chris Lalancette <[email protected]>

* Remove rclcpp_now completely.

Signed-off-by: Chris Lalancette <[email protected]>

* Fix to not pass node to clock->now

Signed-off-by: Chris Lalancette <[email protected]>

* Change ts -> timesource.

Signed-off-by: Chris Lalancette <[email protected]>

looks like logging is initialized automatically now, fixes warning (#24)

Update for rclcpp namespace removals (#25)

* Remove client:: namespace

* Remove service:: namespace

* Remove parameter_service:: namespace

* Remove rate:: namespace

* Remove node:: namespace

Update maintainers and version ahead of Ardent release (#26)

* Update maintainers and version ahead of Ardent release

* Prev maintainers -> authors

* Level all versions so bloom doesn't complain
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants