Skip to content

Commit

Permalink
Publish fly time.
Browse files Browse the repository at this point in the history
  • Loading branch information
1moule committed Apr 12, 2024
1 parent 96cb624 commit 393241c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include <rm_common/eigen_types.h>
#include <rm_common/ros_utilities.h>
#include <std_msgs/Bool.h>
#include <rm_msgs/GimbalDesError.h>
#include <std_msgs/Float64.h>
#include <rm_msgs/TrackData.h>
#include <rm_msgs/ShootBeforehandCmd.h>

Expand Down Expand Up @@ -90,6 +90,7 @@ class BulletSolver
std::shared_ptr<realtime_tools::RealtimePublisher<visualization_msgs::Marker>> path_desire_pub_;
std::shared_ptr<realtime_tools::RealtimePublisher<visualization_msgs::Marker>> path_real_pub_;
std::shared_ptr<realtime_tools::RealtimePublisher<rm_msgs::ShootBeforehandCmd>> shoot_beforehand_cmd_pub_;
std::shared_ptr<realtime_tools::RealtimePublisher<std_msgs::Float64>> fly_time_pub_;
ros::Subscriber identified_target_change_sub_;
ros::Time switch_armor_time_{};
realtime_tools::RealtimeBuffer<Config> config_rt_buffer_;
Expand Down
6 changes: 6 additions & 0 deletions rm_gimbal_controllers/src/bullet_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ BulletSolver::BulletSolver(ros::NodeHandle& controller_nh)
new realtime_tools::RealtimePublisher<visualization_msgs::Marker>(controller_nh, "model_real", 10));
shoot_beforehand_cmd_pub_.reset(
new realtime_tools::RealtimePublisher<rm_msgs::ShootBeforehandCmd>(controller_nh, "shoot_beforehand_cmd", 10));
fly_time_pub_.reset(new realtime_tools::RealtimePublisher<std_msgs::Float64>(controller_nh, "fly_time", 10));

identified_target_change_sub_ = controller_nh.subscribe<std_msgs::Bool>(
"/armor_processor/change", 10, &BulletSolver::identifiedTargetChangeCB, this);
Expand Down Expand Up @@ -202,6 +203,11 @@ bool BulletSolver::solve(geometry_msgs::Point pos, geometry_msgs::Vector3 vel, d
if (count >= 20 || std::isnan(error))
return false;
}
if (fly_time_pub_->trylock())
{
fly_time_pub_->msg_.data = fly_time_;
fly_time_pub_->unlockAndPublish();
}
return true;
}

Expand Down

0 comments on commit 393241c

Please sign in to comment.