mirror of
https://github.com/modelec/modelec-marcel-ROS.git
synced 2026-01-18 16:47:43 +01:00
send one time
This commit is contained in:
@@ -38,6 +38,8 @@ namespace Modelec
|
|||||||
bool enemy_initialized_ = false;
|
bool enemy_initialized_ = false;
|
||||||
rclcpp::Time last_publish_time_;
|
rclcpp::Time last_publish_time_;
|
||||||
|
|
||||||
|
bool is_enemy_close_ = false;
|
||||||
|
|
||||||
float min_move_threshold_mm_ = 0.0f;
|
float min_move_threshold_mm_ = 0.0f;
|
||||||
float refresh_rate_s_ = 0.0f;
|
float refresh_rate_s_ = 0.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -138,16 +138,27 @@ namespace Modelec
|
|||||||
// Check if in bounds
|
// Check if in bounds
|
||||||
if (x_global >= 0 && x_global <= (map_width_ - margin_detection_table_) && y_global >= 0 && y_global <= (map_height_ - margin_detection_table_))
|
if (x_global >= 0 && x_global <= (map_width_ - margin_detection_table_) && y_global >= 0 && y_global <= (map_height_ - margin_detection_table_))
|
||||||
{
|
{
|
||||||
modelec_interfaces::msg::OdometryPos emergency_msg;
|
if (!is_enemy_close_)
|
||||||
emergency_msg.x = x_global;
|
{
|
||||||
emergency_msg.y = y_global;
|
modelec_interfaces::msg::OdometryPos emergency_msg;
|
||||||
emergency_msg.theta = 0.0;
|
emergency_msg.x = x_global;
|
||||||
|
emergency_msg.y = y_global;
|
||||||
|
emergency_msg.theta = 0.0;
|
||||||
|
|
||||||
close_enemy_pos_pub_->publish(emergency_msg);
|
close_enemy_pos_pub_->publish(emergency_msg);
|
||||||
RCLCPP_WARN(this->get_logger(), "EMERGENCY CLOSE OBJECT DETECTED at x=%.2f y=%.2f (%.1f mm)", x_global, y_global, range_mm);
|
RCLCPP_WARN(this->get_logger(), "EMERGENCY CLOSE OBJECT DETECTED at x=%.2f y=%.2f (%.1f mm)", x_global, y_global, range_mm);
|
||||||
|
|
||||||
|
is_enemy_close_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;;
|
is_enemy_close_ = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
is_enemy_close_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to local robot frame
|
// Convert to local robot frame
|
||||||
|
|||||||
Reference in New Issue
Block a user