Skip to content

Commit

Permalink
Simplify thread construction
Browse files Browse the repository at this point in the history
  • Loading branch information
rjoomen committed Jan 9, 2024
1 parent a6440ac commit e343e49
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions tesseract_monitoring/src/environment_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ ROSEnvironmentMonitor::ROSEnvironmentMonitor(rclcpp::Node::SharedPtr node,
}

internal_node_executor_ = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
internal_node_spinner_ = std::make_shared<std::thread>(std::thread{ [this]() {
internal_node_spinner_ = std::make_shared<std::thread>([this]() {
internal_node_executor_->add_node(internal_node_);
internal_node_executor_->spin();
} });
});
}

ROSEnvironmentMonitor::ROSEnvironmentMonitor(rclcpp::Node::SharedPtr node,
Expand All @@ -102,10 +102,10 @@ ROSEnvironmentMonitor::ROSEnvironmentMonitor(rclcpp::Node::SharedPtr node,
RCLCPP_WARN(logger_, "ENV passed to ros env monitor did not initialize");
}
internal_node_executor_ = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
internal_node_spinner_ = std::make_shared<std::thread>(std::thread{ [this]() {
internal_node_spinner_ = std::make_shared<std::thread>([this]() {
internal_node_executor_->add_node(internal_node_);
internal_node_executor_->spin();
} });
});
}

ROSEnvironmentMonitor::~ROSEnvironmentMonitor()
Expand Down
4 changes: 2 additions & 2 deletions tesseract_rosutils/src/plotting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ ROSPlotting::ROSPlotting(std::string root_link, std::string topic_namespace)
node_->create_publisher<visualization_msgs::msg::MarkerArray>(topic_namespace + "/display_tool_path", 1);

internal_node_executor_ = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
internal_node_spinner_ = std::make_shared<std::thread>(std::thread{ [this]() {
internal_node_spinner_ = std::make_shared<std::thread>([this]() {
internal_node_executor_->add_node(node_);
internal_node_executor_->spin();
internal_node_executor_->remove_node(node_);
} });
});
}

ROSPlotting::~ROSPlotting()
Expand Down
4 changes: 2 additions & 2 deletions tesseract_rviz/src/environment_monitor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ void EnvironmentMonitorProperties::onInitialize(Ogre::SceneManager* scene_manage
data_->joint_state_topic_property->initialize(ros_node_abstraction);

data_->internal_node_executor = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
data_->internal_node_spinner = std::make_shared<std::thread>(std::thread{ [this]() {
data_->internal_node_spinner = std::make_shared<std::thread>([this]() {
data_->internal_node_executor->add_node(data_->node);
data_->internal_node_executor->spin();
data_->internal_node_executor->remove_node(data_->node);
} });
});

data_->scene_manager = scene_manager;
data_->scene_node = scene_node;
Expand Down
4 changes: 2 additions & 2 deletions tesseract_rviz/src/joint_trajectory_monitor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ void JointTrajectoryMonitorProperties::onInitialize(rviz_common::DisplayContext*
data_->tesseract_joint_trajectory_topic_property->initialize(ros_node_abstraction);

data_->internal_node_executor = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
data_->internal_node_spinner = std::make_shared<std::thread>(std::thread{ [this]() {
data_->internal_node_spinner = std::make_shared<std::thread>([this]() {
data_->internal_node_executor->add_node(data_->node);
data_->internal_node_executor->spin();
data_->internal_node_executor->remove_node(data_->node);
} });
});

onLegacyJointTrajectoryTopicConnect();
onTesseractJointTrajectoryTopicConnect();
Expand Down

0 comments on commit e343e49

Please sign in to comment.