68class Controller :
public controller_interface::MultiInterfaceController<hardware_interface::EffortJointInterface,
69 hardware_interface::VelocityJointInterface,
70 rm_control::RobotStateInterface>
74 bool init(hardware_interface::RobotHW* robot_hw, ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh)
override;
75 void update(
const ros::Time& time,
const ros::Duration& period)
override;
76 void starting(
const ros::Time& )
override;
79 void stop(
const ros::Time& time,
const ros::Duration& period);
80 void ready(
const ros::Duration& period);
81 void push(
const ros::Time& time,
const ros::Duration& period);
82 void block(
const ros::Time& time,
const ros::Duration& period);
83 void setSpeed(
const rm_msgs::ShootCmd& cmd,
const ros::Duration& period);
85 void judgeBulletShoot(
const ros::Time& time,
const ros::Duration& period);
86 void commandCB(
const rm_msgs::ShootCmdConstPtr& msg)
88 cmd_rt_buffer_.writeFromNonRT(*msg);
91 void reconfigCB(rm_dshot_shooter_controllers::ShooterConfig& config, uint32_t );
93 hardware_interface::EffortJointInterface* effort_joint_interface_{};
94 hardware_interface::VelocityJointInterface* velocity_joint_interface_{};
95 std::vector<std::vector<velocity_controllers::JointVelocityController*>> ctrls_friction_;
96 std::vector<std::vector<std::shared_ptr<control_toolbox::Pid>>> friction_pid_controllers_;
97 effort_controllers::JointPositionController ctrl_trigger_;
98 LowPassFilter* lp_filter_;
99 RampFilter<double>* wheel_speed_ramp_filter_{};
100 int push_per_rotation_{}, count_{};
101 double push_wheel_speed_threshold_{};
102 double freq_threshold_{};
103 bool dynamic_reconfig_initialized_ =
false;
104 bool state_changed_ =
false;
105 bool enter_ready_ =
false;
106 bool maybe_block_ =
false;
107 int friction_block_count = 0;
108 bool last_friction_wheel_block =
false, friction_wheel_block =
false;
109 double friction_block_vel_{};
110 double anti_friction_block_duty_cycle_{}, anti_friction_block_vel_{};
111 bool has_shoot_ =
false, has_shoot_last_ =
false;
112 bool wheel_speed_drop_ =
true;
113 double last_fricition_speed_{};
114 double last_friction_change_speed_{};
116 ros::Time last_shoot_time_, block_time_, last_block_time_;
126 realtime_tools::RealtimeBuffer<Config> config_rt_buffer;
127 realtime_tools::RealtimeBuffer<rm_msgs::ShootCmd> cmd_rt_buffer_;
128 rm_msgs::ShootCmd cmd_;
129 std::shared_ptr<realtime_tools::RealtimePublisher<rm_msgs::LocalHeatState>> local_heat_state_pub_;
130 std::shared_ptr<realtime_tools::RealtimePublisher<rm_msgs::ShootState>> shoot_state_pub_;
131 std::vector<std::vector<std::unique_ptr<realtime_tools::RealtimePublisher<control_msgs::JointControllerState>>>>
132 friction_state_publishers_;
134 ros::Subscriber cmd_subscriber_;
135 dynamic_reconfigure::Server<rm_dshot_shooter_controllers::ShooterConfig>* d_srv_{};