Skip to content

Commit

Permalink
Add allow_shoot mode when switching armor target.
Browse files Browse the repository at this point in the history
  • Loading branch information
liyixin135 committed Apr 15, 2024
1 parent 2af8cf0 commit 691a359
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 16 additions & 3 deletions rm_common/include/rm_common/decision/command_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <rm_msgs/ChassisCmd.h>
#include <rm_msgs/GimbalCmd.h>
#include <rm_msgs/ShootCmd.h>
#include <rm_msgs/ShootBeforehandCmd.h>
#include <rm_msgs/GimbalDesError.h>
#include <rm_msgs/StateCmd.h>
#include <rm_msgs/TrackData.h>
Expand Down Expand Up @@ -359,7 +360,7 @@ class ShooterCommandSender : public TimeStampCommandSenderBase<rm_msgs::ShootCmd
{
gimbal_des_error_ = error;
}
void updateAllowShoot(const rm_msgs::GimbalDesError& data)
void updateAllowShoot(const rm_msgs::ShootBeforehandCmd& data)
{
allow_shoot_ = data;
}
Expand All @@ -373,10 +374,21 @@ class ShooterCommandSender : public TimeStampCommandSenderBase<rm_msgs::ShootCmd
}
void checkError(const ros::Time& time)
{
if (msg_.mode == rm_msgs::ShootCmd::PUSH && time - allow_shoot_.stamp < ros::Duration(0.1))
{
if (allow_shoot_.cmd == rm_msgs::ShootBeforehandCmd::ALLOW_SHOOT)
return;
if (allow_shoot_.cmd == rm_msgs::ShootBeforehandCmd::BAN_SHOOT)
{
setMode(rm_msgs::ShootCmd::READY);
return;
}
}
if ((((gimbal_des_error_.error > gimbal_error_tolerance_ && time - gimbal_des_error_.stamp < ros::Duration(0.1)) ||
(track_data_.accel > target_acceleration_tolerance_)) ||
(!suggest_fire_.data && armor_type_ == rm_msgs::StatusChangeRequest::ARMOR_OUTPOST_BASE)) ||
(allow_shoot_.error == 0. && time - allow_shoot_.stamp < ros::Duration(0.1)))
(allow_shoot_.cmd == rm_msgs::ShootBeforehandCmd::JUDGE_BY_ERROR &&
time - allow_shoot_.stamp < ros::Duration(0.1)))
if (msg_.mode == rm_msgs::ShootCmd::PUSH)
setMode(rm_msgs::ShootCmd::READY);
}
Expand Down Expand Up @@ -464,7 +476,8 @@ class ShooterCommandSender : public TimeStampCommandSenderBase<rm_msgs::ShootCmd
double extra_wheel_speed_once_{};
double total_extra_wheel_speed_{};
rm_msgs::TrackData track_data_;
rm_msgs::GimbalDesError gimbal_des_error_, allow_shoot_;
rm_msgs::GimbalDesError gimbal_des_error_;
rm_msgs::ShootBeforehandCmd allow_shoot_;
std_msgs::Bool suggest_fire_;
uint8_t armor_type_{};
};
Expand Down
4 changes: 2 additions & 2 deletions rm_msgs/msg/ShootBeforehandCmd.msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
uint8 BAN_SHOOT = 0
uint8 ALLOW_SHOOT = 1
uint8 JUDGE_BY_ERROR = 2
uint8 JUDGE_BY_ERROR = 1
uint8 ALLOW_SHOOT = 2

uint8 cmd

Expand Down

0 comments on commit 691a359

Please sign in to comment.