Skip to content

Commit

Permalink
ranger_base: add ranger mini v3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
hanskw-weston authored Oct 9, 2024
1 parent b7a0208 commit 494d8c4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
34 changes: 29 additions & 5 deletions include/ugv_sdk/details/robot_base/ranger_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include "ugv_sdk/details/protocol_v2/protocol_v2_parser.hpp"

namespace westonrobot {
class RangerBaseV2 : public AgilexBase<ProtocolV2Parser>,
class RangerBase : public AgilexBase<ProtocolV2Parser>,
public RangerInterface {
public:
RangerBaseV2() : AgilexBase<ProtocolV2Parser>(){};
virtual ~RangerBaseV2() = default;
RangerBase() : AgilexBase<ProtocolV2Parser>(){};
virtual ~RangerBase() = default;

// set up connection
bool Connect(std::string can_name) override {
Expand Down Expand Up @@ -88,6 +88,30 @@ class RangerBaseV2 : public AgilexBase<ProtocolV2Parser>,
return ranger_actuator;
}

RangerCommonSensorState GetCommonSensorState() override {
auto common_sensor =
AgilexBase<ProtocolV2Parser>::GetCommonSensorStateMsgGroup();

RangerCommonSensorState ranger_bms;

ranger_bms.time_stamp = common_sensor.time_stamp;

ranger_bms.bms_basic_state.current = common_sensor.bms_basic_state.current;
ranger_bms.bms_basic_state.voltage =
common_sensor.bms_basic_state.voltage;
ranger_bms.bms_basic_state.battery_soc =
common_sensor.bms_basic_state.battery_soc;
ranger_bms.bms_basic_state.battery_soh =
common_sensor.bms_basic_state.battery_soh;
ranger_bms.bms_basic_state.temperature =
common_sensor.bms_basic_state.temperature;

return ranger_bms;
}
};

using RangerMiniV3Base = RangerBase;
class RangerMiniV2Base : public RangerBase {
RangerCommonSensorState GetCommonSensorState() override {
auto common_sensor =
AgilexBase<ProtocolV2Parser>::GetCommonSensorStateMsgGroup();
Expand All @@ -111,12 +135,12 @@ class RangerBaseV2 : public AgilexBase<ProtocolV2Parser>,

return ranger_bms;
}
};
}

// Note: Ranger Mini V1 uses a modified AgileX V2 protocol
// Here we provide a work-around fix as no new firmware will be provided from
// AgileX to properly fix the issue.
class RangerMiniV1Base : public RangerBaseV2 {
class RangerMiniV1Base : public RangerBase {
public:
RangerMiniV1Base() : RangerBaseV2(){};
~RangerMiniV1Base() = default;
Expand Down
9 changes: 8 additions & 1 deletion include/ugv_sdk/mobile_robot/ranger_robot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
namespace westonrobot {
class RangerRobot : public RobotCommonInterface, public RangerInterface {
public:
RangerRobot(bool is_mini_v1);
enum class Variant {
kRangerMiniV1 = 0,
kRangerMiniV2,
kRangerMiniV3,
kRanger,
}

RangerRobot(Variant variant);
~RangerRobot();

bool Connect(std::string can_name) override;
Expand Down
12 changes: 6 additions & 6 deletions src/mobile_robot/ranger_robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#include "ugv_sdk/details/robot_base/ranger_base.hpp"

namespace westonrobot {
RangerRobot::RangerRobot(bool is_mini_v1) {
if (is_mini_v1) {
robot_ = new RangerMiniV1Base();
} else {
robot_ = new RangerBaseV2();
}
RangerRobot::RangerRobot(Variant variant) {
// if (is_mini_v1) {
// robot_ = new RangerMiniV1Base();
// } else {
// robot_ = new RangerBaseV2();
// }
}

RangerRobot::~RangerRobot() {
Expand Down

0 comments on commit 494d8c4

Please sign in to comment.