Retrieving(get_parameter()) value of parameter of type std::vector<int> won't build
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
Bug report
Required Info:
- Operating System:
- Ubuntu 22.04 MATE
- Installation type:
- binaries
- Version or commit hash:
- Iron
- DDS implementation:
- Default(have not changed it)
- Client library (if applicable):
- rclcpp
Steps to reproduce issue
- Create a ROS2 package
ros2 pkg create --build-type ament_cmake vector_int_pkg
- Create a simple node the declares a parameter of type std::vector in file src/test_vector_int.cpp
#include "rclcpp/rclcpp.hpp"
int main(int argc, char ** argv)
{
rclcpp::init(argc, argv);
std::shared_ptr<rclcpp::Node> node = rclcpp::Node::make_shared("vector_integer_parameters");
// Declaring Params
node->declare_parameter("param", std::vector<int>{});
// Getting Params
std::vector<int> clamps_iters = {1,2,3};
node->get_parameter("param", clamps_iters);
rclcpp::spin(node);
rclcpp::shutdown();
}
- Adjust the CMakeLists.txt file
cmake_minimum_required(VERSION 3.5)
project(vector_int_pkg)
if (NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif ()
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif ()
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif ()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
add_executable(test_vector_int src/test_vector_int.cpp)
ament_target_dependencies(test_vector_int rclcpp)
ament_package()
- Adjust the package.xml
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>vector_int_pkg</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">John Doe</maintainer>
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>rclcpp</depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
- Build the package
colcon build --packages-select vector_int_pkg
Expected behavior
The package should build successfully.
Actual behavior
The build fails with the following error:
/home/user/ros_ws/src/vector_int_pkg/src/test_vector_int.cpp:14:22: required from here
/opt/ros/iron/include/rclcpp/rclcpp/node_impl.hpp:343:17: error: no matching function for call to ‘std::vector<int>::vector(std::vector<long int, std::allocator<long int> >)’
343 | parameter = static_cast<ParameterT>(parameter_variant.get_value<ParameterT>());
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Additional information
The issue seems similar to #1585. The only difference is that issue was related to declaring parameter values and this one is related to retrieving values.
NOTE: The code in #1585 is building successfully on my system.
- 主要语言
- C++
- 星标
- 829
- 派生
- 587
- 平均合并
- 4 天 6 小时
- 30 天内合并 PR
- 30
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ros2/rclcpp 的其他 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
Memory grows per callback group created and destroyed on long lived nodes可能已有人在做 @jwallace42 于 1 天前认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 28/100
ros2/rclcpp#3428 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
removing and immediately re-adding a node to the EventsCBGExecutor leaves its entities unregistered可能已有人在做 @skyegalaxy 于 10 天前认领。 未关闭bug
维护者通常 1 天内回复
-
[Humble] Removing a node with more than one auto-added callback group leaves a dangling guard condition in the executor可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
相似的 Issue
-
arch-based bug niri
难度 2/5 1-3 小时 新手友好度 68/100
noctalia-dev/noctalia#5552 ·
维护者通常 1 天内回复
-
bug
难度 1/5 1-3 小时 新手友好度 82/100
EchoTools/nevr-runtime#2912 ·
维护者通常 1 天内回复
-
area/docdb kind/failing-test priority/medium status/awaiting-triage
难度 2/5 1-3 小时 新手友好度 82/100
yugabyte/yugabyte-db#39462 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
meshtastic/firmware#12519 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复