Repository navigation
Flesh out kobuki driver - #7
Conversation
…xed linting. Next is to test that the data produced make sense.
…many messages. Also fix a couple of bugs in kobuki driver.
wjwwood
left a comment
There was a problem hiding this comment.
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}) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
$ 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)
There was a problem hiding this comment.
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)
| for (auto & parameter : parameters_client->get_parameters({"device_port"})) { | ||
| parameters.device_port = parameter.as_string(); | ||
| } | ||
| for (auto & parameter : parameters_client->get_parameters({"odom_frame"})) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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...)
There was a problem hiding this comment.
There was a problem hiding this comment.
Most of the useful parameter API's are linked to from the "parameters" sections on this doxygen page:
That's for beta1, but it should be pretty pretty close to up-to-date.
| 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(); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Yep, that's a bug, thanks.
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)


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