Repository navigation
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[written by AI]
Refs PickNikRobotics/moveit_pro#24179 (story A of PickNikRobotics/moveit_pro#18694)
Motivation
Numbers often reach Script expressions as strings, for example through SubTree ports. Today
-,*,/on them fail withOperation not permitted,'3 apples' + 4silently gives7becauseAny::stringToNumberaccepts a numeric prefix,1 .. 2returns an empty value that:=reports as "not initialized", and..prints doubles as2.000000. The measured table is on PickNikRobotics/moveit_pro#18694.Brief description
All in
include/behaviortree_cpp/scripting/operators.hpp. Helpers live inBT::Ast::detail;Any::stringToNumberandAny's double-to-string conversion are unchanged, so port conversions elsewhere in the library behave as before.' 5 'is 5;'3 apples','5000ms','+5','0x10','nan','inf','1e999','1e-400'and''are not. A character check runs before parsing so every standard library rejects the same strings.int64, also for strings above 2^53), logic, unary-~!, compound assignment,?:and comparisons use that rule. A non-number is aRuntimeErrornaming the operand; with+it suggests...+on two strings still concatenates. PickNikRobotics/moveit_pro#24181 removes that in 11.0.0.int64, otherwise aslong doublesoIsSameapplies no tolerance. Numbers too large to compare exactly are an error; strings compare as text only when one of them is not a number.int64entry already is, instead of rounding silently. Every number-to-double cast in the operators turns a precision-lossstd::runtime_errorinto aRuntimeError, soParseScriptAndExecutereturns an error instead of throwing...joins any strings and numbers. Whole doubles up to 2^53 print as integers (2, not2.000000); others in the shortest%gform that reads back exactly (0.25,0.0001,0.30000000000000004), the same on every standard library.c := '1'; c += 1gives'2'); with a number entry, a numeric string on the right is a number (n := 1; n += '2'gives3).Behavior changes to decide on before this ships
compatibility-bot(moveit_pro reviewer role) rated theseNeeds-discussionfor a non-major release. None of the scripts shipped in moveit_pro or moveit_pro_example_ws change outcome; the only visible difference is one log line inhangar_sim/objectives/calibrate_sam3_mask_areas.xml(threshold=0.250000→threshold=0.25).'10' > '9'becomes true;'007' == '7'and'1.0' == '1'become equal. Previously text comparison.'5000ms' / 1000(was5),'3 apples' == 3(was true),'3 apples' ? 1 : 2(was1),x = '3 apples'into a number entry (was3),'0x10' == 0(was true),'inf' > 1(was true)...drops trailing zeros on doubles.Options for 1 and 2: accept in the next minor with a
Breaking Change:release note in the moveit_proBTCPP_PICKNIK_VERSIONbump PR, or hold those parts for 11.0.0 with #24181.How it was tested
Built in a container from the
moveit-pro-devimage (clang with libstdc++ 13), plain CMake,BTCPP_GROOT_INTERFACE=OFF.main-picknikbefore the change, plusParserTest.UntypedNumericOperands,ParserTest.NumberStreamFallbacksandSubTree.ScriptingTypingIssue_SubtractNumericStringPort).operators.hpp.ParserTest.*andSubTree.*clean under ASan and UBSan.pre-commit(clang-format 17, clang-tidy, codespell) clean on the changed files.from_chars(libc++).ParserTest.NumberStreamFallbackscalls the stream parse and format functions directly; thefrom_charsvs. stream choice insideParseWholeNumberonly runs there.Follow-ups after merge
git_shaandrevision6 →ros-jazzy-behaviortree-cpp-picknik=4.9.0-6noble.BTCPP_PICKNIK_VERSION, add the script operator reference page, correct the two operator sentences in PickNikRobotics/moveit_pro#24177's docs and the pin line indocs_nonpublic/design/behaviortree-cpp-fork-coexistence.md, and add the release notes.