1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【ROS2 パラメータTips】 int型配列パラメータをビルドできない場合の対処方法

Last updated at Posted at 2024-03-15

はじめに

ROS2のC++ノードでint配列(std::vector<int>)パラメータを使おうとしたら、コンパイルエラーとなったので、その対処方法を記載する。

環境

  • ROS2 Foxy

方法

リンク先にあるように、std::vector<int>では、エラーとなるので、std::vector<int64_t>に変更する。

int(uint)型配列の対応状況は以下のようになっている。

  • NG

    // int
    node->declare_parameter<vector<int>>("param", std::vector<int>{});
    node->declare_parameter<vector<int16_t>>("param", std::vector<int16_t>{});
    node->declare_parameter<vector<int32_t>>("param", std::vector<int32_t>{});
    // unsigned int
    node->declare_parameter<vector<uint16_t>>("param", std::vector<uint16_t>{});    
    node->declare_parameter<vector<uint32_t>>("param", std::vector<uint32_t>{});    
    
  • OK

    // int
    node->declare_parameter<vector<int64_t>>("param", std::vector<int64_t>{});
    // unsigned int
    node->declare_parameter<vector<uint8_t>>("param", std::vector<uint8_t>{});    
    

補足情報

配列型パラメータでコンパイル可能な型は以下の通り。

node->declare_parameter<std::vector<double>>("param", std::vector<double>{});
node->declare_parameter<std::vector<uint8_t>>("param", std::vector<uint8_t>{});
node->declare_parameter<std::vector<bool>>("param", std::vector<bool>{});
node->declare_parameter<std::vector<int64_t>>("param", std::vector<int64_t>{});
node->declare_parameter<std::vector<double>>("param", std::vector<double>{});
node->declare_parameter<std::vector<std::string>>("param", std::vector<std::string>{});

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?