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

Check limb swing motion has been finished at the end of ConfigMotion if exitWhenLimbSwingFinished is true #10

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
3 changes: 3 additions & 0 deletions include/MultiContactController/LimbManagerSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class LimbManagerSet : public std::unordered_map<Limb, std::shared_ptr<LimbManag
/** \brief Get whether future contact command is stacked. */
bool contactCommandStacked() const;

/** \brief Get whether any limbs are executing swing motion. */
bool isExecutingLimbSwing() const;

/** \brief Get limbs of the specified group.
\param group limb group
*/
Expand Down
3 changes: 3 additions & 0 deletions include/MultiContactController/states/ConfigMotionState.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ struct ConfigMotionState : State

//! Task configuration list
std::multimap<double, mc_rtc::Configuration> taskConfigList_;

//! Option to select whether this state should wait for finishing swing motion or not
bool exitWhenLimbSwingFinished_ = false;
};
} // namespace MCC
13 changes: 13 additions & 0 deletions src/LimbManagerSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ bool LimbManagerSet::contactCommandStacked() const
return false;
}

bool LimbManagerSet::isExecutingLimbSwing() const
{
for(const auto & limbManagerKV : *this)
{
const auto & contactCommandList = limbManagerKV.second->contactCommandList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line seems unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 97b00df

if(limbManagerKV.second->currentSwingCommand_ != nullptr)
{
return true;
}
}
return false;
}

void LimbManagerSet::addToGUI(mc_rtc::gui::StateBuilder & gui)
{
for(const auto & limbManagerKV : *this)
Expand Down
9 changes: 8 additions & 1 deletion src/states/ConfigMotionState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ void ConfigMotionState::start(mc_control::fsm::Controller & _ctl)
}
}

// Set option to wait for finishing swing motion
if(config_.has("configs") && config_("configs").has("exitWhenLimbSwingFinished"))
Copy link
Member

@mmurooka mmurooka Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, you don't need to change it as I wrote in the following comment.

Same as https://github.com/isri-aist/MultiContactController/pull/7/files#r1560534133

{
exitWhenLimbSwingFinished_ = static_cast<bool>(config_("configs")("exitWhenLimbSwingFinished"));
}

output("OK");
}

Expand Down Expand Up @@ -161,7 +167,8 @@ bool ConfigMotionState::run(mc_control::fsm::Controller &)
}
}

return !ctl().limbManagerSet_->contactCommandStacked() && taskConfigList_.empty() && collisionConfigList_.empty();
return !ctl().limbManagerSet_->contactCommandStacked() && taskConfigList_.empty() && collisionConfigList_.empty()
&& (!exitWhenLimbSwingFinished_ || !ctl().limbManagerSet_->isExecutingLimbSwing());
}

void ConfigMotionState::teardown(mc_control::fsm::Controller &) {}
Expand Down