(c++) Rospram fails when reading certain boolean values
For some reason, I can't get getParam() to return the value true unless it is formatted in a very specific way. Is this a bug? Any insight is appreciated.
I am loading the rosparam server using a yaml file. My file looks something like this:
foo:
bar:
my_boolean_value: true
When I use the getParam() function to retrieve the value, it tells me that the value does not exist.
bool value;
bool success = handle.getParam("foo/bar/my_boolean_value", value);
// success == false
The same thing happens when I try to interpret it as a string.
std::string value;
bool success = handle.getParam("foo/bar/my_boolean_value", value);
// success == false
However, if I use the following yaml files I have no problem reading it with the code above.
foo:
bar:
my_boolean_value: True
# Notice the capitol 'T'
foo:
bar:
my_boolean_value: False
foo:
bar:
my_boolean_value: false
# first letter doesn't need to be a capitol for false
foo:
bar:
my_boolean_value: "true"
# I can read this a a string value, unlike the unquoted variant
Clarifying question: if success is false for all cases, then your code is never actually reading the parameters, when does true return successfully for value not success?
The variable success is false only for the input string true. success resolves to true and the variable value holds the correct result when the input string is True, false, False, and "true" (as long as I request a string).