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

Publish zero if locked #42

Open
wants to merge 7 commits into
base: rolling
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update topic_handle.hpp
Publish zero if topic has priority and is locked
BriceRenaudeau authored May 2, 2023

Verified

This commit was signed with the committer’s verified signature.
hakimifr Hakimi
commit e8b0e85726a9705addd168822946282d66181c6d
8 changes: 7 additions & 1 deletion include/twist_mux/topic_handle.hpp
Original file line number Diff line number Diff line change
@@ -189,12 +189,18 @@ class VelocityTopicHandle : public TopicHandle_<geometry_msgs::msg::Twist>
stamp_ = mux_->now();
msg_ = *msg;

// If topic locked, overide with zero twist
const auto lock_priority = mux_->getLockPriority();
if (getPriority() < lock_priority) {
msg_ = geometry_msgs::msg::Twist();
}

// Check if this twist has priority.
// Note that we have to check all the locks because they might time out
// and since we have several topics we must look for the highest one in
// all the topic list; so far there's no O(1) solution.
if (mux_->hasPriority(*this)) {
mux_->publishTwist(msg);
mux_->publishTwist(msg_);
}
}
};