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

Store subscriptions, so they don't get cleaned up. #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 2 additions & 3 deletions include/humanoid_base_footprint/base_footprint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <tf2_ros/transform_broadcaster.h>
#include <memory>
#include <string>
#include <vector>
#include <biped_interfaces/msg/phase.hpp>
#include <rclcpp/node.hpp>
#include <geometry_msgs/msg/transform_stamped.hpp>
Expand Down Expand Up @@ -57,9 +58,7 @@ class BaseFootprintBroadcaster : public rclcpp::Node
bool is_left_support_, got_support_foot_;
std::string base_link_frame_, base_footprint_frame_, r_sole_frame_, l_sole_frame_, odom_frame_;
void supportFootCallback(const biped_interfaces::msg::Phase msg);
rclcpp::Subscription<biped_interfaces::msg::Phase>::SharedPtr walking_support_foot_subscriber_;
rclcpp::Subscription<biped_interfaces::msg::Phase>::SharedPtr
dynamic_kick_support_foot_subscriber_;
std::vector<rclcpp::Subscription<biped_interfaces::msg::Phase>::SharedPtr> phase_subs_;

std::unique_ptr<tf2_ros::TransformBroadcaster> tfBroadcaster_;
rclcpp::TimerBase::SharedPtr timer_;
Expand Down
4 changes: 2 additions & 2 deletions src/base_footprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ BaseFootprintBroadcaster::BaseFootprintBroadcaster(const rclcpp::NodeOptions &)
std::vector<std::string> support_state_topics;
this->get_parameter("support_state_topics", support_state_topics);
for (auto topic : support_state_topics) {
this->create_subscription<biped_interfaces::msg::Phase>(
phase_subs_.emplace_back(this->create_subscription<biped_interfaces::msg::Phase>(
topic,
1,
std::bind(
&BaseFootprintBroadcaster::supportFootCallback,
this,
_1));
_1)));
}

tfBroadcaster_ = std::make_unique<tf2_ros::TransformBroadcaster>(this);
Expand Down