Skip to content

Commit

Permalink
Fixed the of mode conflict optimized the low velocity planning for lo…
Browse files Browse the repository at this point in the history
…w radio frequency.
  • Loading branch information
Fawo011 committed Jan 5, 2024
1 parent 9cf6bdb commit b0d6774
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions rm_shooter_controllers/src/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,14 @@ void Controller::update(const ros::Time& time, const ros::Duration& period)
if (state_ != cmd_.mode)
{
if (state_ != BLOCK)
{
if (cmd_.hz >= 20)
{
if ((state_ != PUSH || cmd_.mode != READY) ||
(cmd_.mode == READY &&
std::fmod(std::abs(ctrl_trigger_.command_struct_.position_ - ctrl_trigger_.getPosition()), 2. * M_PI) <
config_.exit_push_threshold + 0.5))
{
state_ = cmd_.mode;
state_changed_ = true;
}
}
else
if ((state_ != PUSH || cmd_.mode != READY) ||
(cmd_.mode == READY &&
std::fmod(std::abs(ctrl_trigger_.command_struct_.position_ - ctrl_trigger_.getPosition()), 2. * M_PI) <
config_.exit_push_threshold))
{
if ((state_ != PUSH || cmd_.mode != READY) ||
(cmd_.mode == READY &&
std::fmod(std::abs(ctrl_trigger_.command_struct_.position_ - ctrl_trigger_.getPosition()), 2. * M_PI) <
config_.exit_push_threshold))
{
state_ = cmd_.mode;
state_changed_ = true;
}
state_ = cmd_.mode;
state_changed_ = true;
}
}
}

if (state_ != STOP)
Expand Down Expand Up @@ -199,12 +183,12 @@ void Controller::push(const ros::Time& time, const ros::Duration& period)
(static_cast<double>(push_per_rotation_) / 2))
{
expect_velocity += std::pow(-1 * cmd_.hz * 2. * M_PI / static_cast<double>(push_per_rotation_), 2) /
ctrl_trigger_.command_struct_.position_;
(2 * (ctrl_trigger_.command_struct_.position_ - 2. * M_PI / static_cast<double>(push_per_rotation_)));
}
else
{
expect_velocity -= std::pow(-1 * cmd_.hz * 2. * M_PI / static_cast<double>(push_per_rotation_), 2) /
ctrl_trigger_.command_struct_.position_;
(2 * (ctrl_trigger_.command_struct_.position_ - 2. * M_PI / static_cast<double>(push_per_rotation_)));
}
if (std::fmod(std::abs(ctrl_trigger_.command_struct_.position_ - ctrl_trigger_.getPosition()), 2. * M_PI) <
config_.forward_push_threshold)
Expand Down Expand Up @@ -242,6 +226,7 @@ void Controller::push(const ros::Time& time, const ros::Duration& period)

void Controller::block(const ros::Time& time, const ros::Duration& period)
{
expect_velocity = 0;
if (state_changed_)
{ // on enter
state_changed_ = false;
Expand Down

0 comments on commit b0d6774

Please sign in to comment.