Skip to content

Commit

Permalink
Merge pull request #99 from 1moule/switch-shoot-freq
Browse files Browse the repository at this point in the history
Switch shoot frequency
  • Loading branch information
d0h0s authored Jul 17, 2024
2 parents fd616fe + cc985c9 commit b62ee1e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/rm_manual/chassis_gimbal_shooter_cover_manual.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ChassisGimbalShooterCoverManual : public ChassisGimbalShooterManual
void rightSwitchUpRise() override;
void rPress() override;
void ePress() override;
void zPressing();
void zPress();
void zRelease();
void wPress() override;
void wPressing() override;
Expand Down
2 changes: 2 additions & 0 deletions include/rm_manual/chassis_gimbal_shooter_manual.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ChassisGimbalShooterManual : public ChassisGimbalManual
void suggestFireCallback(const std_msgs::Bool::ConstPtr& data) override;
void trackCallback(const rm_msgs::TrackData::ConstPtr& data) override;
void leftSwitchUpOn(ros::Duration duration);
void leftSwitchUpFall();
void mouseLeftPress();
void mouseLeftRelease()
{
Expand Down Expand Up @@ -119,6 +120,7 @@ class ChassisGimbalShooterManual : public ChassisGimbalManual
rm_common::CalibrationQueue* gimbal_calibration_;

geometry_msgs::PointStamped point_out_;
uint8_t last_shoot_freq_{};

bool prepare_shoot_ = false, turn_flag_ = false, is_balance_ = false, use_scope_ = false,
adjust_image_transmission_ = false;
Expand Down
9 changes: 5 additions & 4 deletions src/chassis_gimbal_shooter_cover_manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ ChassisGimbalShooterCoverManual::ChassisGimbalShooterCoverManual(ros::NodeHandle

ctrl_z_event_.setEdge(boost::bind(&ChassisGimbalShooterCoverManual::ctrlZPress, this),
boost::bind(&ChassisGimbalShooterCoverManual::ctrlZRelease, this));
z_event_.setActiveHigh(boost::bind(&ChassisGimbalShooterCoverManual::zPressing, this));
z_event_.setFalling(boost::bind(&ChassisGimbalShooterCoverManual::zRelease, this));
z_event_.setEdge(boost::bind(&ChassisGimbalShooterCoverManual::zPress, this),
boost::bind(&ChassisGimbalShooterCoverManual::zRelease, this));
}

void ChassisGimbalShooterCoverManual::changeSpeedMode(SpeedMode speed_mode)
Expand Down Expand Up @@ -159,14 +159,15 @@ void ChassisGimbalShooterCoverManual::ePress()
switch_exposure_srv_->callService();
}

void ChassisGimbalShooterCoverManual::zPressing()
void ChassisGimbalShooterCoverManual::zPress()
{
last_shoot_freq_ = shooter_cmd_sender_->getShootFrequency();
shooter_cmd_sender_->setShootFrequency(rm_common::HeatLimit::MINIMAL);
}

void ChassisGimbalShooterCoverManual::zRelease()
{
shooter_cmd_sender_->setShootFrequency(rm_common::HeatLimit::LOW);
shooter_cmd_sender_->setShootFrequency(last_shoot_freq_);
}

void ChassisGimbalShooterCoverManual::wPress()
Expand Down
9 changes: 9 additions & 0 deletions src/chassis_gimbal_shooter_manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ChassisGimbalShooterManual::ChassisGimbalShooterManual(ros::NodeHandle& nh, ros:
self_inspection_event_.setRising(boost::bind(&ChassisGimbalShooterManual::selfInspectionStart, this));
game_start_event_.setRising(boost::bind(&ChassisGimbalShooterManual::gameStart, this));
left_switch_up_event_.setActiveHigh(boost::bind(&ChassisGimbalShooterManual::leftSwitchUpOn, this, _1));
left_switch_up_event_.setFalling(boost::bind(&ChassisGimbalShooterManual::leftSwitchUpFall, this));
left_switch_mid_event_.setActiveHigh(boost::bind(&ChassisGimbalShooterManual::leftSwitchMidOn, this, _1));
e_event_.setEdge(boost::bind(&ChassisGimbalShooterManual::ePress, this),
boost::bind(&ChassisGimbalShooterManual::eRelease, this));
Expand Down Expand Up @@ -313,6 +314,12 @@ void ChassisGimbalShooterManual::leftSwitchUpRise()
{
ChassisGimbalManual::leftSwitchUpRise();
gimbal_cmd_sender_->setMode(rm_msgs::GimbalCmd::TRACK);
last_shoot_freq_ = shooter_cmd_sender_->getShootFrequency();
}

void ChassisGimbalShooterManual::leftSwitchUpFall()
{
shooter_cmd_sender_->setShootFrequency(last_shoot_freq_);
}

void ChassisGimbalShooterManual::leftSwitchUpOn(ros::Duration duration)
Expand All @@ -323,11 +330,13 @@ void ChassisGimbalShooterManual::leftSwitchUpOn(ros::Duration duration)
gimbal_cmd_sender_->setMode(rm_msgs::GimbalCmd::TRACK);
if (duration > ros::Duration(1.))
{
shooter_cmd_sender_->setShootFrequency(last_shoot_freq_);
shooter_cmd_sender_->setMode(rm_msgs::ShootCmd::PUSH);
shooter_cmd_sender_->checkError(ros::Time::now());
}
else if (duration < ros::Duration(0.02))
{
shooter_cmd_sender_->setShootFrequency(rm_common::HeatLimit::MINIMAL);
shooter_cmd_sender_->setMode(rm_msgs::ShootCmd::PUSH);
shooter_cmd_sender_->checkError(ros::Time::now());
}
Expand Down

0 comments on commit b62ee1e

Please sign in to comment.