Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Merge pull request #1 from peroxyacyl/2022.10.05-cache-tf-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
peroxyacyl authored Oct 11, 2022
2 parents bd2a7c6 + cf91833 commit 105a476
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/robot_state_publisher/joint_state_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class JointStateListener {
MimicMap mimic_;
bool use_tf_static_;
bool ignore_timestamp_;

std::string tf_prefix_;
bool tf_prefix_cached_;
};
}

Expand Down
12 changes: 8 additions & 4 deletions src/joint_state_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ JointStateListener::JointStateListener(const KDL::Tree& tree, const MimicMap& m,
}

JointStateListener::JointStateListener(const std::shared_ptr<RobotStatePublisher>& rsp, const MimicMap& m)
: state_publisher_(rsp), mimic_(m)
: state_publisher_(rsp), mimic_(m), tf_prefix_cached_(false)
{
ros::NodeHandle n_tilde("~");
ros::NodeHandle n;
Expand Down Expand Up @@ -92,15 +92,19 @@ JointStateListener::~JointStateListener()

std::string JointStateListener::getTFPrefix()
{
if (tf_prefix_cached_) {
return tf_prefix_;
}

ros::NodeHandle n_tilde("~");
std::string tf_prefix;

// get the tf_prefix parameter from the closest namespace
std::string tf_prefix_key;
n_tilde.searchParam("tf_prefix", tf_prefix_key);
n_tilde.param(tf_prefix_key, tf_prefix, std::string(""));
n_tilde.param(tf_prefix_key, tf_prefix_, std::string(""));
tf_prefix_cached_ = true;

return tf_prefix;
return tf_prefix_;
}

void JointStateListener::callbackFixedJoint(const ros::TimerEvent& e)
Expand Down

0 comments on commit 105a476

Please sign in to comment.