bool and bool_array should not be converted to strings in parameter msg
See original GitHub issueDescription
Parameter bool values are currently converted to strings (for example, true
becomes 'true'
) when using the Parameter.toParameterMessage()
method. These messages aren’t parsed correctly when they are received by an rclcpp node and the as_bool()
and as_bool_array()
methods are used.
I have tested and it seems that the conversions here(parameter.js:L227-L234) aren’t necessary, and the code works as expected if removed.
- Library Version: 0.21.1
- ROS Version: Galactic
- Platform / OS: Linux (Ubuntu 20.04)
Steps To Reproduce
- With rclnodejs:
//Create a parameter of type PARAMETER_BOOL or PARAMETER_BOOL_ARRAY
let parameters: Parameter[];
parameters.push(new Parameter('foo', ParameterType.PARAMETER_BOOL_ARRAY, [true, false, true]))
// Convert parameter to msg
const setParametersRequest: rcl_interfaces.srv.SetParameters_Request = {
parameters: parameters.map(function (e) {
return e.toParameterMessage();
}),
};
// Send request using the client Client<'rcl_interfaces/srv/SetParametersAtomically'> or Client<'rcl_interfaces/srv/SetParameters'>
client.sendRequest(setParametersRequest, (resp) => {
console.log('resp: ', resp)
});
- With rclcpp:
rcl_interfaces::msg::SetParametersResult parameters_callback(
const vector<rclcpp::Parameter> & parameters)
{
rcl_interfaces::msg::SetParametersResult result;
result.successful = true;
for (const rclcpp::Parameter & param : parameters) {
if (param.get_name() == "foo") {
vector<bool> foo = param.as_bool_array();
RCLCPP_INFO_STREAM(
get_node()->get_logger(), "Received foo : " <<
foo[0] << " " <<
foo[1] << " " <<
foo[2];
}
return result;
}
Expected Behavior
1 0 1
should be outputted in the terminal.
Actual Behavior
1 1 1
is actually outputted in the terminal.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Error msg: Failed to convert parameter value from a String to a ...
I am getting an error msg when attempting to update a record from asp.net into a SQL database. The only boolean value being...
Read more >validateBoolean is not working with verbose "true" parameter ...
Boolean validation seems failing, because value is "true" not true, with message "The parameter field must be true or false.".
Read more >[Solved] 1 Write a program to ask the user about the validity of ...
For this question, you must use a variable of type bool. It is useful to know that Convert.ToBoolean() can work with true, True,...
Read more >How to Handle the Incompatible Types Error in Java - Rollbar
The best way to do this is to use Java's built-in Integer::parseInt method which takes a String argument and converts it to an...
Read more >Boolean Struct (System) - Microsoft Learn
You use the ToString method to convert Boolean values to strings. The Boolean structure includes two ToString overloads: the parameterless ToString() method ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@imcelroy Unlike the rclcpp/rclpy clients that will be released with the ROS2 packages, so you don’t need to worry about the compatibility. rclnodejs is a stand-alone nodejs package, and as you know ROS2 has many releases in parallel and their patch releases, which makes it difficult to maintain the compatibility. We did try to leverage e.g., build flag, to cover different ROS2 releases, but usually, we only verify the binary with our tests on the latest stable ROS2 due to limited resources.
Thank you for the explanation, that makes sense.