From c053d732225acb5f34908e5023c06601191a2697 Mon Sep 17 00:00:00 2001 From: Ruixiang Du Date: Mon, 19 Jul 2021 09:52:26 +0800 Subject: [PATCH] added exception for invalid function calls from interface --- .../interface/robot_common_interface.hpp | 18 +++++++++++++++--- include/ugv_sdk/mobile_robot/scout_robot.hpp | 1 - 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/ugv_sdk/details/interface/robot_common_interface.hpp b/include/ugv_sdk/details/interface/robot_common_interface.hpp index c16d1bf..df382fb 100644 --- a/include/ugv_sdk/details/interface/robot_common_interface.hpp +++ b/include/ugv_sdk/details/interface/robot_common_interface.hpp @@ -65,22 +65,34 @@ class RobotCommonInterface { // functions to be implemented by class AgilexBase virtual void SetMotionMode(uint8_t mode){}; virtual CoreStateMsgGroup GetRobotCoreStateMsgGroup() { + throw std::runtime_error( + "Only a derived version of this function with actual implementation " + "is supposed to be used."); return CoreStateMsgGroup{}; }; virtual ActuatorStateMsgGroup GetActuatorStateMsgGroup() { + throw std::runtime_error( + "Only a derived version of this function with actual implementation " + "is supposed to be used."); return ActuatorStateMsgGroup{}; }; // any specific robot will use a specialized version of the two functions virtual void SendMotionCommand(double linear_vel, double angular_vel, double lateral_velocity, - double steering_angle){ - // use derived version + double steering_angle) { + throw std::runtime_error( + "Only a derived version of this function with actual implementation " + "is supposed to be used."); }; virtual void SendLightCommand(LightMode front_mode, uint8_t front_custom_value, LightMode rear_mode, - uint8_t rear_custom_value){}; + uint8_t rear_custom_value) { + throw std::runtime_error( + "Only a derived version of this function with actual implementation " + "is supposed to be used."); + }; }; } // namespace westonrobot diff --git a/include/ugv_sdk/mobile_robot/scout_robot.hpp b/include/ugv_sdk/mobile_robot/scout_robot.hpp index 56a5569..54a2046 100644 --- a/include/ugv_sdk/mobile_robot/scout_robot.hpp +++ b/include/ugv_sdk/mobile_robot/scout_robot.hpp @@ -56,7 +56,6 @@ class ScoutMiniOmniRobot : public ScoutRobot, public ScoutOmniInterface { private: using ScoutRobot::SetMotionCommand; - // void SetMotionCommand(double linear_vel, double angular_vel) = delete; }; } // namespace westonrobot