57 if (!nh.getParam(
"low_shoot_frequency", low_shoot_frequency_))
58 ROS_ERROR(
"Low shoot frequency no defined (namespace: %s)", nh.getNamespace().c_str());
59 if (!nh.getParam(
"high_shoot_frequency", high_shoot_frequency_))
60 ROS_ERROR(
"High shoot frequency no defined (namespace: %s)", nh.getNamespace().c_str());
61 if (!nh.getParam(
"burst_shoot_frequency", burst_shoot_frequency_))
62 ROS_ERROR(
"Burst shoot frequency no defined (namespace: %s)", nh.getNamespace().c_str());
63 if (!nh.getParam(
"minimal_shoot_frequency", minimal_shoot_frequency_))
64 ROS_ERROR(
"Minimal shoot frequency no defined (namespace: %s)", nh.getNamespace().c_str());
65 if (!nh.getParam(
"outpost_shoot_frequency", outpost_shoot_frequency_))
66 ROS_ERROR(
"Outpost shoot frequency no defined (namespace: %s)", nh.getNamespace().c_str());
67 if (!nh.getParam(
"safe_shoot_frequency", safe_shoot_frequency_))
68 ROS_ERROR(
"Safe shoot frequency no defined (namespace: %s)", nh.getNamespace().c_str());
69 if (!nh.getParam(
"heat_coeff", heat_coeff_))
70 ROS_ERROR(
"Heat coeff no defined (namespace: %s)", nh.getNamespace().c_str());
71 if (!nh.getParam(
"type", type_))
72 ROS_ERROR(
"Shooter type no defined (namespace: %s)", nh.getNamespace().c_str());
73 if (!nh.getParam(
"local_heat_protect_threshold", heat_protect_threshold_))
74 ROS_ERROR(
"Local heat protect threshold no defined (namespace: %s)", nh.getNamespace().c_str());
75 if (!nh.getParam(
"buff_offset", buff_offset_))
76 ROS_ERROR(
"Buff offset no defined (namespace: %s)", nh.getNamespace().c_str());
77 nh.param(
"use_local_heat", use_local_heat_,
true);
78 if (type_ ==
"ID1_42MM")
82 local_heat_pub_ = nh.advertise<rm_msgs::LocalHeatData>(
"/local_heat_state/local_cooling_heat", 10);
84 nh.subscribe<rm_msgs::LocalHeatState>(
"/local_heat_state/shooter_state", 50, &
HeatLimit::heatCB,
this);
86 fly_time_sub_ = nh.subscribe<std_msgs::Float64>(
"/controllers/gimbal_controller/bullet_solver/fly_time", 10,
98 void heatCB(
const rm_msgs::LocalHeatStateConstPtr& msg)
100 std::lock_guard<std::mutex> lock(heat_mutex_);
101 if (msg->has_shoot && last_shoot_state_ != msg->has_shoot)
103 local_shooter_cooling_heat_ += bullet_heat_;
104 if (local_shooter_cooling_heat_ > 0)
107 last_shoot_state_ = msg->has_shoot;
112 std::lock_guard<std::mutex> lock(heat_mutex_);
113 if (local_shooter_cooling_heat_ > 0.0)
114 local_shooter_cooling_heat_ -= shooter_cooling_rate_ * 0.1;
115 if (local_shooter_cooling_heat_ < 0.0)
117 local_shooter_cooling_heat_ = 0.0;
120 local_heat_pub_data_.once_shoot_num = once_shoot_num_;
121 local_heat_pub_data_.local_shooter_cooling_heat = local_shooter_cooling_heat_;
122 local_heat_pub_data_.desire_shoot_frequency = shoot_frequency_;
123 local_heat_pub_.publish(local_heat_pub_data_);
157 std::lock_guard<std::mutex> lock(heat_mutex_);
158 if (!referee_is_online_)
160 if (referee_status_change_ && abs(local_shooter_cooling_heat_ - shooter_cooling_heat_) > 10)
162 local_shooter_cooling_heat_ = shooter_cooling_heat_;
164 referee_status_change_ =
false;
165 double shooter_cooling_heat =
166 (use_local_heat_ || !referee_is_online_) ? local_shooter_cooling_heat_ : shooter_cooling_heat_;
167 if (shooter_cooling_limit_ - shooter_cooling_heat < bullet_heat_)
169 else if (shooter_cooling_limit_ - shooter_cooling_heat == bullet_heat_)
170 return shooter_cooling_rate_ / bullet_heat_;
171 else if (shooter_cooling_limit_ - shooter_cooling_heat <= bullet_heat_ * heat_coeff_)
172 return (shooter_cooling_limit_ - shooter_cooling_heat) / (bullet_heat_ * heat_coeff_) *
173 (shoot_frequency_ - shooter_cooling_rate_ / bullet_heat_) +
174 shooter_cooling_rate_ / bullet_heat_;
176 return shoot_frequency_;
250 double bullet_heat_, safe_shoot_frequency_{}, heat_coeff_{}, shoot_frequency_{}, low_shoot_frequency_{},
251 high_shoot_frequency_{}, burst_shoot_frequency_{}, minimal_shoot_frequency_{}, outpost_shoot_frequency_{};