From c0d7a7221135f6d15030ee2fc71d06f40d7e974e Mon Sep 17 00:00:00 2001 From: Guramumei <1421887449@qq.com> Date: Sun, 22 Oct 2023 18:07:03 +0800 Subject: [PATCH] Optimize the code. --- rm_referee/include/rm_referee/referee_base.h | 1 - rm_referee/include/rm_referee/ui/flash_ui.h | 6 ++- .../include/rm_referee/ui/time_change_ui.h | 34 +++++++----- .../include/rm_referee/ui/trigger_change_ui.h | 26 ++++++---- rm_referee/include/rm_referee/ui/ui_base.h | 11 ++-- rm_referee/src/referee_base.cpp | 52 ++++++++++--------- rm_referee/src/ui/flash_ui.cpp | 1 - rm_referee/src/ui/graph.cpp | 2 +- rm_referee/src/ui/time_change_ui.cpp | 2 +- rm_referee/src/ui/trigger_change_ui.cpp | 5 +- rm_referee/src/ui/ui_base.cpp | 18 +++---- 11 files changed, 90 insertions(+), 68 deletions(-) diff --git a/rm_referee/include/rm_referee/referee_base.h b/rm_referee/include/rm_referee/referee_base.h index 72e68507..e526d2fd 100644 --- a/rm_referee/include/rm_referee/referee_base.h +++ b/rm_referee/include/rm_referee/referee_base.h @@ -13,7 +13,6 @@ #include "rm_referee/ui/time_change_ui.h" #include "rm_referee/ui/flash_ui.h" - namespace rm_referee { class RefereeBase diff --git a/rm_referee/include/rm_referee/ui/flash_ui.h b/rm_referee/include/rm_referee/ui/flash_ui.h index 6251fe1e..7be7495e 100644 --- a/rm_referee/include/rm_referee/ui/flash_ui.h +++ b/rm_referee/include/rm_referee/ui/flash_ui.h @@ -25,7 +25,8 @@ class FlashUi : public UiBase class CoverFlashUi : public FlashUi { public: - explicit CoverFlashUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit CoverFlashUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : FlashUi(rpc_value, base, "cover", graph_queue, character_queue){}; void updateManualCmdData(const rm_msgs::ManualToReferee::ConstPtr data, const ros::Time& last_get_data_time) override; @@ -38,7 +39,8 @@ class CoverFlashUi : public FlashUi class SpinFlashUi : public FlashUi { public: - explicit SpinFlashUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit SpinFlashUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : FlashUi(rpc_value, base, "spin", graph_queue, character_queue){}; void updateChassisCmdData(const rm_msgs::ChassisCmd::ConstPtr data, const ros::Time& last_get_data_time); diff --git a/rm_referee/include/rm_referee/ui/time_change_ui.h b/rm_referee/include/rm_referee/ui/time_change_ui.h index 1a0f4d1b..a249a44b 100644 --- a/rm_referee/include/rm_referee/ui/time_change_ui.h +++ b/rm_referee/include/rm_referee/ui/time_change_ui.h @@ -12,7 +12,7 @@ class TimeChangeUi : public UiBase { public: explicit TimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, const std::string& graph_name, - std::deque * graph_queue, std::deque * character_queue) + std::deque* graph_queue, std::deque* character_queue) : UiBase(rpc_value, base, graph_queue, character_queue) { graph_ = new Graph(rpc_value["config"], base_, id_++); @@ -26,7 +26,7 @@ class TimeChangeGroupUi : public GroupUiBase { public: explicit TimeChangeGroupUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, const std::string& graph_name, - std::deque * graph_queue, std::deque * character_queue) + std::deque* graph_queue, std::deque* character_queue) : GroupUiBase(rpc_value, base, graph_queue, character_queue) { graph_name_ = graph_name; @@ -42,7 +42,8 @@ class TimeChangeGroupUi : public GroupUiBase class CapacitorTimeChangeUi : public TimeChangeUi { public: - explicit CapacitorTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit CapacitorTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TimeChangeUi(rpc_value, base, "capacitor", graph_queue, character_queue){}; void add() override; void updateRemainCharge(const double remain_charge, const ros::Time& time); @@ -55,7 +56,8 @@ class CapacitorTimeChangeUi : public TimeChangeUi class EffortTimeChangeUi : public TimeChangeUi { public: - explicit EffortTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit EffortTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TimeChangeUi(rpc_value, base, "effort", graph_queue, character_queue){}; void updateJointStateData(const sensor_msgs::JointState::ConstPtr data, const ros::Time& time); @@ -68,7 +70,8 @@ class EffortTimeChangeUi : public TimeChangeUi class ProgressTimeChangeUi : public TimeChangeUi { public: - explicit ProgressTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit ProgressTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TimeChangeUi(rpc_value, base, "progress", graph_queue, character_queue){}; void updateEngineerUiData(const rm_msgs::EngineerUi::ConstPtr data, const ros::Time& last_get_data_time); @@ -81,7 +84,8 @@ class ProgressTimeChangeUi : public TimeChangeUi class DartStatusTimeChangeUi : public TimeChangeUi { public: - explicit DartStatusTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit DartStatusTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TimeChangeUi(rpc_value, base, "dart", graph_queue, character_queue){}; void updateDartClientCmd(const rm_msgs::DartClientCmd::ConstPtr data, const ros::Time& last_get_data_time); @@ -93,7 +97,8 @@ class DartStatusTimeChangeUi : public TimeChangeUi class RotationTimeChangeUi : public TimeChangeUi { public: - explicit RotationTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit RotationTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TimeChangeUi(rpc_value, base, "rotation", graph_queue, character_queue) { if (rpc_value.hasMember("data")) @@ -125,7 +130,8 @@ class RotationTimeChangeUi : public TimeChangeUi class LaneLineTimeChangeGroupUi : public TimeChangeGroupUi { public: - explicit LaneLineTimeChangeGroupUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit LaneLineTimeChangeGroupUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TimeChangeGroupUi(rpc_value, base, "lane_line", graph_queue, character_queue) { if (rpc_value.hasMember("data")) @@ -171,7 +177,8 @@ class LaneLineTimeChangeGroupUi : public TimeChangeGroupUi class BalancePitchTimeChangeGroupUi : public TimeChangeGroupUi { public: - explicit BalancePitchTimeChangeGroupUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit BalancePitchTimeChangeGroupUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TimeChangeGroupUi(rpc_value, base, "balance_pitch", graph_queue, character_queue) { XmlRpc::XmlRpcValue config; @@ -232,7 +239,8 @@ class BalancePitchTimeChangeGroupUi : public TimeChangeGroupUi class PitchAngleTimeChangeUi : public TimeChangeUi { public: - explicit PitchAngleTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit PitchAngleTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TimeChangeUi(rpc_value, base, "pitch", graph_queue, character_queue){}; void updateJointStateData(const sensor_msgs::JointState::ConstPtr data, const ros::Time& time); @@ -244,9 +252,9 @@ class PitchAngleTimeChangeUi : public TimeChangeUi class JointPositionTimeChangeUi : public TimeChangeUi { public: - explicit JointPositionTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, std::deque* character_queue, - std::string name) - : TimeChangeUi(rpc_value, base, name, graph_queue,character_queue) + explicit JointPositionTimeChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue, std::string name) + : TimeChangeUi(rpc_value, base, name, graph_queue, character_queue) { if (rpc_value.hasMember("data")) { diff --git a/rm_referee/include/rm_referee/ui/trigger_change_ui.h b/rm_referee/include/rm_referee/ui/trigger_change_ui.h index 60fb3a6f..2e882cf4 100644 --- a/rm_referee/include/rm_referee/ui/trigger_change_ui.h +++ b/rm_referee/include/rm_referee/ui/trigger_change_ui.h @@ -31,7 +31,7 @@ class TriggerChangeGroupUi : public GroupUiBase { public: explicit TriggerChangeGroupUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, const std::string& graph_name, - std::deque * graph_queue, std::deque * character_queue) + std::deque* graph_queue, std::deque* character_queue) : GroupUiBase(rpc_value, base, graph_queue, character_queue) { graph_name_ = graph_name; @@ -48,7 +48,8 @@ class TriggerChangeGroupUi : public GroupUiBase class ChassisTriggerChangeUi : public TriggerChangeUi { public: - explicit ChassisTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit ChassisTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TriggerChangeUi(rpc_value, base, "chassis", graph_queue, character_queue) { if (base.robot_id_ == rm_referee::RobotId::RED_ENGINEER || base.robot_id_ == rm_referee::RobotId::BLUE_ENGINEER) @@ -79,7 +80,8 @@ class ChassisTriggerChangeUi : public TriggerChangeUi class ShooterTriggerChangeUi : public TriggerChangeUi { public: - explicit ShooterTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit ShooterTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TriggerChangeUi(rpc_value, base, "shooter", graph_queue, character_queue) { graph_->setContent("0"); @@ -97,7 +99,8 @@ class ShooterTriggerChangeUi : public TriggerChangeUi class GimbalTriggerChangeUi : public TriggerChangeUi { public: - explicit GimbalTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit GimbalTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TriggerChangeUi(rpc_value, base, "gimbal", graph_queue, character_queue) { graph_->setContent("0"); @@ -115,7 +118,8 @@ class GimbalTriggerChangeUi : public TriggerChangeUi class TargetTriggerChangeUi : public TriggerChangeUi { public: - explicit TargetTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit TargetTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TriggerChangeUi(rpc_value, base, "target", graph_queue, character_queue) { graph_->setContent("armor"); @@ -137,7 +141,8 @@ class TargetTriggerChangeUi : public TriggerChangeUi class TargetViewAngleTriggerChangeUi : public TriggerChangeUi { public: - explicit TargetViewAngleTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit TargetViewAngleTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TriggerChangeUi(rpc_value, base, "target_scale", graph_queue, character_queue) { } @@ -152,7 +157,8 @@ class TargetViewAngleTriggerChangeUi : public TriggerChangeUi class PolygonTriggerChangeGroupUi : public TriggerChangeGroupUi { public: - explicit PolygonTriggerChangeGroupUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit PolygonTriggerChangeGroupUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TriggerChangeGroupUi(rpc_value, base, "Polygon", graph_queue, character_queue) { ROS_ASSERT(rpc_value.hasMember("points")); @@ -193,13 +199,15 @@ class PolygonTriggerChangeGroupUi : public TriggerChangeGroupUi } } void update() override; - //virtual void updateConfig(uint8_t main_mode, bool main_flag, uint8_t sub_mode = 0, bool sub_flag = false){} void setContent(const std::string &content) override; + // virtual void updateConfig(uint8_t main_mode, bool main_flag, uint8_t sub_mode = 0, bool sub_flag = false){} void + // setContent(const std::string &content) override; }; class CameraTriggerChangeUi : public TriggerChangeUi { public: - explicit CameraTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue, std::deque * character_queue) + explicit CameraTriggerChangeUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue, + std::deque* character_queue) : TriggerChangeUi(rpc_value, base, "camera", graph_queue, character_queue) { if (rpc_value.hasMember("camera_name")) diff --git a/rm_referee/include/rm_referee/ui/ui_base.h b/rm_referee/include/rm_referee/ui/ui_base.h index f178f462..e5b5a1a4 100644 --- a/rm_referee/include/rm_referee/ui/ui_base.h +++ b/rm_referee/include/rm_referee/ui/ui_base.h @@ -19,7 +19,8 @@ namespace rm_referee class UiBase { public: - explicit UiBase(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue = nullptr, std::deque* character_queue = nullptr ) + explicit UiBase(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue = nullptr, + std::deque* character_queue = nullptr) : base_(base), tf_listener_(tf_buffer_) { if (rpc_value.hasMember("config")) @@ -73,7 +74,8 @@ class UiBase class GroupUiBase : public UiBase { public: - explicit GroupUiBase(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque * graph_queue = nullptr, std::deque * character_queue = nullptr) + explicit GroupUiBase(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue = nullptr, + std::deque* character_queue = nullptr) : UiBase(rpc_value, base, graph_queue, character_queue){}; ~GroupUiBase() = default; void add() override; @@ -98,10 +100,11 @@ class GroupUiBase : public UiBase class FixedUi : public GroupUiBase { public: - explicit FixedUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue = nullptr, std::deque* character_queue = nullptr) + explicit FixedUi(XmlRpc::XmlRpcValue& rpc_value, Base& base, std::deque* graph_queue = nullptr, + std::deque* character_queue = nullptr) : GroupUiBase(rpc_value, base, graph_queue, character_queue) { - for(int i = 0; i < static_cast(rpc_value.size()); i++) + for (int i = 0; i < static_cast(rpc_value.size()); i++) graph_vector_.insert( std::pair(rpc_value[i]["name"], new Graph(rpc_value[i]["config"], base_, id_++))); }; diff --git a/rm_referee/src/referee_base.cpp b/rm_referee/src/referee_base.cpp index 362f2583..3fed1374 100644 --- a/rm_referee/src/referee_base.cpp +++ b/rm_referee/src/referee_base.cpp @@ -55,7 +55,8 @@ RefereeBase::RefereeBase(ros::NodeHandle& nh, Base& base) : base_(base), nh_(nh) if (rpc_value[i]["name"] == "target") target_trigger_change_ui_ = new TargetTriggerChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_); if (rpc_value[i]["name"] == "target_view_angle") - target_view_angle_trigger_change_ui_ = new TargetViewAngleTriggerChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_); + target_view_angle_trigger_change_ui_ = + new TargetViewAngleTriggerChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_); if (rpc_value[i]["name"] == "camera") camera_trigger_change_ui_ = new CameraTriggerChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_); } @@ -74,17 +75,22 @@ RefereeBase::RefereeBase(ros::NodeHandle& nh, Base& base) : base_(base), nh_(nh) if (rpc_value[i]["name"] == "rotation") rotation_time_change_ui_ = new RotationTimeChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_); if (rpc_value[i]["name"] == "lane_line") - lane_line_time_change_ui_ = new LaneLineTimeChangeGroupUi(rpc_value[i], base_, &graph_queue_, &character_queue_); + lane_line_time_change_ui_ = + new LaneLineTimeChangeGroupUi(rpc_value[i], base_, &graph_queue_, &character_queue_); if (rpc_value[i]["name"] == "pitch") pitch_angle_time_change_ui_ = new PitchAngleTimeChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_); if (rpc_value[i]["name"] == "balance_pitch") - balance_pitch_time_change_group_ui_ = new BalancePitchTimeChangeGroupUi(rpc_value[i], base_, &graph_queue_, &character_queue_); + balance_pitch_time_change_group_ui_ = + new BalancePitchTimeChangeGroupUi(rpc_value[i], base_, &graph_queue_, &character_queue_); if (rpc_value[i]["name"] == "engineer_joint1") - engineer_joint1_time_change_ui = new JointPositionTimeChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_,"joint1"); + engineer_joint1_time_change_ui = + new JointPositionTimeChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_, "joint1"); if (rpc_value[i]["name"] == "engineer_joint2") - engineer_joint2_time_change_ui = new JointPositionTimeChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_,"joint2"); + engineer_joint2_time_change_ui = + new JointPositionTimeChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_, "joint2"); if (rpc_value[i]["name"] == "engineer_joint3") - engineer_joint3_time_change_ui = new JointPositionTimeChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_,"joint3"); + engineer_joint3_time_change_ui = + new JointPositionTimeChangeUi(rpc_value[i], base_, &graph_queue_, &character_queue_, "joint3"); } ui_nh.getParam("fixed", rpc_value); @@ -103,7 +109,7 @@ RefereeBase::RefereeBase(ros::NodeHandle& nh, Base& base) : base_(base), nh_(nh) add_ui_timer_ = nh.createTimer(ros::Duration(1. / add_ui_frequency_), std::bind(&RefereeBase::addUi, this), false, false); send_serial_data_timer_ = nh.createTimer(ros::Duration(send_ui_queue_delay_), - std::bind(&RefereeBase::sendSerialDataCallback, this), false, true); + std::bind(&RefereeBase::sendSerialDataCallback, this), false, true); } void RefereeBase::addUi() { @@ -163,7 +169,8 @@ void RefereeBase::addUi() void RefereeBase::sendSerialDataCallback() { - if (graph_queue_.empty() && character_queue_.empty()){ + if (graph_queue_.empty() && character_queue_.empty()) + { ROS_INFO_THROTTLE(1.0, "No UI to send"); return; } @@ -186,9 +193,9 @@ void RefereeBase::sendSerialDataCallback() character_queue_.pop_front(); } - if(send_radar_receive_data_) + if (send_radar_receive_data_) { - if(ros::Time::now() - radar_receive_last_send < ros::Duration(0.2)) + if (ros::Time::now() - radar_receive_last_send < ros::Duration(0.2)) ROS_WARN_THROTTLE(2.0, "Sending radar receive data too frequently"); interactive_data_sender_->sendRadarInteractiveData(radar_receive_data); radar_receive_last_send = ros::Time::now(); @@ -197,49 +204,47 @@ void RefereeBase::sendSerialDataCallback() } else if (send_map_sentry_data_) { - if(ros::Time::now() - map_sentry_last_send < ros::Duration(0.2)) - ROS_WARN_THROTTLE(2.0, "Sending map sentry data too frequently"); + if (ros::Time::now() - map_sentry_last_send < ros::Duration(0.2)) + ROS_WARN_THROTTLE(2.0, "Sending map sentry data too frequently"); interactive_data_sender_->sendMapSentryData(map_sentry_data); radar_receive_last_send = ros::Time::now(); send_map_sentry_data_ = false; ROS_INFO_THROTTLE(1.0, " send map sentry data"); } - else + else queueSend(); } else queueSend(); - if (base_.robot_id_ == 0 ) + if (base_.robot_id_ == 0) { ROS_WARN_THROTTLE(1.0, "robot base id = 0, the serial or referee system may not be connected"); } - if ( base_.client_id_ == 0) + if (base_.client_id_ == 0) ROS_WARN_THROTTLE(1.0, "client base id = 0, the serial or referee system may not be connected\""); send_serial_data_timer_.start(); } void RefereeBase::queueSend() { - if(!character_queue_.empty() && graph_queue_.size() <= 14) + if (!character_queue_.empty() && graph_queue_.size() <= 14) { graph_queue_sender_->sendCharacter(ros::Time::now(), &character_queue_.at(0)); character_queue_.pop_front(); } else if (graph_queue_.size() >= 7) { - graph_queue_sender_->sendSevenGraph(ros::Time::now(), &graph_queue_.at(0), &graph_queue_.at(1), - &graph_queue_.at(2), &graph_queue_.at(3), - &graph_queue_.at(4), &graph_queue_.at(5), + graph_queue_sender_->sendSevenGraph(ros::Time::now(), &graph_queue_.at(0), &graph_queue_.at(1), &graph_queue_.at(2), + &graph_queue_.at(3), &graph_queue_.at(4), &graph_queue_.at(5), &graph_queue_.at(6)); for (int i = 0; i < 7; i++) graph_queue_.pop_front(); } else if (graph_queue_.size() >= 5) { - graph_queue_sender_->sendFiveGraph(ros::Time::now(), &graph_queue_.at(0), &graph_queue_.at(1), - &graph_queue_.at(2), &graph_queue_.at(3), - &graph_queue_.at(4)); + graph_queue_sender_->sendFiveGraph(ros::Time::now(), &graph_queue_.at(0), &graph_queue_.at(1), &graph_queue_.at(2), + &graph_queue_.at(3), &graph_queue_.at(4)); for (int i = 0; i < 5; i++) graph_queue_.pop_front(); } @@ -311,11 +316,10 @@ void RefereeBase::dbusDataCallback(const rm_msgs::DbusData::ConstPtr& data) add_ui_flag_ = false; is_adding_ = true; if (!graph_queue_.empty()) - graph_queue_.clear(); + graph_queue_.clear(); send_serial_data_timer_.setPeriod(ros::Duration(0.05)); add_ui_timer_.start(); add_ui_times_ = 0; - } if (data->s_r != rm_msgs::DbusData::UP) { diff --git a/rm_referee/src/ui/flash_ui.cpp b/rm_referee/src/ui/flash_ui.cpp index 184d0f28..3b8421b8 100644 --- a/rm_referee/src/ui/flash_ui.cpp +++ b/rm_referee/src/ui/flash_ui.cpp @@ -6,7 +6,6 @@ namespace rm_referee { - void FlashUi::updateFlashUiForQueue(const ros::Time& time, bool state, bool once) { if (once) diff --git a/rm_referee/src/ui/graph.cpp b/rm_referee/src/ui/graph.cpp index 7ba5148e..1a6061f6 100644 --- a/rm_referee/src/ui/graph.cpp +++ b/rm_referee/src/ui/graph.cpp @@ -60,7 +60,7 @@ Graph::Graph(const XmlRpc::XmlRpcValue& config, Base& base, int id) : base_(base if (config.hasMember("content")) { content_ = static_cast(config["content"]); - if (!title_.empty()|| !content_.empty()) + if (!title_.empty() || !content_.empty()) config_.end_angle = static_cast((title_ + content_).size()); } config_.operate_type = rm_referee::GraphOperation::DELETE; diff --git a/rm_referee/src/ui/time_change_ui.cpp b/rm_referee/src/ui/time_change_ui.cpp index 9fd110e0..a1533c62 100644 --- a/rm_referee/src/ui/time_change_ui.cpp +++ b/rm_referee/src/ui/time_change_ui.cpp @@ -40,7 +40,7 @@ void TimeChangeGroupUi::updateForQueue() updateConfig(); if (graph_queue_ && character_queue_ && ros::Time::now() - last_send_ > delay_) { - GroupUiBase::updateForQueue(); + GroupUiBase::updateForQueue(); last_send_ = ros::Time::now(); } } diff --git a/rm_referee/src/ui/trigger_change_ui.cpp b/rm_referee/src/ui/trigger_change_ui.cpp index 9420d848..8811a9c8 100644 --- a/rm_referee/src/ui/trigger_change_ui.cpp +++ b/rm_referee/src/ui/trigger_change_ui.cpp @@ -26,7 +26,7 @@ void TriggerChangeUi::updateTwiceForQueue(bool check_repeat) if (graph_->isRepeated()) return; graph_->updateLastConfig(); - for(int i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) UiBase::updateForQueue(); } @@ -77,11 +77,10 @@ void TriggerChangeGroupUi::updateTwiceForQueue(bool check_repeat) for (auto it : character_vector_) it.second->updateLastConfig(); - for(int i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) GroupUiBase::updateForQueue(); } - void ChassisTriggerChangeUi::update() { if (s_l_ == rm_msgs::DbusData::MID && s_r_ == rm_msgs::DbusData::UP) diff --git a/rm_referee/src/ui/ui_base.cpp b/rm_referee/src/ui/ui_base.cpp index 9a00a524..30ff6ce1 100644 --- a/rm_referee/src/ui/ui_base.cpp +++ b/rm_referee/src/ui/ui_base.cpp @@ -316,7 +316,7 @@ void GroupUiBase::display(const ros::Time& time) void GroupUiBase::sendUi(const ros::Time& time) { - if (base_.robot_id_ == 0 || base_.client_id_ == 0) + if (base_.robot_id_ == 0 || base_.client_id_ == 0) return; for (auto it : character_vector_) @@ -385,17 +385,17 @@ void GroupUiBase::sendSevenGraph(const ros::Time& time, Graph* graph0, Graph* gr void FixedUi::updateForQueue() { - while(update_fixed_ui_times < 1) + while (update_fixed_ui_times < 1) { - for (auto it : graph_vector_) - it.second->updateLastConfig(); + for (auto it : graph_vector_) + it.second->updateLastConfig(); - if (base_.robot_id_ == 0 || base_.client_id_ == 0) - return; + if (base_.robot_id_ == 0 || base_.client_id_ == 0) + return; - GroupUiBase::updateForQueue(); - ROS_INFO_THROTTLE(1.0, "update fixed ui"); - update_fixed_ui_times++; + GroupUiBase::updateForQueue(); + ROS_INFO_THROTTLE(1.0, "update fixed ui"); + update_fixed_ui_times++; } }