Skip to content

Commit

Permalink
add auto start param to aruco lifecyle
Browse files Browse the repository at this point in the history
  • Loading branch information
brsbilgin authored Feb 3, 2024
1 parent 6c48787 commit b8ac673
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions aruco_opencv/src/aruco_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class ArucoTracker : public rclcpp_lifecycle::LifecycleNode
int min_board_id_for_mapping;
double translation_weight_;
double rotation_weight_;
bool auto_start_;

// ROS
OnSetParametersCallbackHandle::SharedPtr on_set_parameter_callback_handle_;
Expand Down Expand Up @@ -258,7 +259,7 @@ class ArucoTracker : public rclcpp_lifecycle::LifecycleNode
declare_param(*this, "min_board_id_for_mapping", 40);
declare_param(*this, "translation_weight", 1.0);
declare_param(*this, "rotation_weight", 1.0);

declare_param(*this, "auto_start", false, false);
declare_aruco_parameters(*this);
}

Expand All @@ -270,6 +271,10 @@ class ArucoTracker : public rclcpp_lifecycle::LifecycleNode
RCLCPP_INFO_STREAM(
get_logger(), "Assume images are rectified: " << (image_is_rectified_ ? "YES" : "NO"));

get_parameter("auto_start", auto_start_);
RCLCPP_INFO_STREAM(
get_logger(), "AutoStart is enabled: " << (auto_start_ ? "YES" : "NO"));

get_parameter("output_frame", output_frame_);
if (output_frame_.empty()) {
RCLCPP_INFO(get_logger(), "Marker detections will be published in the camera frame");
Expand Down Expand Up @@ -607,8 +612,8 @@ class ArucoTrackerAutostart : public ArucoTracker
: ArucoTracker(options)
{
auto new_state = configure();
if (new_state.label() == "inactive") {
activate();
if (new_state.label() == "inactive" and auto_start_) {
activate();
}
}
};
Expand All @@ -617,4 +622,4 @@ class ArucoTrackerAutostart : public ArucoTracker

#include "rclcpp_components/register_node_macro.hpp"
RCLCPP_COMPONENTS_REGISTER_NODE(aruco_opencv::ArucoTracker)
RCLCPP_COMPONENTS_REGISTER_NODE(aruco_opencv::ArucoTrackerAutostart)
RCLCPP_COMPONENTS_REGISTER_NODE(aruco_opencv::ArucoTrackerAutostart)

0 comments on commit b8ac673

Please sign in to comment.