Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ BT::NodeStatus ExampleConvertMtcSolutionToJointTrajectory::tick()
// Initialize the robot model loader if this is the first time this Behavior has been run.
if (robot_model_loader_ == nullptr)
{
robot_model_loader_ = std::make_unique<robot_model_loader::RobotModelLoader>(shared_resources_->node);
robot_model_loader_ = std::make_unique<robot_model_loader::RobotModelLoader>(getBehaviorContext()->node);
}

// Get the robot model from the robot model loader.
Expand Down
4 changes: 2 additions & 2 deletions src/example_behaviors/src/example_create_string_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ BT::NodeStatus ExampleCreateStringMsg::tick()
if (const auto error = moveit_pro::behaviors::maybe_error(expected_string); error)
{
// If the port was set incorrectly, we will log an error message to the UI and the node will return FAILURE
shared_resources_->logger->publishFailureMessage(name(), "Failed to get required values from input data ports." +
error.value());
getBehaviorContext()->logger->publishFailureMessage(name(), "Failed to get required values from input data ports." +
error.value());
return BT::NodeStatus::FAILURE;
}

Expand Down
8 changes: 4 additions & 4 deletions src/example_behaviors/src/example_delayed_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ BT::NodeStatus ExampleDelayedMessage::onStart()
if (const auto error = moveit_pro::behaviors::maybe_error(maybe_duration); error)
{
// If the port was set incorrectly, we will log an error message to the UI and the node will return FAILURE
shared_resources_->logger->publishFailureMessage(name(), "Failed to get required values from input data ports." +
error.value());
getBehaviorContext()->logger->publishFailureMessage(name(), "Failed to get required values from input data ports." +
error.value());
return BT::NodeStatus::FAILURE;
}

Expand All @@ -47,7 +47,7 @@ BT::NodeStatus ExampleDelayedMessage::onStart()
{
// Log the "Hello, world!" message.
// Setting the third argument to false ensures the message will be shown immediately
shared_resources_->logger->publishInfoMessage(name(), "Hello, world!");
getBehaviorContext()->logger->publishInfoMessage(name(), "Hello, world!");
return BT::NodeStatus::SUCCESS;
}

Expand All @@ -62,7 +62,7 @@ BT::NodeStatus ExampleDelayedMessage::onRunning()
{
// Log the "Hello, world!" message.
// Setting the third argument to false ensures the message will be shown immediately
shared_resources_->logger->publishInfoMessage(name(), "Hello, world!");
getBehaviorContext()->logger->publishInfoMessage(name(), "Hello, world!");
return BT::NodeStatus::SUCCESS;
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/example_behaviors/src/example_fibonacci_action_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ExampleFibonacciActionClient::processResult(const std::shared_ptr<Fibonacci::Res
std::cout << stream.str() << std::endl;

// Publish the result to the UI
shared_resources_->logger->publishInfoMessage(name(), "Result: " + stream.str());
getBehaviorContext()->logger->publishInfoMessage(name(), "Result: " + stream.str());

setOutput<std::vector<int>>("result", result->sequence);

Expand All @@ -83,7 +83,7 @@ void ExampleFibonacciActionClient::processFeedback(const std::shared_ptr<const F
std::cout << stream.str() << std::endl;

// Publish the feedback to the UI
shared_resources_->logger->publishInfoMessage(name(), "Feedback: " + stream.str());
getBehaviorContext()->logger->publishInfoMessage(name(), "Feedback: " + stream.str());

setOutput<std::vector<int>>("feedback", feedback->sequence);
}
Expand Down
2 changes: 1 addition & 1 deletion src/example_behaviors/src/example_hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BT::NodeStatus ExampleHelloWorld::tick()
{
// Do ExampleHelloWorld's useful work.
// Setting the third argument to false ensures the message will be shown immediately
shared_resources_->logger->publishInfoMessage(name(), "Hello, world!");
getBehaviorContext()->logger->publishInfoMessage(name(), "Hello, world!");

return BT::NodeStatus::SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion src/example_behaviors/src/example_publish_color_rgba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ExamplePublishColorRGBA::ExamplePublishColorRGBA(
const std::string& name, const BT::NodeConfiguration& config,
const std::shared_ptr<moveit_pro::behaviors::BehaviorContext>& shared_resources)
: moveit_pro::behaviors::SharedResourcesNode<BT::SyncActionNode>(name, config, shared_resources)
, publisher_{ shared_resources_->node->create_publisher<std_msgs::msg::ColorRGBA>("/my_topic", rclcpp::QoS(1)) }
, publisher_{ getBehaviorContext()->node->create_publisher<std_msgs::msg::ColorRGBA>("/my_topic", rclcpp::QoS(1)) }
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ BT::NodeStatus ComputeTrayPlacePositionsUsingAprilTags::tick()

if (!ports.has_value())
{
shared_resources_->logger->publishFailureMessage(name(), "Failed to get required values from input data ports: " +
ports.error());
getBehaviorContext()->logger->publishFailureMessage(
name(), "Failed to get required values from input data ports: " + ports.error());
return BT::NodeStatus::FAILURE;
}

Expand All @@ -128,7 +128,7 @@ BT::NodeStatus ComputeTrayPlacePositionsUsingAprilTags::tick()

if (tray_it == detections_array.detections.end())
{
shared_resources_->logger->publishFailureMessage(
getBehaviorContext()->logger->publishFailureMessage(
name(), fmt::format("Tray AprilTag with ID {} not found in detections.", tray_apriltag_id));
return BT::NodeStatus::FAILURE;
}
Expand Down Expand Up @@ -168,14 +168,14 @@ BT::NodeStatus ComputeTrayPlacePositionsUsingAprilTags::tick()
}

// Look up camera_frame -> "world" transform
if (!shared_resources_->transform_buffer_ptr->canTransform("world", camera_frame, tf2::TimePointZero))
if (!getBehaviorContext()->transform_buffer_ptr->canTransform("world", camera_frame, tf2::TimePointZero))
{
shared_resources_->logger->publishFailureMessage(name(), fmt::format("Cannot transform between '{}' and 'world'.",
camera_frame));
getBehaviorContext()->logger->publishFailureMessage(
name(), fmt::format("Cannot transform between '{}' and 'world'.", camera_frame));
return BT::NodeStatus::FAILURE;
}
const geometry_msgs::msg::TransformStamped camera_to_world_tf =
shared_resources_->transform_buffer_ptr->lookupTransform("world", camera_frame, tf2::TimePointZero);
getBehaviorContext()->transform_buffer_ptr->lookupTransform("world", camera_frame, tf2::TimePointZero);
const Eigen::Isometry3d camera_to_world = tf2::transformToEigen(camera_to_world_tf);

// Transform all positions to world frame with gripper-down orientation (x=1, y=0, z=0, w=0)
Expand All @@ -201,14 +201,14 @@ BT::NodeStatus ComputeTrayPlacePositionsUsingAprilTags::tick()
const auto maybe_image = getInput<sensor_msgs::msg::Image>(kPortIDInputImage);
if (!maybe_image.has_value())
{
shared_resources_->logger->publishInfoMessage(name(), "No input_image provided; skipping visualization.");
getBehaviorContext()->logger->publishInfoMessage(name(), "No input_image provided; skipping visualization.");
}
else
{
try
{
const auto viz_topic = getInput<std::string>(kPortIDVisualizationTopic).value();
ros_publisher_interface_->init(viz_topic, shared_resources_);
ros_publisher_interface_->init(viz_topic, getBehaviorContext());

const double fx = camera_info.k[0];
const double fy = camera_info.k[4];
Expand Down Expand Up @@ -260,8 +260,8 @@ BT::NodeStatus ComputeTrayPlacePositionsUsingAprilTags::tick()
}
catch (const cv_bridge::Exception& e)
{
shared_resources_->logger->publishFailureMessage(name(), fmt::format("cv_bridge error during visualization: {}",
e.what()));
getBehaviorContext()->logger->publishFailureMessage(
name(), fmt::format("cv_bridge error during visualization: {}", e.what()));
}
}

Expand Down
Loading