added exception for invalid function calls from interface

This commit is contained in:
Ruixiang Du
2021-07-19 09:52:26 +08:00
parent 90d34480be
commit c053d73222
2 changed files with 15 additions and 4 deletions

View File

@@ -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

View File

@@ -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