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

feat(default_ad_api): update pause interface request #3437

Closed
Closed
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
9 changes: 6 additions & 3 deletions system/default_ad_api/src/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ MotionNode::MotionNode(const rclcpp::NodeOptions & options)

void MotionNode::update_state()
{
if (!is_paused_ || !is_start_requested_) {
if (!is_paused_by_node_ || !is_start_requested_) {
return;
}

const auto get_next_state = [this]() {
if (is_paused_.value()) {
if (is_paused_by_node_.value()) {
if (!is_start_requested_.value()) {
return State::Paused;
} else {
Expand Down Expand Up @@ -112,6 +112,7 @@ void MotionNode::change_pause(bool pause)
if (!is_calling_set_pause_ && cli_set_pause_->service_is_ready()) {
const auto req = std::make_shared<control_interface::SetPause::Service::Request>();
req->pause = pause;
req->request_source = "default_ad_api";
is_calling_set_pause_ = true;
cli_set_pause_->async_send_request(req, [this](auto) { is_calling_set_pause_ = false; });
}
Expand All @@ -131,7 +132,9 @@ void MotionNode::on_timer()

void MotionNode::on_is_paused(const control_interface::IsPaused::Message::ConstSharedPtr msg)
{
is_paused_ = msg->data;
is_paused_by_node_ = msg->data && std::find(
msg->requested_sources.begin(), msg->requested_sources.end(),
"default_ad_api") != msg->requested_sources.end();
}

void MotionNode::on_is_start_requested(
Expand Down
2 changes: 1 addition & 1 deletion system/default_ad_api/src/motion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MotionNode : public rclcpp::Node

enum class State { Unknown, Pausing, Paused, Starting, Resuming, Resumed, Moving };
State state_;
std::optional<bool> is_paused_;
std::optional<bool> is_paused_by_node_;
std::optional<bool> is_start_requested_;

double stop_check_duration_;
Expand Down