command_sender.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2021, Qiayuan Liao
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *******************************************************************************/
33 
34 //
35 // Created by qiayuan on 5/18/21.
36 //
37 
38 #pragma once
39 
40 #include <type_traits>
41 #include <utility>
42 
43 #include <ros/ros.h>
44 #include <rm_msgs/ChassisCmd.h>
45 #include <rm_msgs/GimbalCmd.h>
46 #include <rm_msgs/ShootCmd.h>
47 #include <rm_msgs/ShootBeforehandCmd.h>
48 #include <rm_msgs/GimbalDesError.h>
49 #include <rm_msgs/StateCmd.h>
50 #include <rm_msgs/TrackData.h>
51 #include <rm_msgs/GameRobotHp.h>
52 #include <rm_msgs/StatusChangeRequest.h>
53 #include <rm_msgs/ShootData.h>
54 #include <rm_msgs/LegCmd.h>
55 #include <geometry_msgs/TwistStamped.h>
56 #include <sensor_msgs/JointState.h>
57 #include <nav_msgs/Odometry.h>
58 #include <std_msgs/UInt8.h>
59 #include <std_msgs/Float64.h>
60 #include <rm_msgs/MultiDofCmd.h>
61 #include <std_msgs/String.h>
62 #include <std_msgs/Bool.h>
63 #include <control_msgs/JointControllerState.h>
64 
70 
71 namespace rm_common
72 {
73 template <class MsgType>
74 class CommandSenderBase
75 {
76 public:
78  {
79  if (!nh.getParam("topic", topic_))
80  ROS_ERROR("Topic name no defined (namespace: %s)", nh.getNamespace().c_str());
81  queue_size_ = getParam(nh, "queue_size", 1);
82  pub_ = nh.advertise<MsgType>(topic_, queue_size_);
83  }
84  void setMode(int mode)
85  {
86  if (!std::is_same<MsgType, geometry_msgs::Twist>::value && !std::is_same<MsgType, std_msgs::Float64>::value)
87  msg_.mode = mode;
88  }
89  virtual void sendCommand(const ros::Time& time)
90  {
91  pub_.publish(msg_);
92  }
93  virtual void updateGameRobotStatus(const rm_msgs::GameRobotStatus data)
94  {
95  }
96  virtual void updateGameStatus(const rm_msgs::GameStatus data)
97  {
98  }
99  virtual void updateCapacityData(const rm_msgs::PowerManagementSampleAndStatusData data)
100  {
101  }
102  virtual void updatePowerHeatData(const rm_msgs::PowerHeatData data)
103  {
104  }
105  virtual void setZero() = 0;
106  MsgType* getMsg()
107  {
108  return &msg_;
109  }
110 
111 protected:
112  std::string topic_;
113  uint32_t queue_size_;
115  MsgType msg_;
116 };
117 
118 template <class MsgType>
119 class TimeStampCommandSenderBase : public CommandSenderBase<MsgType>
120 {
121 public:
123  {
124  }
125  void sendCommand(const ros::Time& time) override
126  {
129  }
130 };
131 
132 template <class MsgType>
133 class HeaderStampCommandSenderBase : public CommandSenderBase<MsgType>
134 {
135 public:
137  {
138  }
139  void sendCommand(const ros::Time& time) override
140  {
141  CommandSenderBase<MsgType>::msg_.header.stamp = time;
143  }
144 };
145 
146 class Vel2DCommandSender : public CommandSenderBase<geometry_msgs::Twist>
147 {
148 public:
150  {
151  XmlRpc::XmlRpcValue xml_rpc_value;
152  if (!nh.getParam("max_linear_x", xml_rpc_value))
153  ROS_ERROR("Max X linear velocity no defined (namespace: %s)", nh.getNamespace().c_str());
154  else
155  max_linear_x_.init(xml_rpc_value);
156  if (!nh.getParam("max_linear_y", xml_rpc_value))
157  ROS_ERROR("Max Y linear velocity no defined (namespace: %s)", nh.getNamespace().c_str());
158  else
159  max_linear_y_.init(xml_rpc_value);
160  if (!nh.getParam("max_angular_z", xml_rpc_value))
161  ROS_ERROR("Max Z angular velocity no defined (namespace: %s)", nh.getNamespace().c_str());
162  else
163  max_angular_z_.init(xml_rpc_value);
164  std::string topic;
165  nh.getParam("power_limit_topic", topic);
166  target_vel_yaw_threshold_ = getParam(nh, "target_vel_yaw_threshold", 3.);
168  nh.subscribe<rm_msgs::ChassisCmd>(topic, 1, &Vel2DCommandSender::chassisCmdCallback, this);
169  }
170 
171  void updateTrackData(const rm_msgs::TrackData& data)
172  {
173  track_data_ = data;
174  }
175  void setLinearXVel(double scale)
176  {
177  msg_.linear.x = scale * max_linear_x_.output(power_limit_);
178  };
179  void setLinearYVel(double scale)
180  {
181  msg_.linear.y = scale * max_linear_y_.output(power_limit_);
182  };
183  void setAngularZVel(double scale)
184  {
186  vel_direction_ = -1.;
188  vel_direction_ = 1.;
189  msg_.angular.z = scale * max_angular_z_.output(power_limit_) * vel_direction_;
190  };
191  void setAngularZVel(double scale, double limit)
192  {
194  vel_direction_ = -1.;
196  vel_direction_ = 1.;
197  double angular_z = max_angular_z_.output(power_limit_) > limit ? limit : max_angular_z_.output(power_limit_);
198  msg_.angular.z = scale * angular_z * vel_direction_;
199  };
200  void set2DVel(double scale_x, double scale_y, double scale_z)
201  {
202  setLinearXVel(scale_x);
203  setLinearYVel(scale_y);
204  setAngularZVel(scale_z);
205  }
206  void setZero() override
207  {
208  msg_.linear.x = 0.;
209  msg_.linear.y = 0.;
210  msg_.angular.z = 0.;
211  }
212 
213 protected:
214  void chassisCmdCallback(const rm_msgs::ChassisCmd::ConstPtr& msg)
215  {
216  power_limit_ = msg->power_limit;
217  }
218 
220  double power_limit_ = 0.;
221  double target_vel_yaw_threshold_{};
222  double vel_direction_ = 1.;
224  rm_msgs::TrackData track_data_;
225 };
226 
227 class ChassisCommandSender : public TimeStampCommandSenderBase<rm_msgs::ChassisCmd>
228 {
229 public:
231  {
232  XmlRpc::XmlRpcValue xml_rpc_value;
233  power_limit_ = new PowerLimit(nh);
234  if (!nh.getParam("accel_x", xml_rpc_value))
235  ROS_ERROR("Accel X no defined (namespace: %s)", nh.getNamespace().c_str());
236  else
237  accel_x_.init(xml_rpc_value);
238  if (!nh.getParam("accel_y", xml_rpc_value))
239  ROS_ERROR("Accel Y no defined (namespace: %s)", nh.getNamespace().c_str());
240  else
241  accel_y_.init(xml_rpc_value);
242  if (!nh.getParam("accel_z", xml_rpc_value))
243  ROS_ERROR("Accel Z no defined (namespace: %s)", nh.getNamespace().c_str());
244  else
245  accel_z_.init(xml_rpc_value);
246  }
247 
248  void updateSafetyPower(int safety_power)
249  {
251  }
252  void updateGameRobotStatus(const rm_msgs::GameRobotStatus data) override
253  {
255  }
256  void updatePowerHeatData(const rm_msgs::PowerHeatData data) override
257  {
259  }
260  void updateCapacityData(const rm_msgs::PowerManagementSampleAndStatusData data) override
261  {
263  }
264  void updateRefereeStatus(bool status)
265  {
267  }
268  void setFollowVelDes(double follow_vel_des)
269  {
270  msg_.follow_vel_des = follow_vel_des;
271  }
272  void sendChassisCommand(const ros::Time& time, bool is_gyro)
273  {
274  power_limit_->setLimitPower(msg_, is_gyro);
275  msg_.accel.linear.x = accel_x_.output(msg_.power_limit);
276  msg_.accel.linear.y = accel_y_.output(msg_.power_limit);
277  msg_.accel.angular.z = accel_z_.output(msg_.power_limit);
279  }
280  void setZero() override{};
281  PowerLimit* power_limit_;
282 
283 private:
285 };
286 
287 class GimbalCommandSender : public TimeStampCommandSenderBase<rm_msgs::GimbalCmd>
288 {
289 public:
291  {
292  if (!nh.getParam("max_yaw_vel", max_yaw_vel_))
293  ROS_ERROR("Max yaw velocity no defined (namespace: %s)", nh.getNamespace().c_str());
294  if (!nh.getParam("max_pitch_vel", max_pitch_vel_))
295  ROS_ERROR("Max pitch velocity no defined (namespace: %s)", nh.getNamespace().c_str());
296  if (!nh.getParam("time_constant_rc", time_constant_rc_))
297  ROS_ERROR("Time constant rc no defined (namespace: %s)", nh.getNamespace().c_str());
298  if (!nh.getParam("time_constant_pc", time_constant_pc_))
299  ROS_ERROR("Time constant pc no defined (namespace: %s)", nh.getNamespace().c_str());
300  if (!nh.getParam("track_timeout", track_timeout_))
301  ROS_ERROR("Track timeout no defined (namespace: %s)", nh.getNamespace().c_str());
302  if (!nh.getParam("eject_sensitivity", eject_sensitivity_))
304  }
305  ~GimbalCommandSender() = default;
306  void setRate(double scale_yaw, double scale_pitch)
307  {
308  if (std::abs(scale_yaw) > 1)
309  scale_yaw = scale_yaw > 0 ? 1 : -1;
310  if (std::abs(scale_pitch) > 1)
311  scale_pitch = scale_pitch > 0 ? 1 : -1;
312  double time_constant{};
313  if (use_rc_)
314  time_constant = time_constant_rc_;
315  else
316  time_constant = time_constant_pc_;
317  msg_.rate_yaw = msg_.rate_yaw + (scale_yaw * max_yaw_vel_ - msg_.rate_yaw) * (0.001 / (time_constant + 0.001));
318  msg_.rate_pitch =
319  msg_.rate_pitch + (scale_pitch * max_pitch_vel_ - msg_.rate_pitch) * (0.001 / (time_constant + 0.001));
320  if (eject_flag_)
321  {
322  msg_.rate_yaw *= eject_sensitivity_;
323  msg_.rate_pitch *= eject_sensitivity_;
324  }
325  }
326  void setGimbalTraj(double traj_yaw, double traj_pitch)
327  {
328  msg_.traj_yaw = traj_yaw;
329  msg_.traj_pitch = traj_pitch;
330  }
331  void setGimbalTrajFrameId(const std::string& traj_frame_id)
332  {
333  msg_.traj_frame_id = traj_frame_id;
334  }
335  void setZero() override
336  {
337  msg_.rate_yaw = 0.;
338  msg_.rate_pitch = 0.;
339  }
340  void setBulletSpeed(double bullet_speed)
341  {
342  msg_.bullet_speed = bullet_speed;
343  }
344  void setEject(bool flag)
345  {
346  eject_flag_ = flag;
347  }
348  void setUseRc(bool flag)
349  {
350  use_rc_ = flag;
351  }
352  bool getEject() const
353  {
354  return eject_flag_;
355  }
356  void setPoint(geometry_msgs::PointStamped point)
357  {
358  msg_.target_pos = point;
359  }
360 
361 private:
364  bool eject_flag_{}, use_rc_{};
365 };
366 
367 class ShooterCommandSender : public TimeStampCommandSenderBase<rm_msgs::ShootCmd>
368 {
369 public:
371  {
372  ros::NodeHandle limit_nh(nh, "heat_limit");
373  heat_limit_ = new HeatLimit(limit_nh);
374  nh.param("speed_10m_per_speed", speed_10_, 10.);
375  nh.param("speed_15m_per_speed", speed_15_, 15.);
376  nh.param("speed_16m_per_speed", speed_16_, 16.);
377  nh.param("speed_18m_per_speed", speed_18_, 18.);
378  nh.param("speed_30m_per_speed", speed_30_, 30.);
379  nh.getParam("wheel_speed_10", wheel_speed_10_);
380  nh.getParam("wheel_speed_15", wheel_speed_15_);
381  nh.getParam("wheel_speed_16", wheel_speed_16_);
382  nh.getParam("wheel_speed_18", wheel_speed_18_);
383  nh.getParam("wheel_speed_30", wheel_speed_30_);
384  nh.param("speed_oscillation", speed_oscillation_, 1.0);
385  nh.param("extra_wheel_speed_once", extra_wheel_speed_once_, 0.);
386  nh.param("extra_speed_for_deploy", extra_speed_for_deploy_, 85.0);
387  if (!nh.getParam("auto_wheel_speed", auto_wheel_speed_))
388  ROS_INFO("auto_wheel_speed no defined (namespace: %s), set to false.", nh.getNamespace().c_str());
389  if (!nh.getParam("target_acceleration_tolerance", target_acceleration_tolerance_))
390  {
392  ROS_INFO("target_acceleration_tolerance no defined(namespace: %s), set to zero.", nh.getNamespace().c_str());
393  }
394  if (!nh.getParam("track_armor_error_tolerance", track_armor_error_tolerance_))
395  ROS_ERROR("track armor error tolerance no defined (namespace: %s)", nh.getNamespace().c_str());
396  nh.param("untrack_armor_error_tolerance", untrack_armor_error_tolerance_, track_armor_error_tolerance_);
397  nh.param("track_buff_error_tolerance", track_buff_error_tolerance_, track_armor_error_tolerance_);
398  if (!nh.getParam("max_track_target_vel", max_track_target_vel_))
399  {
400  max_track_target_vel_ = 9.0;
401  ROS_ERROR("max track target vel no defined (namespace: %s)", nh.getNamespace().c_str());
402  }
403  }
405  {
406  delete heat_limit_;
407  }
408 
409  void updateGameRobotStatus(const rm_msgs::GameRobotStatus data) override
410  {
412  }
413  void updatePowerHeatData(const rm_msgs::PowerHeatData data) override
414  {
416  }
417  void updateRefereeStatus(bool status)
418  {
419  heat_limit_->setRefereeStatus(status);
420  }
421  void updateGimbalDesError(const rm_msgs::GimbalDesError& error)
422  {
423  gimbal_des_error_ = error;
424  }
425  void updateShootBeforehandCmd(const rm_msgs::ShootBeforehandCmd& data)
426  {
427  shoot_beforehand_cmd_ = data;
428  }
429  void updateTrackData(const rm_msgs::TrackData& data)
430  {
431  track_data_ = data;
432  }
433  void updateSuggestFireData(const std_msgs::Bool& data)
434  {
436  }
437  void updateShootData(const rm_msgs::ShootData& data)
438  {
439  shoot_data_ = data;
441  {
442  if (last_bullet_speed_ == 0.0)
444  if (shoot_data_.bullet_speed != last_bullet_speed_)
445  {
447  {
449  }
451  {
453  }
454  }
455  if (shoot_data_.bullet_speed != 0.0)
457  }
458  }
459  void checkError(const ros::Time& time)
460  {
461  if (msg_.mode == rm_msgs::ShootCmd::PUSH && time - shoot_beforehand_cmd_.stamp < ros::Duration(0.1))
462  {
463  if (shoot_beforehand_cmd_.cmd == rm_msgs::ShootBeforehandCmd::ALLOW_SHOOT)
464  return;
465  if (shoot_beforehand_cmd_.cmd == rm_msgs::ShootBeforehandCmd::BAN_SHOOT)
466  {
467  setMode(rm_msgs::ShootCmd::READY);
468  return;
469  }
470  }
471  double gimbal_error_tolerance;
472  if (track_data_.id == 12)
473  gimbal_error_tolerance = track_buff_error_tolerance_;
474  else if (std::abs(track_data_.v_yaw) < max_track_target_vel_)
475  gimbal_error_tolerance = track_armor_error_tolerance_;
476  else
477  gimbal_error_tolerance = untrack_armor_error_tolerance_;
478  if (((gimbal_des_error_.error > gimbal_error_tolerance && time - gimbal_des_error_.stamp < ros::Duration(0.1)) ||
480  (!suggest_fire_.data && armor_type_ == rm_msgs::StatusChangeRequest::ARMOR_OUTPOST_BASE))
481  if (msg_.mode == rm_msgs::ShootCmd::PUSH)
482  setMode(rm_msgs::ShootCmd::READY);
483  }
484  void sendCommand(const ros::Time& time) override
485  {
486  msg_.wheel_speed = getWheelSpeedDes();
489  }
490  double getSpeed()
491  {
493  return speed_des_;
494  }
495  double getWheelSpeedDes()
496  {
499  }
501  {
502  switch (heat_limit_->getSpeedLimit())
503  {
504  case rm_msgs::ShootCmd::SPEED_10M_PER_SECOND:
505  {
506  speed_limit_ = 10.0;
509  break;
510  }
511  case rm_msgs::ShootCmd::SPEED_15M_PER_SECOND:
512  {
513  speed_limit_ = 15.0;
516  break;
517  }
518  case rm_msgs::ShootCmd::SPEED_16M_PER_SECOND:
519  {
520  speed_limit_ = 16.0;
523  break;
524  }
525  case rm_msgs::ShootCmd::SPEED_18M_PER_SECOND:
526  {
527  speed_limit_ = 18.0;
530  break;
531  }
532  case rm_msgs::ShootCmd::SPEED_30M_PER_SECOND:
533  {
534  speed_limit_ = 30.0;
537  break;
538  }
539  }
540  }
541  void dropSpeed()
542  {
544  }
545  void raiseSpeed()
546  {
548  }
549  void deploySpeed()
550  {
552  }
553  void exitDeploySpeed()
554  {
556  }
557  void setArmorType(uint8_t armor_type)
558  {
559  armor_type_ = armor_type;
560  }
561  void setShootFrequency(uint8_t mode)
562  {
564  }
565  uint8_t getShootFrequency()
566  {
568  }
569  void setZero() override{};
570  HeatLimit* heat_limit_{};
571 
572 private:
579  double max_track_target_vel_{};
581  double extra_wheel_speed_once_{};
582  double total_extra_wheel_speed_{};
583  double extra_speed_for_deploy_{};
584  bool auto_wheel_speed_ = false;
585  rm_msgs::TrackData track_data_;
586  rm_msgs::GimbalDesError gimbal_des_error_;
587  rm_msgs::ShootBeforehandCmd shoot_beforehand_cmd_;
588  rm_msgs::ShootData shoot_data_;
589  std_msgs::Bool suggest_fire_;
590  uint8_t armor_type_{};
591 };
592 
593 class BalanceCommandSender : public CommandSenderBase<std_msgs::UInt8>
594 {
595 public:
597  {
598  }
599 
600  void setBalanceMode(const int mode)
601  {
602  msg_.data = mode;
603  }
605  {
606  return msg_.data;
607  }
608  void setZero() override{};
609 };
610 
611 class LegCommandSender : public CommandSenderBase<rm_msgs::LegCmd>
612 {
613 public:
614  explicit LegCommandSender(ros::NodeHandle& nh) : CommandSenderBase<rm_msgs::LegCmd>(nh)
615  {
616  }
617 
618  void setJump(bool jump)
619  {
620  msg_.jump = jump;
621  }
622  void setLgeLength(double length)
623  {
624  msg_.leg_length = length;
625  }
626  bool getJump()
627  {
628  return msg_.jump;
629  }
630  double getLgeLength()
631  {
632  return msg_.leg_length;
633  }
634  void setZero() override{};
635 };
636 
637 class Vel3DCommandSender : public HeaderStampCommandSenderBase<geometry_msgs::TwistStamped>
638 {
639 public:
641  {
642  if (!nh.getParam("max_linear_x", max_linear_x_))
643  ROS_ERROR("Max X linear velocity no defined (namespace: %s)", nh.getNamespace().c_str());
644  if (!nh.getParam("max_linear_y", max_linear_y_))
645  ROS_ERROR("Max Y linear velocity no defined (namespace: %s)", nh.getNamespace().c_str());
646  if (!nh.getParam("max_linear_z", max_linear_z_))
647  ROS_ERROR("Max Z linear velocity no defined (namespace: %s)", nh.getNamespace().c_str());
648  if (!nh.getParam("max_angular_x", max_angular_x_))
649  ROS_ERROR("Max X linear velocity no defined (namespace: %s)", nh.getNamespace().c_str());
650  if (!nh.getParam("max_angular_y", max_angular_y_))
651  ROS_ERROR("Max Y angular velocity no defined (namespace: %s)", nh.getNamespace().c_str());
652  if (!nh.getParam("max_angular_z", max_angular_z_))
653  ROS_ERROR("Max Z angular velocity no defined (namespace: %s)", nh.getNamespace().c_str());
654  }
655  void setLinearVel(double scale_x, double scale_y, double scale_z)
656  {
657  msg_.twist.linear.x = max_linear_x_ * scale_x;
658  msg_.twist.linear.y = max_linear_y_ * scale_y;
659  msg_.twist.linear.z = max_linear_z_ * scale_z;
660  }
661  void setAngularVel(double scale_x, double scale_y, double scale_z)
662  {
663  msg_.twist.angular.x = max_angular_x_ * scale_x;
664  msg_.twist.angular.y = max_angular_y_ * scale_y;
665  msg_.twist.angular.z = max_angular_z_ * scale_z;
666  }
667  void setZero() override
668  {
669  msg_.twist.linear.x = 0.;
670  msg_.twist.linear.y = 0.;
671  msg_.twist.linear.z = 0.;
672  msg_.twist.angular.x = 0.;
673  msg_.twist.angular.y = 0.;
674  msg_.twist.angular.z = 0.;
675  }
676 
677 private:
679 };
680 
681 class JointPositionBinaryCommandSender : public CommandSenderBase<std_msgs::Float64>
682 {
683 public:
685  {
686  ROS_ASSERT(nh.getParam("on_pos", on_pos_) && nh.getParam("off_pos", off_pos_));
687  }
688  void on()
689  {
690  msg_.data = on_pos_;
691  state = true;
692  }
693  void off()
694  {
695  msg_.data = off_pos_;
696  state = false;
697  }
698  void changePosition(double scale)
699  {
700  current_position_ = msg_.data;
702  msg_.data = change_position_;
703  }
704  bool getState() const
705  {
706  return state;
707  }
708  void sendCommand(const ros::Time& time) override
709  {
711  }
712  void setZero() override{};
713 
714 private:
715  bool state{};
717 };
718 
719 class CardCommandSender : public CommandSenderBase<std_msgs::Float64>
720 {
721 public:
723  {
724  ROS_ASSERT(nh.getParam("long_pos", long_pos_) && nh.getParam("short_pos", short_pos_) &&
725  nh.getParam("off_pos", off_pos_));
726  }
727  void long_on()
728  {
729  msg_.data = long_pos_;
730  state = true;
731  }
732  void short_on()
733  {
734  msg_.data = short_pos_;
735  state = true;
736  }
737  void off()
738  {
739  msg_.data = off_pos_;
740  state = false;
741  }
742  bool getState() const
743  {
744  return state;
745  }
746  void sendCommand(const ros::Time& time) override
747  {
749  }
750  void setZero() override{};
751 
752 private:
753  bool state{};
754  double long_pos_{}, short_pos_{}, off_pos_{};
755 };
756 
757 class JointJogCommandSender : public CommandSenderBase<std_msgs::Float64>
758 {
759 public:
760  explicit JointJogCommandSender(ros::NodeHandle& nh, const sensor_msgs::JointState& joint_state)
762  {
763  ROS_ASSERT(nh.getParam("joint", joint_));
764  ROS_ASSERT(nh.getParam("step", step_));
765  }
766  void reset()
767  {
768  auto i = std::find(joint_state_.name.begin(), joint_state_.name.end(), joint_);
769  if (i != joint_state_.name.end())
770  msg_.data = joint_state_.position[std::distance(joint_state_.name.begin(), i)];
771  else
772  msg_.data = NAN;
773  }
774  void plus()
775  {
776  if (msg_.data != NAN)
777  {
778  msg_.data += step_;
780  }
781  }
782  void minus()
783  {
784  if (msg_.data != NAN)
785  {
786  msg_.data -= step_;
788  }
789  }
790  const std::string& getJoint()
791  {
792  return joint_;
793  }
794 
795 private:
796  std::string joint_{};
797  const sensor_msgs::JointState& joint_state_;
798  double step_{};
799 };
800 
801 class JointPointCommandSender : public CommandSenderBase<std_msgs::Float64>
802 {
803 public:
804  explicit JointPointCommandSender(ros::NodeHandle& nh, const sensor_msgs::JointState& joint_state)
805  : CommandSenderBase<std_msgs::Float64>(nh), joint_state_(joint_state)
806  {
807  ROS_ASSERT(nh.getParam("joint", joint_));
808  }
809  void setPoint(double point)
810  {
811  msg_.data = point;
812  }
813  int getIndex()
814  {
815  auto i = std::find(joint_state_.name.begin(), joint_state_.name.end(), joint_);
816  if (i != joint_state_.name.end())
817  {
818  index_ = std::distance(joint_state_.name.begin(), i);
819  return index_;
820  }
821  else
822  {
823  ROS_ERROR("Can not find joint %s", joint_.c_str());
824  return -1;
825  }
826  }
827  void setZero() override{};
828 
829 private:
830  std::string joint_{};
831  int index_{};
832  const sensor_msgs::JointState& joint_state_;
833 };
834 
835 class CameraSwitchCommandSender : public CommandSenderBase<std_msgs::String>
836 {
837 public:
839  {
840  ROS_ASSERT(nh.getParam("camera1_name", camera1_name_) && nh.getParam("camera2_name", camera2_name_));
841  msg_.data = camera1_name_;
842  }
843  void switchCamera()
844  {
846  }
847  void sendCommand(const ros::Time& time) override
848  {
850  }
851  void setZero() override{};
852 
853 private:
854  std::string camera1_name_{}, camera2_name_{};
855 };
856 
857 class MultiDofCommandSender : public TimeStampCommandSenderBase<rm_msgs::MultiDofCmd>
858 {
859 public:
861  {
862  }
864  void setMode(int mode)
865  {
866  msg_.mode = mode;
867  }
868  int getMode()
869  {
870  return msg_.mode;
871  }
872  void setGroupValue(double linear_x, double linear_y, double linear_z, double angular_x, double angular_y,
873  double angular_z)
874  {
875  msg_.linear.x = linear_x;
876  msg_.linear.y = linear_y;
877  msg_.linear.z = linear_z;
878  msg_.angular.x = angular_x;
879  msg_.angular.y = angular_y;
880  msg_.angular.z = angular_z;
881  }
882  void setZero() override
883  {
884  msg_.linear.x = 0;
885  msg_.linear.y = 0;
886  msg_.linear.z = 0;
887  msg_.angular.x = 0;
888  msg_.angular.y = 0;
889  msg_.angular.z = 0;
890  }
891 
892 private:
894 };
895 
897 {
898 public:
900  {
901  ros::NodeHandle shooter_ID1_nh(nh, "shooter_ID1");
902  shooter_ID1_cmd_sender_ = new ShooterCommandSender(shooter_ID1_nh);
903  ros::NodeHandle shooter_ID2_nh(nh, "shooter_ID2");
904  shooter_ID2_cmd_sender_ = new ShooterCommandSender(shooter_ID2_nh);
905  ros::NodeHandle barrel_nh(nh, "barrel");
907 
908  barrel_nh.getParam("is_double_barrel", is_double_barrel_);
909  barrel_nh.getParam("id1_point", id1_point_);
910  barrel_nh.getParam("id2_point", id2_point_);
911  barrel_nh.getParam("frequency_threshold", frequency_threshold_);
912  barrel_nh.getParam("check_launch_threshold", check_launch_threshold_);
913  barrel_nh.getParam("check_switch_threshold", check_switch_threshold_);
914  barrel_nh.getParam("ready_duration", ready_duration_);
915  barrel_nh.getParam("switching_duration", switching_duration_);
916 
917  joint_state_sub_ = nh.subscribe<sensor_msgs::JointState>("/joint_states", 10,
919  trigger_state_sub_ = nh.subscribe<control_msgs::JointControllerState>(
920  "/controllers/shooter_controller/trigger/state", 10, &DoubleBarrelCommandSender::triggerStateCallback, this);
921  }
922 
923  void updateGameRobotStatus(const rm_msgs::GameRobotStatus data)
924  {
927  }
928  void updatePowerHeatData(const rm_msgs::PowerHeatData data)
929  {
932  }
933  void updateRefereeStatus(bool status)
934  {
937  }
938  void updateGimbalDesError(const rm_msgs::GimbalDesError& error)
939  {
942  }
943  void updateTrackData(const rm_msgs::TrackData& data)
944  {
947  }
948  void updateSuggestFireData(const std_msgs::Bool& data)
949  {
952  }
953  void updateShootBeforehandCmd(const rm_msgs::ShootBeforehandCmd& data)
954  {
957  }
958 
959  void setMode(int mode)
960  {
961  getBarrel()->setMode(mode);
962  }
963  void setZero()
964  {
965  getBarrel()->setZero();
966  }
967  void checkError(const ros::Time& time)
968  {
970  }
971  void sendCommand(const ros::Time& time)
972  {
973  if (checkSwitch())
974  need_switch_ = true;
975  if (need_switch_)
976  switchBarrel();
977  checklaunch();
978  if (getBarrel()->getMsg()->mode == rm_msgs::ShootCmd::PUSH)
980  getBarrel()->sendCommand(time);
981  }
982  void init()
983  {
986  shooter_ID1_cmd_sender_->setMode(rm_msgs::ShootCmd::STOP);
987  shooter_ID2_cmd_sender_->setMode(rm_msgs::ShootCmd::STOP);
991  }
992  void setArmorType(uint8_t armor_type)
993  {
996  }
997  void setShootFrequency(uint8_t mode)
998  {
999  getBarrel()->setShootFrequency(mode);
1000  }
1001  uint8_t getShootFrequency()
1002  {
1003  return getBarrel()->getShootFrequency();
1004  }
1005  double getSpeed()
1006  {
1007  return getBarrel()->getSpeed();
1008  }
1009 
1010 private:
1011  ShooterCommandSender* getBarrel()
1012  {
1014  is_id1_ = true;
1015  else
1016  is_id1_ = false;
1018  }
1019  void switchBarrel()
1020  {
1021  ros::Time time = ros::Time::now();
1022  bool time_to_switch = (std::fmod(std::abs(trigger_error_), 2. * M_PI) < check_switch_threshold_);
1023  setMode(rm_msgs::ShootCmd::READY);
1024  if (time_to_switch || (time - last_push_time_).toSec() > ready_duration_)
1025  {
1029  last_switch_time_ = time;
1030  need_switch_ = false;
1031  is_switching_ = true;
1032  }
1033  }
1034 
1035  void checklaunch()
1036  {
1037  ros::Time time = ros::Time::now();
1038  if (is_switching_)
1039  {
1040  setMode(rm_msgs::ShootCmd::READY);
1041  if ((time - last_switch_time_).toSec() > switching_duration_ ||
1044  is_switching_ = false;
1045  }
1046  }
1047 
1048  bool checkSwitch()
1049  {
1051  return false;
1054  {
1055  ROS_WARN_ONCE("Can not get cooling limit");
1056  return false;
1057  }
1060  {
1064  else
1067  }
1068  else
1069  return false;
1070  }
1071  void triggerStateCallback(const control_msgs::JointControllerState::ConstPtr& data)
1072  {
1073  trigger_error_ = data->error;
1074  }
1075  void jointStateCallback(const sensor_msgs::JointState::ConstPtr& data)
1076  {
1077  joint_state_ = *data;
1078  }
1084  sensor_msgs::JointState joint_state_;
1085  bool is_double_barrel_{ false }, need_switch_{ false }, is_switching_{ false };
1088  double trigger_error_;
1089  bool is_id1_{ false };
1090  double id1_point_, id2_point_;
1091  double frequency_threshold_;
1093 };
1094 
1095 } // namespace rm_common
rm_common::CardCommandSender::short_pos_
double short_pos_
Definition: command_sender.h:785
rm_common::CommandSenderBase::CommandSenderBase
CommandSenderBase(ros::NodeHandle &nh)
Definition: command_sender.h:139
rm_common::MultiDofCommandSender::getMode
int getMode()
Definition: command_sender.h:899
rm_common::HeatLimit
Definition: heat_limit.h:80
rm_common::GimbalCommandSender::max_pitch_vel_
double max_pitch_vel_
Definition: command_sender.h:393
rm_common::MultiDofCommandSender::setMode
void setMode(int mode)
Definition: command_sender.h:895
rm_common::ShooterCommandSender::updateGameRobotStatus
void updateGameRobotStatus(const rm_msgs::GameRobotStatus data) override
Definition: command_sender.h:440
rm_common::DoubleBarrelCommandSender::getBarrel
ShooterCommandSender * getBarrel()
Definition: command_sender.h:1042
rm_common::Vel2DCommandSender::power_limit_
double power_limit_
Definition: command_sender.h:251
rm_common::BalanceCommandSender::getBalanceMode
int getBalanceMode()
Definition: command_sender.h:635
rm_common::CardCommandSender::setZero
void setZero() override
Definition: command_sender.h:781
rm_common::DoubleBarrelCommandSender::getShootFrequency
uint8_t getShootFrequency()
Definition: command_sender.h:1032
rm_common::MultiDofCommandSender::setGroupValue
void setGroupValue(double linear_x, double linear_y, double linear_z, double angular_x, double angular_y, double angular_z)
Definition: command_sender.h:903
rm_common::ShooterCommandSender
Definition: command_sender.h:398
ros::Publisher
rm_common::JointPositionBinaryCommandSender::off_pos_
double off_pos_
Definition: command_sender.h:747
rm_common::Vel2DCommandSender::max_linear_x_
LinearInterp max_linear_x_
Definition: command_sender.h:250
rm_common::DoubleBarrelCommandSender::setZero
void setZero()
Definition: command_sender.h:994
rm_common::HeatLimit::getSpeedLimit
int getSpeedLimit()
Definition: heat_limit.h:212
rm_common::ChassisCommandSender::accel_x_
LinearInterp accel_x_
Definition: command_sender.h:315
rm_common::ShooterCommandSender::updateGimbalDesError
void updateGimbalDesError(const rm_msgs::GimbalDesError &error)
Definition: command_sender.h:452
rm_common::JointJogCommandSender::getJoint
const std::string & getJoint()
Definition: command_sender.h:821
rm_common::Vel2DCommandSender::max_linear_y_
LinearInterp max_linear_y_
Definition: command_sender.h:250
rm_common::CommandSenderBase::topic_
std::string topic_
Definition: command_sender.h:174
rm_common::ShooterCommandSender::wheel_speed_15_
double wheel_speed_15_
Definition: command_sender.h:605
rm_common::JointJogCommandSender::plus
void plus()
Definition: command_sender.h:805
rm_common::ShooterCommandSender::track_data_
rm_msgs::TrackData track_data_
Definition: command_sender.h:616
rm_common::ChassisCommandSender
Definition: command_sender.h:258
rm_common::LinearInterp
Definition: linear_interpolation.h:11
rm_common::LegCommandSender
Definition: command_sender.h:642
rm_common::LegCommandSender::getJump
bool getJump()
Definition: command_sender.h:657
rm_common::DoubleBarrelCommandSender::setShootFrequency
void setShootFrequency(uint8_t mode)
Definition: command_sender.h:1028
rm_common::Vel2DCommandSender::chassisCmdCallback
void chassisCmdCallback(const rm_msgs::ChassisCmd::ConstPtr &msg)
Definition: command_sender.h:245
rm_common::HeatLimit::getCoolingLimit
int getCoolingLimit()
Definition: heat_limit.h:224
rm_common::Vel2DCommandSender::chassis_power_limit_subscriber_
ros::Subscriber chassis_power_limit_subscriber_
Definition: command_sender.h:254
rm_common::LegCommandSender::setJump
void setJump(bool jump)
Definition: command_sender.h:649
rm_common::Vel3DCommandSender::setZero
void setZero() override
Definition: command_sender.h:698
rm_common::GimbalCommandSender::getEject
bool getEject() const
Definition: command_sender.h:383
rm_common::ShooterCommandSender::speed_15_
double speed_15_
Definition: command_sender.h:604
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
rm_common::CardCommandSender::getState
bool getState() const
Definition: command_sender.h:773
ros.h
rm_common::ShooterCommandSender::armor_type_
uint8_t armor_type_
Definition: command_sender.h:621
rm_common::DoubleBarrelCommandSender::check_switch_threshold_
double check_switch_threshold_
Definition: command_sender.h:1123
rm_common::Vel3DCommandSender::Vel3DCommandSender
Vel3DCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:671
rm_common::LinearInterp::output
double output(double input)
Definition: linear_interpolation.h:37
rm_common::JointPositionBinaryCommandSender::off
void off()
Definition: command_sender.h:724
rm_common::ChassisCommandSender::updateSafetyPower
void updateSafetyPower(int safety_power)
Definition: command_sender.h:279
rm_common::ShooterCommandSender::track_armor_error_tolerance_
double track_armor_error_tolerance_
Definition: command_sender.h:607
rm_common::ShooterCommandSender::setZero
void setZero() override
Definition: command_sender.h:600
rm_common::CameraSwitchCommandSender::CameraSwitchCommandSender
CameraSwitchCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:869
heat_limit.h
rm_common::CommandSenderBase
Definition: command_sender.h:105
rm_common::ShooterCommandSender::updateRefereeStatus
void updateRefereeStatus(bool status)
Definition: command_sender.h:448
rm_common::DoubleBarrelCommandSender::jointStateCallback
void jointStateCallback(const sensor_msgs::JointState::ConstPtr &data)
Definition: command_sender.h:1106
rm_common::Vel3DCommandSender
Definition: command_sender.h:668
rm_common::BalanceCommandSender::BalanceCommandSender
BalanceCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:627
rm_common::CommandSenderBase::updatePowerHeatData
virtual void updatePowerHeatData(const rm_msgs::PowerHeatData data)
Definition: command_sender.h:164
rm_common::ChassisCommandSender::accel_y_
LinearInterp accel_y_
Definition: command_sender.h:315
rm_common::Vel2DCommandSender
Definition: command_sender.h:177
rm_common::PowerLimit::setLimitPower
void setLimitPower(rm_msgs::ChassisCmd &chassis_cmd, bool is_gyro)
Definition: power_limit.h:213
rm_common::Vel3DCommandSender::max_linear_x_
double max_linear_x_
Definition: command_sender.h:709
rm_common::HeaderStampCommandSenderBase
Definition: command_sender.h:164
rm_common::JointPositionBinaryCommandSender::changePosition
void changePosition(double scale)
Definition: command_sender.h:729
rm_common::DoubleBarrelCommandSender::updateSuggestFireData
void updateSuggestFireData(const std_msgs::Bool &data)
Definition: command_sender.h:979
rm_common::DoubleBarrelCommandSender::switchBarrel
void switchBarrel()
Definition: command_sender.h:1050
rm_common::BalanceCommandSender::setZero
void setZero() override
Definition: command_sender.h:639
rm_common::JointPositionBinaryCommandSender::per_change_position_
double per_change_position_
Definition: command_sender.h:747
rm_common::ShooterCommandSender::raiseSpeed
void raiseSpeed()
Definition: command_sender.h:576
rm_common::CardCommandSender::off_pos_
double off_pos_
Definition: command_sender.h:785
rm_common::DoubleBarrelCommandSender::getSpeed
double getSpeed()
Definition: command_sender.h:1036
rm_common::Vel3DCommandSender::setAngularVel
void setAngularVel(double scale_x, double scale_y, double scale_z)
Definition: command_sender.h:692
rm_common::JointPositionBinaryCommandSender::on_pos_
double on_pos_
Definition: command_sender.h:747
rm_common::CommandSenderBase::queue_size_
uint32_t queue_size_
Definition: command_sender.h:175
rm_common::CameraSwitchCommandSender::switchCamera
void switchCamera()
Definition: command_sender.h:874
rm_common::GimbalCommandSender::setUseRc
void setUseRc(bool flag)
Definition: command_sender.h:379
ros_utilities.h
rm_common::DoubleBarrelCommandSender::is_double_barrel_
bool is_double_barrel_
Definition: command_sender.h:1116
rm_common::JointPositionBinaryCommandSender::JointPositionBinaryCommandSender
JointPositionBinaryCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:715
ROS_WARN_ONCE
#define ROS_WARN_ONCE(...)
rm_common::ShooterCommandSender::speed_10_
double speed_10_
Definition: command_sender.h:604
rm_common::CardCommandSender::CardCommandSender
CardCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:753
rm_common::Vel2DCommandSender::target_vel_yaw_threshold_
double target_vel_yaw_threshold_
Definition: command_sender.h:252
rm_common::MultiDofCommandSender::~MultiDofCommandSender
~MultiDofCommandSender()=default
rm_common::ChassisCommandSender::updateGameRobotStatus
void updateGameRobotStatus(const rm_msgs::GameRobotStatus data) override
Definition: command_sender.h:283
rm_common::DoubleBarrelCommandSender::trigger_state_sub_
ros::Subscriber trigger_state_sub_
Definition: command_sender.h:1113
rm_common::HeatLimit::getShootFrequency
double getShootFrequency() const
Definition: heat_limit.h:194
rm_common::CommandSenderBase::updateGameRobotStatus
virtual void updateGameRobotStatus(const rm_msgs::GameRobotStatus data)
Definition: command_sender.h:155
rm_common::CommandSenderBase::msg_
MsgType msg_
Definition: command_sender.h:177
rm_common::Vel2DCommandSender::setAngularZVel
void setAngularZVel(double scale)
Definition: command_sender.h:214
rm_common::ChassisCommandSender::setZero
void setZero() override
Definition: command_sender.h:311
rm_common::DoubleBarrelCommandSender::updateRefereeStatus
void updateRefereeStatus(bool status)
Definition: command_sender.h:964
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
rm_common::JointJogCommandSender::JointJogCommandSender
JointJogCommandSender(ros::NodeHandle &nh, const sensor_msgs::JointState &joint_state)
Definition: command_sender.h:791
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
rm_common::JointJogCommandSender::minus
void minus()
Definition: command_sender.h:813
rm_common::DoubleBarrelCommandSender::last_push_time_
ros::Time last_push_time_
Definition: command_sender.h:1117
rm_common::GimbalCommandSender::setRate
void setRate(double scale_yaw, double scale_pitch)
Definition: command_sender.h:337
rm_common::JointPointCommandSender::JointPointCommandSender
JointPointCommandSender(ros::NodeHandle &nh, const sensor_msgs::JointState &joint_state)
Definition: command_sender.h:835
rm_common::JointPointCommandSender::getIndex
int getIndex()
Definition: command_sender.h:844
rm_common::DoubleBarrelCommandSender::trigger_error_
double trigger_error_
Definition: command_sender.h:1119
rm_common::CommandSenderBase::getMsg
MsgType * getMsg()
Definition: command_sender.h:168
rm_common::ShooterCommandSender::speed_oscillation_
double speed_oscillation_
Definition: command_sender.h:606
rm_common::GimbalCommandSender::max_yaw_vel_
double max_yaw_vel_
Definition: command_sender.h:393
filters.h
rm_common::HeatLimit::setStatusOfShooter
void setStatusOfShooter(const rm_msgs::GameRobotStatus data)
Definition: heat_limit.h:167
rm_common::ShooterCommandSender::updatePowerHeatData
void updatePowerHeatData(const rm_msgs::PowerHeatData data) override
Definition: command_sender.h:444
rm_common::PowerLimit::setRefereeStatus
void setRefereeStatus(bool status)
Definition: power_limit.h:186
rm_common::JointPositionBinaryCommandSender::sendCommand
void sendCommand(const ros::Time &time) override
Definition: command_sender.h:739
rm_common::JointPositionBinaryCommandSender::current_position_
double current_position_
Definition: command_sender.h:747
rm_common::TimeStampCommandSenderBase::TimeStampCommandSenderBase
TimeStampCommandSenderBase(ros::NodeHandle &nh)
Definition: command_sender.h:153
rm_common::Vel3DCommandSender::max_linear_y_
double max_linear_y_
Definition: command_sender.h:709
rm_common::HeatLimit::setRefereeStatus
void setRefereeStatus(bool status)
Definition: heat_limit.h:189
rm_common::ShooterCommandSender::dropSpeed
void dropSpeed()
Definition: command_sender.h:572
rm_common::GimbalCommandSender
Definition: command_sender.h:318
rm_common::LegCommandSender::setZero
void setZero() override
Definition: command_sender.h:665
rm_common::DoubleBarrelCommandSender::frequency_threshold_
double frequency_threshold_
Definition: command_sender.h:1122
rm_common::CameraSwitchCommandSender::setZero
void setZero() override
Definition: command_sender.h:882
rm_common::JointPositionBinaryCommandSender::getState
bool getState() const
Definition: command_sender.h:735
rm_common::LegCommandSender::getLgeLength
double getLgeLength()
Definition: command_sender.h:661
rm_common::PowerLimit
Definition: power_limit.h:80
rm_common::DoubleBarrelCommandSender::is_id1_
bool is_id1_
Definition: command_sender.h:1120
rm_common::DoubleBarrelCommandSender::id2_point_
double id2_point_
Definition: command_sender.h:1121
rm_common::ShooterCommandSender::~ShooterCommandSender
~ShooterCommandSender()
Definition: command_sender.h:435
rm_common::Vel3DCommandSender::setLinearVel
void setLinearVel(double scale_x, double scale_y, double scale_z)
Definition: command_sender.h:686
rm_common::CommandSenderBase::setZero
virtual void setZero()=0
rm_common::JointPositionBinaryCommandSender::change_position_
double change_position_
Definition: command_sender.h:747
rm_common::BalanceCommandSender
Definition: command_sender.h:624
rm_common::CameraSwitchCommandSender::camera1_name_
std::string camera1_name_
Definition: command_sender.h:885
rm_common::ShooterCommandSender::track_buff_error_tolerance_
double track_buff_error_tolerance_
Definition: command_sender.h:608
rm_common::CameraSwitchCommandSender
Definition: command_sender.h:866
rm_common::GimbalCommandSender::setPoint
void setPoint(geometry_msgs::PointStamped point)
Definition: command_sender.h:387
rm_common::ShooterCommandSender::getWheelSpeedDes
double getWheelSpeedDes()
Definition: command_sender.h:526
rm_common::ChassisCommandSender::power_limit_
PowerLimit * power_limit_
Definition: command_sender.h:311
rm_common::GimbalCommandSender::setZero
void setZero() override
Definition: command_sender.h:366
rm_common::CardCommandSender::long_pos_
double long_pos_
Definition: command_sender.h:785
std_msgs
rm_common::ShooterCommandSender::wheel_speed_30_
double wheel_speed_30_
Definition: command_sender.h:605
rm_common::HeatLimit::setCoolingHeatOfShooter
void setCoolingHeatOfShooter(const rm_msgs::PowerHeatData data)
Definition: heat_limit.h:173
rm_common::DoubleBarrelCommandSender::sendCommand
void sendCommand(const ros::Time &time)
Definition: command_sender.h:1002
rm_common::CommandSenderBase::setMode
void setMode(int mode)
Definition: command_sender.h:146
rm_common::ShooterCommandSender::getSpeed
double getSpeed()
Definition: command_sender.h:521
rm_common::CardCommandSender::state
bool state
Definition: command_sender.h:784
rm_common::DoubleBarrelCommandSender::last_switch_time_
ros::Time last_switch_time_
Definition: command_sender.h:1117
rm_common::DoubleBarrelCommandSender::ready_duration_
double ready_duration_
Definition: command_sender.h:1118
rm_common::TimeStampCommandSenderBase
Definition: command_sender.h:150
rm_common::ShooterCommandSender::speed_18_
double speed_18_
Definition: command_sender.h:604
rm_common::JointPointCommandSender::joint_
std::string joint_
Definition: command_sender.h:861
rm_common::LegCommandSender::setLgeLength
void setLgeLength(double length)
Definition: command_sender.h:653
rm_common
Definition: calibration_queue.h:43
rm_common::ChassisCommandSender::accel_z_
LinearInterp accel_z_
Definition: command_sender.h:315
rm_common::GimbalCommandSender::GimbalCommandSender
GimbalCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:321
rm_common::CommandSenderBase::updateGameStatus
virtual void updateGameStatus(const rm_msgs::GameStatus data)
Definition: command_sender.h:158
rm_common::ShooterCommandSender::shoot_data_
rm_msgs::ShootData shoot_data_
Definition: command_sender.h:619
rm_common::CardCommandSender::long_on
void long_on()
Definition: command_sender.h:758
rm_common::DoubleBarrelCommandSender::checkSwitch
bool checkSwitch()
Definition: command_sender.h:1079
rm_common::JointPositionBinaryCommandSender::on
void on()
Definition: command_sender.h:719
rm_common::ShooterCommandSender::extra_speed_for_deploy_
double extra_speed_for_deploy_
Definition: command_sender.h:614
rm_common::DoubleBarrelCommandSender::is_switching_
bool is_switching_
Definition: command_sender.h:1116
rm_common::LegCommandSender::LegCommandSender
LegCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:645
rm_common::DoubleBarrelCommandSender::updateGameRobotStatus
void updateGameRobotStatus(const rm_msgs::GameRobotStatus data)
Definition: command_sender.h:954
rm_common::ShooterCommandSender::suggest_fire_
std_msgs::Bool suggest_fire_
Definition: command_sender.h:620
rm_common::Vel3DCommandSender::max_linear_z_
double max_linear_z_
Definition: command_sender.h:709
rm_common::DoubleBarrelCommandSender::updateGimbalDesError
void updateGimbalDesError(const rm_msgs::GimbalDesError &error)
Definition: command_sender.h:969
rm_common::ShooterCommandSender::last_bullet_speed_
double last_bullet_speed_
Definition: command_sender.h:606
rm_common::TimeStampCommandSenderBase::sendCommand
void sendCommand(const ros::Time &time) override
Definition: command_sender.h:156
rm_common::JointPointCommandSender
Definition: command_sender.h:832
rm_common::MultiDofCommandSender::time_
ros::Time time_
Definition: command_sender.h:924
ros::NodeHandle::subscribe
Subscriber subscribe(const std::string &topic, uint32_t queue_size, const boost::function< void(C)> &callback, const VoidConstPtr &tracked_object=VoidConstPtr(), const TransportHints &transport_hints=TransportHints())
rm_common::Vel2DCommandSender::setLinearXVel
void setLinearXVel(double scale)
Definition: command_sender.h:206
rm_common::CommandSenderBase::updateCapacityData
virtual void updateCapacityData(const rm_msgs::PowerManagementSampleAndStatusData data)
Definition: command_sender.h:161
rm_common::GimbalCommandSender::eject_flag_
bool eject_flag_
Definition: command_sender.h:395
rm_common::ChassisCommandSender::updateRefereeStatus
void updateRefereeStatus(bool status)
Definition: command_sender.h:295
rm_common::CommandSenderBase::sendCommand
virtual void sendCommand(const ros::Time &time)
Definition: command_sender.h:151
rm_common::ShooterCommandSender::updateTrackData
void updateTrackData(const rm_msgs::TrackData &data)
Definition: command_sender.h:460
rm_common::JointJogCommandSender::joint_state_
const sensor_msgs::JointState & joint_state_
Definition: command_sender.h:828
rm_common::ShooterCommandSender::speed_limit_
double speed_limit_
Definition: command_sender.h:604
rm_common::ShooterCommandSender::checkError
void checkError(const ros::Time &time)
Definition: command_sender.h:490
rm_common::GimbalCommandSender::eject_sensitivity_
double eject_sensitivity_
Definition: command_sender.h:393
rm_common::Vel2DCommandSender::max_angular_z_
LinearInterp max_angular_z_
Definition: command_sender.h:250
rm_common::Vel2DCommandSender::updateTrackData
void updateTrackData(const rm_msgs::TrackData &data)
Definition: command_sender.h:202
rm_common::DoubleBarrelCommandSender::setArmorType
void setArmorType(uint8_t armor_type)
Definition: command_sender.h:1023
rm_common::HeatLimit::setShootFrequency
void setShootFrequency(uint8_t mode)
Definition: heat_limit.h:234
rm_common::DoubleBarrelCommandSender::joint_state_
sensor_msgs::JointState joint_state_
Definition: command_sender.h:1115
rm_common::DoubleBarrelCommandSender::checkError
void checkError(const ros::Time &time)
Definition: command_sender.h:998
rm_common::ShooterCommandSender::shoot_beforehand_cmd_
rm_msgs::ShootBeforehandCmd shoot_beforehand_cmd_
Definition: command_sender.h:618
rm_common::ShooterCommandSender::auto_wheel_speed_
bool auto_wheel_speed_
Definition: command_sender.h:615
rm_common::ShooterCommandSender::deploySpeed
void deploySpeed()
Definition: command_sender.h:580
rm_common::DoubleBarrelCommandSender::shooter_ID2_cmd_sender_
ShooterCommandSender * shooter_ID2_cmd_sender_
Definition: command_sender.h:1111
rm_common::GimbalCommandSender::time_constant_rc_
double time_constant_rc_
Definition: command_sender.h:394
rm_common::ShooterCommandSender::total_extra_wheel_speed_
double total_extra_wheel_speed_
Definition: command_sender.h:613
rm_common::CardCommandSender::sendCommand
void sendCommand(const ros::Time &time) override
Definition: command_sender.h:777
rm_common::HeatLimit::getShootFrequencyMode
bool getShootFrequencyMode() const
Definition: heat_limit.h:239
rm_common::DoubleBarrelCommandSender::check_launch_threshold_
double check_launch_threshold_
Definition: command_sender.h:1123
rm_common::ShooterCommandSender::updateShootData
void updateShootData(const rm_msgs::ShootData &data)
Definition: command_sender.h:468
rm_common::Vel2DCommandSender::setZero
void setZero() override
Definition: command_sender.h:237
rm_common::ShooterCommandSender::exitDeploySpeed
void exitDeploySpeed()
Definition: command_sender.h:584
rm_common::JointPointCommandSender::index_
int index_
Definition: command_sender.h:862
rm_common::JointJogCommandSender::step_
double step_
Definition: command_sender.h:829
rm_common::ShooterCommandSender::wheel_speed_des_
double wheel_speed_des_
Definition: command_sender.h:606
rm_common::ShooterCommandSender::wheel_speed_10_
double wheel_speed_10_
Definition: command_sender.h:605
rm_common::CardCommandSender::off
void off()
Definition: command_sender.h:768
rm_common::MultiDofCommandSender::MultiDofCommandSender
MultiDofCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:891
rm_common::GimbalCommandSender::setEject
void setEject(bool flag)
Definition: command_sender.h:375
rm_common::ShooterCommandSender::max_track_target_vel_
double max_track_target_vel_
Definition: command_sender.h:610
rm_common::ShooterCommandSender::wheel_speed_16_
double wheel_speed_16_
Definition: command_sender.h:605
rm_common::ShooterCommandSender::wheel_speed_18_
double wheel_speed_18_
Definition: command_sender.h:605
rm_common::JointPositionBinaryCommandSender::state
bool state
Definition: command_sender.h:746
ros::Time
rm_common::JointPointCommandSender::setPoint
void setPoint(double point)
Definition: command_sender.h:840
rm_common::Vel3DCommandSender::max_angular_z_
double max_angular_z_
Definition: command_sender.h:709
rm_common::ShooterCommandSender::setArmorType
void setArmorType(uint8_t armor_type)
Definition: command_sender.h:588
rm_common::HeaderStampCommandSenderBase::HeaderStampCommandSenderBase
HeaderStampCommandSenderBase(ros::NodeHandle &nh)
Definition: command_sender.h:167
rm_common::ShooterCommandSender::speed_16_
double speed_16_
Definition: command_sender.h:604
rm_common::PowerLimit::setCapacityData
void setCapacityData(const rm_msgs::PowerManagementSampleAndStatusData data)
Definition: power_limit.h:180
rm_common::DoubleBarrelCommandSender
Definition: command_sender.h:927
getParam
T getParam(ros::NodeHandle &pnh, const std::string &param_name, const T &default_val)
Definition: ros_utilities.h:44
rm_common::ShooterCommandSender::extra_wheel_speed_once_
double extra_wheel_speed_once_
Definition: command_sender.h:612
length
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
rm_common::CommandSenderBase::pub_
ros::Publisher pub_
Definition: command_sender.h:176
rm_common::ShooterCommandSender::ShooterCommandSender
ShooterCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:401
rm_common::ChassisCommandSender::sendChassisCommand
void sendChassisCommand(const ros::Time &time, bool is_gyro)
Definition: command_sender.h:303
ROS_ERROR
#define ROS_ERROR(...)
rm_common::ShooterCommandSender::setShootFrequency
void setShootFrequency(uint8_t mode)
Definition: command_sender.h:592
rm_common::PowerLimit::setGameRobotData
void setGameRobotData(const rm_msgs::GameRobotStatus data)
Definition: power_limit.h:170
rm_common::JointPointCommandSender::setZero
void setZero() override
Definition: command_sender.h:858
rm_common::JointJogCommandSender::reset
void reset()
Definition: command_sender.h:797
rm_common::Vel3DCommandSender::max_angular_y_
double max_angular_y_
Definition: command_sender.h:709
rm_common::DoubleBarrelCommandSender::updatePowerHeatData
void updatePowerHeatData(const rm_msgs::PowerHeatData data)
Definition: command_sender.h:959
rm_common::GimbalCommandSender::use_rc_
bool use_rc_
Definition: command_sender.h:395
rm_common::DoubleBarrelCommandSender::triggerStateCallback
void triggerStateCallback(const control_msgs::JointControllerState::ConstPtr &data)
Definition: command_sender.h:1102
power_limit.h
ros::NodeHandle::param
T param(const std::string &param_name, const T &default_val) const
rm_common::Vel2DCommandSender::vel_direction_
double vel_direction_
Definition: command_sender.h:253
rm_common::JointJogCommandSender::joint_
std::string joint_
Definition: command_sender.h:827
rm_common::DoubleBarrelCommandSender::need_switch_
bool need_switch_
Definition: command_sender.h:1116
rm_common::ShooterCommandSender::gimbal_des_error_
rm_msgs::GimbalDesError gimbal_des_error_
Definition: command_sender.h:617
rm_common::GimbalCommandSender::time_constant_pc_
double time_constant_pc_
Definition: command_sender.h:394
rm_common::DoubleBarrelCommandSender::joint_state_sub_
ros::Subscriber joint_state_sub_
Definition: command_sender.h:1114
rm_common::CameraSwitchCommandSender::camera2_name_
std::string camera2_name_
Definition: command_sender.h:885
rm_common::PowerLimit::updateSafetyPower
void updateSafetyPower(int safety_power)
Definition: power_limit.h:153
rm_common::ChassisCommandSender::updatePowerHeatData
void updatePowerHeatData(const rm_msgs::PowerHeatData data) override
Definition: command_sender.h:287
rm_common::Vel2DCommandSender::setLinearYVel
void setLinearYVel(double scale)
Definition: command_sender.h:210
rm_common::Vel2DCommandSender::track_data_
rm_msgs::TrackData track_data_
Definition: command_sender.h:255
rm_common::Vel3DCommandSender::max_angular_x_
double max_angular_x_
Definition: command_sender.h:709
rm_common::GimbalCommandSender::setBulletSpeed
void setBulletSpeed(double bullet_speed)
Definition: command_sender.h:371
rm_common::DoubleBarrelCommandSender::DoubleBarrelCommandSender
DoubleBarrelCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:930
rm_common::GimbalCommandSender::~GimbalCommandSender
~GimbalCommandSender()=default
rm_common::DoubleBarrelCommandSender::switching_duration_
double switching_duration_
Definition: command_sender.h:1118
rm_common::DoubleBarrelCommandSender::updateTrackData
void updateTrackData(const rm_msgs::TrackData &data)
Definition: command_sender.h:974
rm_common::GimbalCommandSender::track_timeout_
double track_timeout_
Definition: command_sender.h:393
rm_common::Vel2DCommandSender::Vel2DCommandSender
Vel2DCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:180
rm_common::ShooterCommandSender::getShootFrequency
uint8_t getShootFrequency()
Definition: command_sender.h:596
rm_common::ShooterCommandSender::setSpeedDesAndWheelSpeedDes
void setSpeedDesAndWheelSpeedDes()
Definition: command_sender.h:531
rm_common::DoubleBarrelCommandSender::init
void init()
Definition: command_sender.h:1013
rm_common::HeaderStampCommandSenderBase::sendCommand
void sendCommand(const ros::Time &time) override
Definition: command_sender.h:170
ros::NodeHandle::getNamespace
const std::string & getNamespace() const
rm_common::DoubleBarrelCommandSender::shooter_ID1_cmd_sender_
ShooterCommandSender * shooter_ID1_cmd_sender_
Definition: command_sender.h:1110
rm_common::ChassisCommandSender::updateCapacityData
void updateCapacityData(const rm_msgs::PowerManagementSampleAndStatusData data) override
Definition: command_sender.h:291
rm_common::JointPointCommandSender::joint_state_
const sensor_msgs::JointState & joint_state_
Definition: command_sender.h:863
rm_common::DoubleBarrelCommandSender::setMode
void setMode(int mode)
Definition: command_sender.h:990
rm_common::DoubleBarrelCommandSender::updateShootBeforehandCmd
void updateShootBeforehandCmd(const rm_msgs::ShootBeforehandCmd &data)
Definition: command_sender.h:984
rm_common::CardCommandSender::short_on
void short_on()
Definition: command_sender.h:763
rm_common::ShooterCommandSender::speed_des_
double speed_des_
Definition: command_sender.h:604
ROS_INFO
#define ROS_INFO(...)
rm_common::PowerLimit::setChassisPowerBuffer
void setChassisPowerBuffer(const rm_msgs::PowerHeatData data)
Definition: power_limit.h:175
rm_common::ChassisCommandSender::setFollowVelDes
void setFollowVelDes(double follow_vel_des)
Definition: command_sender.h:299
ROS_ASSERT
#define ROS_ASSERT(cond)
rm_common::ShooterCommandSender::updateSuggestFireData
void updateSuggestFireData(const std_msgs::Bool &data)
Definition: command_sender.h:464
linear_interpolation.h
rm_common::CardCommandSender
Definition: command_sender.h:750
rm_common::DoubleBarrelCommandSender::id1_point_
double id1_point_
Definition: command_sender.h:1121
rm_common::LinearInterp::init
void init(XmlRpc::XmlRpcValue &config)
Definition: linear_interpolation.h:15
rm_common::GimbalCommandSender::setGimbalTrajFrameId
void setGimbalTrajFrameId(const std::string &traj_frame_id)
Definition: command_sender.h:362
ros::Duration
rm_common::CameraSwitchCommandSender::sendCommand
void sendCommand(const ros::Time &time) override
Definition: command_sender.h:878
rm_common::BalanceCommandSender::setBalanceMode
void setBalanceMode(const int mode)
Definition: command_sender.h:631
rm_common::DoubleBarrelCommandSender::barrel_command_sender_
JointPointCommandSender * barrel_command_sender_
Definition: command_sender.h:1112
rm_common::DoubleBarrelCommandSender::checklaunch
void checklaunch()
Definition: command_sender.h:1066
rm_common::GimbalCommandSender::setGimbalTraj
void setGimbalTraj(double traj_yaw, double traj_pitch)
Definition: command_sender.h:357
rm_common::ShooterCommandSender::untrack_armor_error_tolerance_
double untrack_armor_error_tolerance_
Definition: command_sender.h:609
rm_common::Vel2DCommandSender::set2DVel
void set2DVel(double scale_x, double scale_y, double scale_z)
Definition: command_sender.h:231
rm_common::ShooterCommandSender::speed_30_
double speed_30_
Definition: command_sender.h:604
rm_common::JointPositionBinaryCommandSender::setZero
void setZero() override
Definition: command_sender.h:743
rm_common::ShooterCommandSender::sendCommand
void sendCommand(const ros::Time &time) override
Definition: command_sender.h:515
XmlRpc::XmlRpcValue
rm_common::ShooterCommandSender::updateShootBeforehandCmd
void updateShootBeforehandCmd(const rm_msgs::ShootBeforehandCmd &data)
Definition: command_sender.h:456
rm_common::ChassisCommandSender::ChassisCommandSender
ChassisCommandSender(ros::NodeHandle &nh)
Definition: command_sender.h:261
ros::NodeHandle
ros::Subscriber
rm_common::ShooterCommandSender::heat_limit_
HeatLimit * heat_limit_
Definition: command_sender.h:601
ros::Time::now
static Time now()
rm_common::ShooterCommandSender::target_acceleration_tolerance_
double target_acceleration_tolerance_
Definition: command_sender.h:611


rm_common
Author(s):
autogenerated on Tue May 6 2025 02:23:36