mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
saved work
This commit is contained in:
@@ -15,25 +15,41 @@
|
||||
#include "ugv_sdk/interface/agilex_message.h"
|
||||
|
||||
namespace westonrobot {
|
||||
struct RobotInterface {
|
||||
enum class ProtocolType { AGX_V1, AGX_V2 };
|
||||
|
||||
class RobotInterface {
|
||||
public:
|
||||
~RobotInterface() = default;
|
||||
|
||||
// functions to be implemented by class AgilexBase
|
||||
virtual void EnableCommandedMode() = 0;
|
||||
|
||||
virtual void SetMotionMode(uint8_t mode){};
|
||||
|
||||
virtual void SendMotionCommand(double linear_vel, double angular_vel,
|
||||
double lateral_velocity,
|
||||
double steering_angle) = 0;
|
||||
virtual void SendLightCommand(LightMode front_mode,
|
||||
uint8_t front_custom_value, LightMode rear_mode,
|
||||
uint8_t rear_custom_value) = 0;
|
||||
virtual void DisableLightControl() = 0;
|
||||
|
||||
// functions to be implemented by each robot class
|
||||
virtual void Connect(std::string can_name) = 0;
|
||||
virtual void Connect(std::string uart_name, uint32_t baudrate) = 0;
|
||||
|
||||
// functions to be implemented by each robot class
|
||||
virtual void Connect(std::string uart_name, uint32_t baudrate){
|
||||
// use derived version
|
||||
};
|
||||
virtual void ResetRobotState() = 0;
|
||||
|
||||
protected:
|
||||
/****** functions not available/valid to all robots ******/
|
||||
// functions to be implemented by class AgilexBase
|
||||
virtual void SetMotionMode(uint8_t mode){};
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
virtual void SendLightCommand(LightMode front_mode,
|
||||
uint8_t front_custom_value, LightMode rear_mode,
|
||||
uint8_t rear_custom_value){
|
||||
// use derived version
|
||||
};
|
||||
};
|
||||
} // namespace westonrobot
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ struct ScoutState {
|
||||
};
|
||||
|
||||
struct ScoutInterface {
|
||||
~ScoutInterface() = default;
|
||||
|
||||
virtual void SetMotionCommand(double linear_vel, double angular_vel) = 0;
|
||||
virtual void SetLightCommand(LightMode f_mode, uint8_t f_value,
|
||||
LightMode r_mode, uint8_t r_value) = 0;
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
#include "ugv_sdk/protocol_v2/agilex_msg_parser.h"
|
||||
|
||||
namespace westonrobot {
|
||||
enum class AgilexProtocol { V1, V2 };
|
||||
|
||||
template <typename ParserType>
|
||||
class AgilexBase : public RobotInterface {
|
||||
public:
|
||||
|
||||
@@ -12,15 +12,32 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ugv_sdk/mobile_base/common.hpp"
|
||||
#include "ugv_sdk/interface/robot_interface.hpp"
|
||||
#include "ugv_sdk/interface/scout_interface.hpp"
|
||||
|
||||
namespace westonrobot {
|
||||
class ScoutRobot {
|
||||
class ScoutRobot : public RobotInterface, public ScoutInterface {
|
||||
public:
|
||||
ScoutRobot(AgilexProtocol protocol);
|
||||
ScoutRobot(ProtocolType protocol = ProtocolType::AGX_V2);
|
||||
~ScoutRobot();
|
||||
|
||||
void Connect(std::string can_name) override;
|
||||
void Connect(std::string uart_name, uint32_t baudrate) override;
|
||||
|
||||
void EnableCommandedMode();
|
||||
|
||||
void SetMotionCommand(double linear_vel, double angular_vel) override;
|
||||
void SetLightCommand(LightMode f_mode, uint8_t f_value, LightMode r_mode,
|
||||
uint8_t r_value) override;
|
||||
void DisableLightControl() override;
|
||||
|
||||
void ResetRobotState() override;
|
||||
|
||||
// get robot state
|
||||
ScoutState GetRobotState() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ScoutInterface> robot_;
|
||||
RobotInterface* robot_;
|
||||
};
|
||||
} // namespace westonrobot
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
#include "ugv_sdk/protocol_v2/protocol_v2_parser.hpp"
|
||||
|
||||
namespace westonrobot {
|
||||
class ScoutBase : public AgilexBase<ProtocolV2Parser>, public ScoutInterface {
|
||||
class ScoutBaseV2 : public AgilexBase<ProtocolV2Parser>, public ScoutInterface {
|
||||
public:
|
||||
ScoutBase() : AgilexBase(){};
|
||||
~ScoutBase() = default;
|
||||
ScoutBaseV2() : AgilexBase(){};
|
||||
~ScoutBaseV2() = default;
|
||||
|
||||
// set up connection
|
||||
void Connect(std::string can_name) override;
|
||||
|
||||
Reference in New Issue
Block a user