Skip to content
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

[pull] master from BehaviorTree:master #60

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/behaviortree_cpp/bt_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Tree
[[nodiscard]] Blackboard::Ptr rootBlackboard();

//Call the visitor for each node of the tree.
void applyVisitor(const std::function<void(const TreeNode*)>& visitor);
void applyVisitor(const std::function<void(const TreeNode*)>& visitor) const;

//Call the visitor for each node of the tree.
void applyVisitor(const std::function<void(TreeNode*)>& visitor);
Expand Down
11 changes: 6 additions & 5 deletions include/behaviortree_cpp/utils/convert_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ inline void checkTruncation(const From& from)
if constexpr(std::is_integral_v<From> && std::is_floating_point_v<To>)
{
// Check if value can be represented exactly in the target type
To as_float = static_cast<To>(from);
From back_conv = static_cast<From>(as_float);
if(back_conv != from)
constexpr auto max_exact = (1LL << std::numeric_limits<double>::digits) - 1;
if(from > max_exact || from < -max_exact)
{
throw std::runtime_error("Loss of precision in conversion to floating point");
throw std::runtime_error("Loss of precision when converting a large integer number "
"to floating point:" +
std::to_string(from));
}
}
// Handle floating point to integer
if constexpr(std::is_floating_point_v<From> && std::is_integral_v<To>)
else if constexpr(std::is_floating_point_v<From> && std::is_integral_v<To>)
{
if(from > static_cast<From>(std::numeric_limits<To>::max()) ||
from < static_cast<From>(std::numeric_limits<To>::lowest()) ||
Expand Down
2 changes: 1 addition & 1 deletion src/bt_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ Blackboard::Ptr Tree::rootBlackboard()
return {};
}

void Tree::applyVisitor(const std::function<void(const TreeNode*)>& visitor)
void Tree::applyVisitor(const std::function<void(const TreeNode*)>& visitor) const
{
BT::applyRecursiveVisitor(static_cast<const TreeNode*>(rootNode()), visitor);
}
Expand Down
Loading