-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieving(get_parameter()) value of parameter of type std::vector<int> won't build #2577
Comments
In ParameterValue, std::vector<int> and std::vector<int64_t> are of the same type. rclcpp/rclcpp/src/rclcpp/parameter_value.cpp Lines 188 to 198 in c743c17
Both are stored as std::vector<int64_t>. The returned value when retrieving is also std::vector<int64_t> rclcpp/rclcpp/include/rclcpp/parameter_value.hpp Lines 305 to 313 in c743c17
A simple workaround is Regarding the fix, I'm considering modifying get() for std::vector as the below template<typename type>
typename std::enable_if<
std::is_convertible<
type, const std::vector<int> &>::value, const std::vector<int>>::type
get() const
{
std::vector<int> convert;
auto array = get<ParameterType::PARAMETER_INTEGER_ARRAY>();
convert.reserve(array.size());
for(const auto& val : array) {
convert.push_back(static_cast<int>(val));
}
return convert;
} Is there a better way? |
|
std::vector -> std:vector<int>
I think you mean these 2 functions. rclcpp/rclcpp/include/rclcpp/parameter_value.hpp Lines 305 to 323 in c743c17
While executing The issue lies in the static conversion here. While the type of clamps_iters is std::vector<int>, it wants to convert std::vector<int64_t> to std:vector<int>. But there's no default conversion function. rclcpp/rclcpp/include/rclcpp/node_impl.hpp Line 345 in c743c17
|
Bug report
Required Info:
Steps to reproduce issue
Expected behavior
The package should build successfully.
Actual behavior
The build fails with the following error:
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.
The text was updated successfully, but these errors were encountered: