鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    fish_protocol在ros2 humble下运行的问题

    已定时 已固定 已锁定 已移动
    ROS 2相关问题
    ros2 fishros
    2
    2
    187
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • C
      cctrr
      最后由 编辑

      编译example_fish_protocol时出现如下警告,该如何修改?
      Starting >>> example_fish_protocol
      --- stderr: example_fish_protocol
      In file included from /usr/include/boost/smart_ptr/detail/sp_thread_sleep.hpp:22,
      from /usr/include/boost/smart_ptr/detail/yield_k.hpp:23,
      from /usr/include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp:14,
      from /usr/include/boost/smart_ptr/detail/spinlock.hpp:42,
      from /usr/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
      from /usr/include/boost/smart_ptr/shared_ptr.hpp:29,
      from /usr/include/boost/shared_ptr.hpp:17,
      from /usr/include/boost/date_time/time_clock.hpp:17,
      from /usr/include/boost/date_time/posix_time/posix_time_types.hpp:10,
      from /usr/include/boost/asio/time_traits.hpp:23,
      from /usr/include/boost/asio/detail/timer_queue_ptime.hpp:22,
      from /usr/include/boost/asio/detail/deadline_timer_service.hpp:29,
      from /usr/include/boost/asio/basic_deadline_timer.hpp:25,
      from /usr/include/boost/asio.hpp:25,
      from /usr/local/include/fish_protocol/fish_protocol.h:10,
      from /home/hhx/ros2_protocol/fish_protocol/examples/example_ros2/example_fish_protocol/src/example_fish_protocol.cpp:1:
      /usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
      36 | BOOST_PRAGMA_MESSAGE(
      | ^~~~~~~~~~~~~~~~~~~~

      Finished <<< example_fish_protocol [3.78s]

      Summary: 1 package finished [3.92s]
      1 package had stderr output: example_fish_protocol
      ![替代文字]

      1 条回复 最后回复 回复 引用 0
      • 小伊小
        机器人小伊
        最后由 编辑

        这个警告信息表明你的代码(或者依赖的库)在使用 Boost 的 bind 功能时,使用了全局命名空间的占位符(如 _1, _2, ...),这种做法已经被弃用。Boost 推荐使用新的方式来引用这些占位符,以避免潜在的命名冲突。

        警告信息中提供了一个解决方案:

        1. 使用 <boost/bind/bind.hpp> 并使用 boost::placeholders 命名空间:

          • 修改你的代码,包含头文件 <boost/bind/bind.hpp> 而不是 <boost/bind.hpp>。
          • 在需要使用占位符的地方,添加 using namespace boost::placeholders;。
        2. 定义 BOOST_BIND_GLOBAL_PLACEHOLDERS:

          • 如果你不想修改现有的代码,可以在编译时定义宏 BOOST_BIND_GLOBAL_PLACEHOLDERS 来保持当前的行为。这可以通过在编译命令中添加 -DBOOST_BIND_GLOBAL_PLACEHOLDERS 来实现。

        针对你的 ROS 2 项目,你可以按照以下步骤操作:

        方法 1:修改代码

        • 修改包含的头文件:
          在你的源文件中(如 example_fish_protocol.cpp),将 #include <boost/bind.hpp> 替换为 #include <boost/bind/bind.hpp>。
        • 添加命名空间:
          在文件顶部或在使用占位符之前,添加 using namespace boost::placeholders;。

        方法 2:定义宏

        • 修改 CMakeLists.txt:
          在 CMakeLists.txt 文件中,找到 ament_add_executable 或类似的命令,添加编译选项:
          ament_add_executable(example_fish_protocol src/example_fish_protocol.cpp)
          ament_target_environments(example_fish_protocol AMENT_CURRENT_PREFIX)
          target_compile_definitions(example_fish_protocol PRIVATE BOOST_BIND_GLOBAL_PLACEHOLDERS)
          

        选择其中一种方法来解决警告问题。如果你控制源代码(包括依赖的第三方库),推荐使用方法 1,因为它更符合现代的 C++ 和 Boost 库的使用习惯。如果你只是用户,且不希望或不能修改源代码,方法 2 可能更合适。不过,长期来看,更新代码以符合新的库标准是更好的做法。


        以上为生成回答,仅供参考~

        我是小伊,已接入ChatGpt,所有回复,仅供参考~

        1 条回复 最后回复 回复 引用 0
        • 第一个帖子
          最后一个帖子
        皖ICP备16016415号-7
        Powered by NodeBB | 鱼香ROS