Migrating C++ code from ROS1 to ROS2 – 如何在ROS2中使用C++串行库?

huangapple go评论103阅读模式
英文:

Migrating C++ code from ROS1 to ROS2 - How to use C++ serial library in ROS2?

问题

我正在将一个软件包从ROS1迁移到ROS2。这是一个电机控制器驱动程序,所以它通过USB通信,并使用了C++库'serial'。我已经看到其他类似的ROS2 C++驱动程序使用了'serial'库,但我想知道在构建时如何修复这个错误:

  By not providing "Findserial.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "serial", but
  CMake did not find one.

  Could not find a package configuration file provided by "serial" with any
  of the following names:

    serialConfig.cmake
    serial-config.cmake

  Add the installation prefix of "serial" to CMAKE_PREFIX_PATH or set
  "serial_DIR" to a directory containing one of the above files.  If "serial"
  provides a separate development package or SDK, be sure it has been
  installed.

在我的文件中,我包括了头文件#include <serial/serial.h>,并在CMakeLists.txt中使用了find_package(serial REQUIRED)。我是否漏掉了什么?这是在全新的安装上,我需要安装其他东西吗?谢谢

在ROS1中,你可以简单地使用apt-get install ros-noetic-serial。但在ROS2上这种方法不起作用。当我运行colcon build时,我得到了上面的错误。

英文:

I am migrating a package from ROS1 to ROS2. It is a motor controller driver so it communicates over USB and uses the 'serial' C++ library. I have seen other ROS2 C++ drivers similar to this one use the serial library, but am wondering how to fix this error when building:


CMake Error at CMakeLists.txt:26 (find_package):

  By not providing &quot;Findserial.cmake&quot; in CMAKE_MODULE_PATH this project has


asked CMake to find a package configuration file provided by &quot;serial&quot;, but
  CMake did not find one.

  Could not find a package configuration file provided by &quot;serial&quot; with any
  of the following names:

    serialConfig.cmake
    serial-config.cmake

  Add the installation prefix of &quot;serial&quot; to CMAKE_PREFIX_PATH or set
  &quot;serial_DIR&quot; to a directory containing one of the above files.  If &quot;serial&quot;
  provides a separate development package or SDK, be sure it has been
  installed.


    ---

Failed   &lt;&lt;&lt;

I include the header #include <serial/serial.h> In my file and find_package(serial REQUIRED) in CMakeLists.txt. Is there something I'm missing for this to work? This is on a fresh install, do I need to install anything? Thanks

In ROS1, you can simply use apt-get install ros-noetic-serial. This doesn't work on ROS2. When I run colcon build, I got the error above.

答案1

得分: 0

我可以为你提供翻译的部分:

"Are you sure the other drivers you've seen with ROS2 use the exact same package? From what I can tell, there is no official release of the serial package for ROS2 available (based on the conversations in the Issues section on the official GIT repository here).

然而,话虽如此,你可以看到有一些“非官方”的版本,人们已经将精确的串行库移植到ROS2中,现在可以使用colcon进行构建。serial-ros2 项目 here 和原始存储库的 ros2 分支 here 目前可能非常相似,都是串行包的非官方版本。你可以尝试使用它们。

Another package I came across for this use-case is the transport_drivers repository with the serial_driver package which has some development for ROS2 here. However, using this would probably involve modifying your original code to work with this package and some extra work Migrating C++ code from ROS1 to ROS2 – 如何在ROS2中使用C++串行库?

希望这对你有帮助!"

英文:

Are you sure the other drivers you've seen with ROS2 use the exact same package? From what I can tell, there is no official release of the serial package for ROS2 available (based on the conversations in the Issues section on the official GIT repository here).

However, that being said, you can see that there are some "unofficial" versions where people have ported the exact serial library to now build with colcon in ROS2. The serial-ros2 project here and the ros2 branch of the original repository here are probably very similar at the moment and are unofficial versions of the serial package. You could give them a shot.

Another package I came across for this use-case is the transport_drivers repository with the serial_driver package which has some development for ROS2 here. However, using this would probably involve modifying your original code to work with this package and some extra work Migrating C++ code from ROS1 to ROS2 – 如何在ROS2中使用C++串行库?

Hope this helps!

huangapple
  • 本文由 发表于 2023年2月19日 02:43:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75495578.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定