Skip to content
This repository was archived by the owner on Sep 13, 2022. It is now read-only.

Flesh out kobuki driver - #7

Merged
gerkey merged 8 commits into
masterfrom
mapping_demo
Mar 10, 2017
Merged

gerkey merged 8 commits into
masterfrom
mapping_demo

Conversation

@gerkey

@gerkey gerkey commented Mar 3, 2017

Copy link
Copy Markdown
Member

Publish /odom, /tf, and /imu_data. To verify the data I joysticked the robot along the side of an approximately 0.5m square. Attached are plots of Y vs. X from odometry showing the expected sloppy square and yaw velocity vs. time from IMU showing the expected 3 CCW rotations with plenty of noise)
imu-yaw-velocity
odom-xy

. I also spot-checked other outputs and they appear sane.

@gerkey
gerkey requested a review from codebot March 3, 2017 20:31

@wjwwood wjwwood 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.

other than one change request and a suggested change, lgtm

# Note that this setting must come after the call to
# ament_target_dependencies() to avoid including a ROS1 tf2 installation that
# might be on the system.
target_include_directories(kobuki_node PRIVATE ${kobuki_driver_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.

Yeah, this is an unfortunate reality because the package names are the same. I guess we're getting lucky on the linking? I could see that we would easily use the headers of tf2_ros from ROS 2 but the library of tf2_ros from ROS 1 by accident. Should we consider renaming tf2_ros as tf2_ros2 (as an example) to avoid this issue? We could eventually probably make it so that all the other tf2* packages are ABI compatible between ROS 1 and ROS 2, but that will likely never be the case with the tf2_ros part.

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.

Good question on linking. Looking at the code, and based on some verification that I just did: in this case we're not getting lucky. For a start, nobody is trying to link against -ltf2_ros. The call to ament_target_dependencies() is generating an absolute path to the ROS2 lib, which isn't ambiguous. And ${kobuki_driver_LIBRARIES} doesn't include tf2_ros. If that last condition weren't true, we'd have trouble. But I'd argue that that would be an unsupported use case, because you're trying to link the ROS2 tf2 lib into an application that also requires a ROS1 lib that internally is using the ROS1 tf2 lib.

The broader point about being careful in these situations still stands, but I'm not sure that changing package names is the right way forward. Let's discuss that at some point.

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.

Ok, I didn't think about the absolute path to the binary. I'd be curious to see the output of ldd though. I wonder if it is using the absolute path or delegating to ld config at some point.

Either way, I agree this can be discussed later.

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.

$ ldd `which kobuki_node`
	linux-vdso.so.1 =>  (0x00007fff036a8000)
	libnav_msgs__rosidl_typesupport_cpp.so => /home/gerkey/ros2_ws/install/lib/libnav_msgs__rosidl_typesupport_cpp.so (0x00007f4617fdc000)
	librmw.so => /home/gerkey/ros2_ws/install/lib/librmw.so (0x00007f4617dd7000)
	librcl.so => /home/gerkey/ros2_ws/install/lib/librcl.so (0x00007f4617bc7000)
	librclcpp.so => /home/gerkey/ros2_ws/install/lib/librclcpp.so (0x00007f46175bb000)
	libgeometry_msgs__rosidl_typesupport_cpp.so => /home/gerkey/ros2_ws/install/lib/libgeometry_msgs__rosidl_typesupport_cpp.so (0x00007f46173b5000)
	libsensor_msgs__rosidl_typesupport_cpp.so => /home/gerkey/ros2_ws/install/lib/libsensor_msgs__rosidl_typesupport_cpp.so (0x00007f46171b0000)
	libtf2_ros.so => /home/gerkey/ros2_ws/install/lib/libtf2_ros.so (0x00007f4616f0f000)
	libkobuki.so => /opt/ros/kinetic/lib/libkobuki.so (0x00007f4616ccb000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f4616903000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f46165fa000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f46163e3000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f461601a000)
	libnav_msgs__rosidl_typesupport_introspection_cpp.so => /home/gerkey/ros2_ws/build/nav_msgs/libnav_msgs__rosidl_typesupport_introspection_cpp.so (0x00007f4615e0c000)
	/lib64/ld-linux-x86-64.so.2 (0x00005600f59f5000)
	librmw_fastrtps_cpp.so => /home/gerkey/ros2_ws/install/lib/librmw_fastrtps_cpp.so (0x00007f4615ba4000)
	librcl_interfaces__rosidl_typesupport_cpp.so => /home/gerkey/ros2_ws/install/lib/librcl_interfaces__rosidl_typesupport_cpp.so (0x00007f461599f000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4615781000)
	libgeometry_msgs__rosidl_typesupport_introspection_cpp.so => /home/gerkey/ros2_ws/build/geometry_msgs/libgeometry_msgs__rosidl_typesupport_introspection_cpp.so (0x00007f4615571000)
	libsensor_msgs__rosidl_typesupport_introspection_cpp.so => /home/gerkey/ros2_ws/build/sensor_msgs/libsensor_msgs__rosidl_typesupport_introspection_cpp.so (0x00007f4615348000)
	libtf2.so => /home/gerkey/ros2_ws/install/lib/libtf2.so (0x00007f46150d3000)
	libtf2_msgs__rosidl_typesupport_cpp.so => /home/gerkey/ros2_ws/install/lib/libtf2_msgs__rosidl_typesupport_cpp.so (0x00007f4614ed0000)
	libecl_mobile_robot.so => /opt/ros/kinetic/lib/libecl_mobile_robot.so (0x00007f4614ccc000)
	libecl_devices.so => /opt/ros/kinetic/lib/libecl_devices.so (0x00007f4614aad000)
	libecl_geometry.so => /opt/ros/kinetic/lib/libecl_geometry.so (0x00007f4614889000)
	libecl_threads.so => /opt/ros/kinetic/lib/libecl_threads.so (0x00007f461467e000)
	libecl_time.so => /opt/ros/kinetic/lib/libecl_time.so (0x00007f4614475000)
	libecl_exceptions.so => /opt/ros/kinetic/lib/libecl_exceptions.so (0x00007f461426f000)
	librosidl_generator_c.so => /home/gerkey/ros2_ws/install/lib/librosidl_generator_c.so (0x00007f4614069000)
	librosidl_typesupport_introspection_cpp.so => /home/gerkey/ros2_ws/install/lib/librosidl_typesupport_introspection_cpp.so (0x00007f4613e67000)
	libbuiltin_interfaces__rosidl_typesupport_introspection_cpp.so => /home/gerkey/ros2_ws/install/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_cpp.so (0x00007f4613c63000)
	libstd_msgs__rosidl_typesupport_introspection_cpp.so => /home/gerkey/ros2_ws/install/lib/libstd_msgs__rosidl_typesupport_introspection_cpp.so (0x00007f4613a56000)
	libfastcdr.so => /home/gerkey/ros2_ws/install/lib/libfastcdr.so (0x00007f4613846000)
	libfastrtps.so => /home/gerkey/ros2_ws/install/lib/libfastrtps.so (0x00007f46134ac000)
	librosidl_typesupport_introspection_c.so => /home/gerkey/ros2_ws/install/lib/librosidl_typesupport_introspection_c.so (0x00007f46132aa000)
	librcl_interfaces__rosidl_typesupport_introspection_cpp.so => /home/gerkey/ros2_ws/build/rcl_interfaces/librcl_interfaces__rosidl_typesupport_introspection_cpp.so (0x00007f461308e000)
	libconsole_bridge.so.0.3 => /home/gerkey/ros2_ws/install/lib/libconsole_bridge.so.0.3 (0x00007f4612e89000)
	libtf2_msgs__rosidl_typesupport_introspection_cpp.so => /home/gerkey/ros2_ws/build/tf2_msgs/libtf2_msgs__rosidl_typesupport_introspection_cpp.so (0x00007f4612c80000)
	libecl_type_traits.so => /opt/ros/kinetic/lib/libecl_type_traits.so (0x00007f4612a7d000)
	libecl_time_lite.so => /opt/ros/kinetic/lib/libecl_time_lite.so (0x00007f4612876000)
	libboost_thread.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.58.0 (0x00007f4612650000)
	libboost_system.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0 (0x00007f461244b000)
	libboost_chrono.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_chrono.so.1.58.0 (0x00007f4612243000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f461203a000)

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.

Or, to check what we're using from /opt/ros:

$ ldd `which kobuki_node` | grep opt
	libkobuki.so => /opt/ros/kinetic/lib/libkobuki.so (0x00007f53eb714000)
	libecl_mobile_robot.so => /opt/ros/kinetic/lib/libecl_mobile_robot.so (0x00007f53e9715000)
	libecl_devices.so => /opt/ros/kinetic/lib/libecl_devices.so (0x00007f53e94f6000)
	libecl_geometry.so => /opt/ros/kinetic/lib/libecl_geometry.so (0x00007f53e92d2000)
	libecl_threads.so => /opt/ros/kinetic/lib/libecl_threads.so (0x00007f53e90c7000)
	libecl_time.so => /opt/ros/kinetic/lib/libecl_time.so (0x00007f53e8ebe000)
	libecl_exceptions.so => /opt/ros/kinetic/lib/libecl_exceptions.so (0x00007f53e8cb8000)
	libecl_type_traits.so => /opt/ros/kinetic/lib/libecl_type_traits.so (0x00007f53e74c6000)
	libecl_time_lite.so => /opt/ros/kinetic/lib/libecl_time_lite.so (0x00007f53e72bf000)

Comment thread turtlebot2_drivers/src/kobuki_node.cpp Outdated
for (auto & parameter : parameters_client->get_parameters({"device_port"})) {
parameters.device_port = parameter.as_string();
}
for (auto & parameter : parameters_client->get_parameters({"odom_frame"})) {

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.

As I discovered in my porting of map_server, this caused this issue for me: ros2/rclcpp#308 Did you not run into that issue?

Anyways, my workaround was to just use the Node::get_parameter methods. If you take a step back here, you're using the ROS interface to ask for parameters your local node already has. So using the Parameter client is a bit overkill anyways. You might want to switch to the local parameters. You still want that Parameter service so external programs can change them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Node::get_parameter interface also allows you to get one parameter (which throws if it doesn't exist), instead of having to fetch a list and for loop over them.

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.

@wjwwood, I haven't seen the problem that you're describing, but if I understand correctly, I'm not going through the same sequence that you are in ros2/rclcpp#308. By luck, I've created all of my topics before actually using the SyncParametersClient.

But as you and @rohbotics have suggested, I should just use Node::get_parameter instead; I'll do that. (Was that interface always available? I wonder why I went for the client/server setup...)

@rohbotics rohbotics Mar 6, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@gerkey I added the single parameter interface over the summer, I don't know when Node::get_parameters was added.
#4 was supposed to convert the kobuki node over to the node interface, as well as make the parameters dynamic, but it looks like that never got merged in.

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.

Most of the useful parameter API's are linked to from the "parameters" sections on this doxygen page:

http://docs.ros2.org/beta1/api/rclcpp/index.html

That's for beta1, but it should be pretty pretty close to up-to-date.

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.

Comment thread turtlebot2_drivers/src/kobuki_node.cpp Outdated
if (rcl_system_time_now(&now) != RCL_RET_OK) {
std::cerr << "Failed to get system time" << std::endl;
}
auto now = std::chrono::system_clock::now();

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.

Can you change this variable, or the other one? It looks like you have now shadowed as both a rcl_time_point_value_t and something like a std::chrono::time_point (whatever auto becomes).

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.

Yep, that's a bug, thanks.

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.

@gerkey
gerkey merged commit 7dbe0a5 into master Mar 10, 2017
@gerkey
gerkey deleted the mapping_demo branch March 10, 2017 19:17
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.

3 participants