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

Modify something to cause double shoot and continuous shoot when high frequency #160

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace rm_shooter_controllers
struct Config
{
double block_effort, block_speed, block_duration, block_overtime, anti_block_angle, anti_block_threshold,
forward_push_threshold,exit_push_threshold;
forward_push_threshold, exit_push_threshold;
double extra_wheel_speed;
};

Expand Down
35 changes: 14 additions & 21 deletions rm_shooter_controllers/src/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ void Controller::update(const ros::Time& time, const ros::Duration& period)
if (state_ != BLOCK)
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))
(std::fmod(std::abs(ctrl_trigger_.command_struct_.position_ - ctrl_trigger_.getPosition()), 2. * M_PI) <
config_.exit_push_threshold ||
cmd_.hz >= 20)))
Copy link
Contributor

Choose a reason for hiding this comment

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

这个20可以改成参数

{
state_ = cmd_.mode;
state_changed_ = true;
Expand Down Expand Up @@ -199,26 +200,17 @@ void Controller::push(const ros::Time& time, const ros::Duration& period)
{ // Time to shoot!!!
if (cmd_.hz >= 20)
Copy link
Contributor

Choose a reason for hiding this comment

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

这也也是

{
config_.forward_push_threshold += 0.5;
if (std::fmod(std::abs(ctrl_trigger_.command_struct_.position_ - ctrl_trigger_.getPosition()), 2. * M_PI) <
config_.forward_push_threshold)
{
ctrl_trigger_.setCommand(ctrl_trigger_.command_struct_.position_ -
2. * M_PI / static_cast<double>(push_per_rotation_),
-1 * cmd_.hz * 2. * M_PI / static_cast<double>(push_per_rotation_));
last_shoot_time_ = time;
}
config_.forward_push_threshold -= 0.5;
ctrl_trigger_.setCommand(ctrl_trigger_.command_struct_.position_ -
2. * M_PI / static_cast<double>(push_per_rotation_),
-1 * cmd_.hz * 2. * M_PI / static_cast<double>(push_per_rotation_));
last_shoot_time_ = time;
}
else
else if (std::fmod(std::abs(ctrl_trigger_.command_struct_.position_ - ctrl_trigger_.getPosition()), 2. * M_PI) <
config_.forward_push_threshold)
{
if (std::fmod(std::abs(ctrl_trigger_.command_struct_.position_ - ctrl_trigger_.getPosition()), 2. * M_PI) <
config_.forward_push_threshold)
{
ctrl_trigger_.setCommand(ctrl_trigger_.command_struct_.position_ -
2. * M_PI / static_cast<double>(push_per_rotation_));
last_shoot_time_ = time;
}
ctrl_trigger_.setCommand(ctrl_trigger_.command_struct_.position_ -
2. * M_PI / static_cast<double>(push_per_rotation_));
last_shoot_time_ = time;
}
// Check block
if ((ctrl_trigger_.joint_.getEffort() < -config_.block_effort &&
Expand Down Expand Up @@ -277,7 +269,8 @@ void Controller::setSpeed(const rm_msgs::ShootCmd& cmd)
void Controller::normalize()
{
double push_angle = 2. * M_PI / static_cast<double>(push_per_rotation_);
ctrl_trigger_.setCommand(push_angle * std::floor((ctrl_trigger_.joint_.getPosition() + 0.01) / push_angle));
ctrl_trigger_.setCommand(
push_angle * std::floor((ctrl_trigger_.joint_.getPosition() + 0.01 + config_.exit_push_threshold) / push_angle));
}

void Controller::reconfigCB(rm_shooter_controllers::ShooterConfig& config, uint32_t /*level*/)
Expand Down
Loading