mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
added bunker robot support
This commit is contained in:
34
include/ugv_sdk/details/interface/bunker_interface.hpp
Normal file
34
include/ugv_sdk/details/interface/bunker_interface.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* bunker_interface.hpp
|
||||
*
|
||||
* Created on: Jul 14, 2021 23:04
|
||||
* Description:
|
||||
*
|
||||
* Copyright (c) 2021 Ruixiang Du (rdu)
|
||||
*/
|
||||
|
||||
#ifndef BUNKER_INTERFACE_HPP
|
||||
#define BUNKER_INTERFACE_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ugv_sdk/details/interface/agilex_message.h"
|
||||
|
||||
namespace westonrobot {
|
||||
struct BunkerCoreState {
|
||||
SystemStateMessage system_state;
|
||||
MotionStateMessage motion_state;
|
||||
RcStateMessage rc_state;
|
||||
};
|
||||
|
||||
struct BunkerInterface {
|
||||
virtual ~BunkerInterface() = default;
|
||||
|
||||
virtual void SetMotionCommand(double linear_vel, double angular_vel) = 0;
|
||||
|
||||
// get robot state
|
||||
virtual BunkerCoreState GetRobotState() = 0;
|
||||
};
|
||||
} // namespace westonrobot
|
||||
|
||||
#endif /* BUNKER_INTERFACE_HPP */
|
||||
@@ -40,7 +40,6 @@ class RobotInterface {
|
||||
|
||||
// functions to be implemented by class AgilexBase
|
||||
virtual void EnableCommandedMode() = 0;
|
||||
virtual void DisableLightControl() = 0;
|
||||
|
||||
// functions to be implemented by each robot class
|
||||
virtual void Connect(std::string can_name) = 0;
|
||||
@@ -50,6 +49,10 @@ class RobotInterface {
|
||||
};
|
||||
virtual void ResetRobotState() = 0;
|
||||
|
||||
virtual void DisableLightControl() {
|
||||
// use derived version
|
||||
}
|
||||
|
||||
virtual ProtocolVersion GetProtocolVersion() = 0;
|
||||
|
||||
protected:
|
||||
@@ -72,9 +75,7 @@ class RobotInterface {
|
||||
|
||||
virtual void SendLightCommand(LightMode front_mode,
|
||||
uint8_t front_custom_value, LightMode rear_mode,
|
||||
uint8_t rear_custom_value){
|
||||
// use derived version
|
||||
};
|
||||
uint8_t rear_custom_value){};
|
||||
};
|
||||
} // namespace westonrobot
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ class ProtocolV1Parser : public ParserInterface<ProtocolVersion::AGX_V1> {
|
||||
using ScoutProtocolV1Parser = ProtocolV1Parser<ScoutV2Limits>;
|
||||
using ScoutMiniProtocolV1Parser = ProtocolV1Parser<ScoutMiniLimits>;
|
||||
|
||||
using BunkerProtocolV1Parser = ProtocolV1Parser<BunkerLimits>;
|
||||
|
||||
using HunterProtocolV1Parser = ProtocolV1Parser<HunterV1Limits>;
|
||||
|
||||
} // namespace westonrobot
|
||||
|
||||
@@ -25,6 +25,13 @@ struct ScoutMiniLimits {
|
||||
static constexpr double min_angular = -max_angular;
|
||||
};
|
||||
|
||||
struct BunkerLimits {
|
||||
static constexpr double max_linear = 3.0; // m/s
|
||||
static constexpr double min_linear = -max_linear;
|
||||
static constexpr double max_angular = 2.5235; // rad/s
|
||||
static constexpr double min_angular = -max_angular;
|
||||
};
|
||||
|
||||
struct HunterV1Limits {
|
||||
static constexpr double max_linear = 1.5; // m/s
|
||||
static constexpr double min_linear = -max_linear;
|
||||
|
||||
60
include/ugv_sdk/details/robot_base/bunker_base.hpp
Normal file
60
include/ugv_sdk/details/robot_base/bunker_base.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* bunker_base.hpp
|
||||
*
|
||||
* Created on: Jul 14, 2021 23:05
|
||||
* Description:
|
||||
*
|
||||
* Copyright (c) 2021 Ruixiang Du (rdu)
|
||||
*/
|
||||
|
||||
#ifndef BUNKER_BASE_HPP
|
||||
#define BUNKER_BASE_HPP
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
#include "ugv_sdk/details/interface/bunker_interface.hpp"
|
||||
#include "ugv_sdk/details/robot_base/agilex_base.hpp"
|
||||
|
||||
namespace westonrobot {
|
||||
template <typename ParserType>
|
||||
class BunkerBase : public AgilexBase<ParserType>, public BunkerInterface {
|
||||
public:
|
||||
BunkerBase() : AgilexBase<ParserType>(){};
|
||||
~BunkerBase() = default;
|
||||
|
||||
// set up connection
|
||||
void Connect(std::string can_name) override {
|
||||
AgilexBase<ParserType>::Connect(can_name);
|
||||
}
|
||||
|
||||
// robot control
|
||||
void SetMotionCommand(double linear_vel, double angular_vel) override {
|
||||
AgilexBase<ParserType>::SendMotionCommand(linear_vel, angular_vel, 0.0,
|
||||
0.0);
|
||||
}
|
||||
|
||||
// get robot state
|
||||
BunkerCoreState GetRobotState() override {
|
||||
auto state = AgilexBase<ParserType>::GetRobotCoreStateMsgGroup();
|
||||
|
||||
BunkerCoreState bunker_state;
|
||||
bunker_state.system_state = state.system_state;
|
||||
bunker_state.motion_state = state.motion_state;
|
||||
bunker_state.rc_state = state.rc_state;
|
||||
return bunker_state;
|
||||
}
|
||||
};
|
||||
} // namespace westonrobot
|
||||
|
||||
#include "ugv_sdk/details/protocol_v1/protocol_v1_parser.hpp"
|
||||
#include "ugv_sdk/details/protocol_v2/protocol_v2_parser.hpp"
|
||||
|
||||
namespace westonrobot {
|
||||
using BunkerBaseV1 = BunkerBase<BunkerProtocolV1Parser>;
|
||||
using BunkerBaseV2 = BunkerBase<ProtocolV2Parser>;
|
||||
} // namespace westonrobot
|
||||
|
||||
#endif /* BUNKER_BASE_HPP */
|
||||
42
include/ugv_sdk/mobile_robot/bunker_robot.hpp
Normal file
42
include/ugv_sdk/mobile_robot/bunker_robot.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* bunker_robot.hpp
|
||||
*
|
||||
* Created on: Jul 14, 2021 23:08
|
||||
* Description:
|
||||
*
|
||||
* Copyright (c) 2021 Ruixiang Du (rdu)
|
||||
*/
|
||||
|
||||
#ifndef BUNKER_ROBOT_HPP
|
||||
#define BUNKER_ROBOT_HPP
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ugv_sdk/details/interface/robot_interface.hpp"
|
||||
#include "ugv_sdk/details/interface/bunker_interface.hpp"
|
||||
|
||||
namespace westonrobot {
|
||||
class BunkerRobot : public RobotInterface, public BunkerInterface {
|
||||
public:
|
||||
BunkerRobot(ProtocolVersion protocol = ProtocolVersion::AGX_V2);
|
||||
~BunkerRobot();
|
||||
|
||||
void Connect(std::string can_name) override;
|
||||
|
||||
void EnableCommandedMode() override;
|
||||
|
||||
void SetMotionCommand(double linear_vel, double angular_vel) override;
|
||||
|
||||
void ResetRobotState() override;
|
||||
|
||||
ProtocolVersion GetProtocolVersion() override;
|
||||
|
||||
// get robot state
|
||||
BunkerCoreState GetRobotState() override;
|
||||
|
||||
private:
|
||||
RobotInterface* robot_;
|
||||
};
|
||||
} // namespace westonrobot
|
||||
|
||||
#endif /* BUNKER_ROBOT_HPP */
|
||||
Reference in New Issue
Block a user