From 7559ea0ce9449cf34829c0810459bed3b33ead48 Mon Sep 17 00:00:00 2001 From: zhoups <1013700083@qq.com> Date: Wed, 25 Aug 2021 16:36:30 +0800 Subject: [PATCH 1/2] fixed current feedback bug in version 1 --- src/protocol_v1/agilex_msg_parser_v1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protocol_v1/agilex_msg_parser_v1.c b/src/protocol_v1/agilex_msg_parser_v1.c index 24abdcd..e05c000 100644 --- a/src/protocol_v1/agilex_msg_parser_v1.c +++ b/src/protocol_v1/agilex_msg_parser_v1.c @@ -79,7 +79,7 @@ bool DecodeCanFrameV1(const struct can_frame *rx_frame, AgxMessage *msg) { rx_frame->can_id - CAN_MSG_ACTUATOR1_STATE_ID; msg->body.v1_actuator_state_msg.current = ((((uint16_t)rx_frame->data[0]) << 8) | (uint16_t)rx_frame->data[1]) / - 0.1f; + 10.0f; msg->body.v1_actuator_state_msg.rpm = (int16_t)(( (((uint16_t)rx_frame->data[2]) << 8) | (uint16_t)rx_frame->data[3])); msg->body.v1_actuator_state_msg.driver_temp = rx_frame->data[4]; From 4e9c952e087a66b242dd7487a41559a0cd14237c Mon Sep 17 00:00:00 2001 From: zhoups <1013700083@qq.com> Date: Thu, 26 Aug 2021 16:33:36 +0800 Subject: [PATCH 2/2] add bunker Actuator feedback function --- .../ugv_sdk/details/interface/bunker_interface.hpp | 11 +++++++++++ include/ugv_sdk/details/robot_base/bunker_base.hpp | 13 +++++++++++++ include/ugv_sdk/mobile_robot/bunker_robot.hpp | 1 + src/mobile_robot/bunker_robot.cpp | 5 +++++ 4 files changed, 30 insertions(+) diff --git a/include/ugv_sdk/details/interface/bunker_interface.hpp b/include/ugv_sdk/details/interface/bunker_interface.hpp index 57c12d5..f064c06 100644 --- a/include/ugv_sdk/details/interface/bunker_interface.hpp +++ b/include/ugv_sdk/details/interface/bunker_interface.hpp @@ -24,6 +24,16 @@ struct BunkerCoreState { RcStateMessage rc_state; }; +struct BunkerActuatorState { + AgxMsgTimeStamp time_stamp; + + // actuator state + ActuatorHSStateMessage actuator_hs_state[2]; + ActuatorLSStateMessage actuator_ls_state[2]; + // - for v1 robots only + ActuatorStateMessageV1 actuator_state[2]; +}; + struct BunkerInterface { virtual ~BunkerInterface() = default; @@ -31,6 +41,7 @@ struct BunkerInterface { // get robot state virtual BunkerCoreState GetRobotState() = 0; + virtual BunkerActuatorState GetActuatorState() = 0; }; } // namespace westonrobot diff --git a/include/ugv_sdk/details/robot_base/bunker_base.hpp b/include/ugv_sdk/details/robot_base/bunker_base.hpp index 16427c3..4d92f20 100644 --- a/include/ugv_sdk/details/robot_base/bunker_base.hpp +++ b/include/ugv_sdk/details/robot_base/bunker_base.hpp @@ -47,6 +47,19 @@ class BunkerBase : public AgilexBase, public BunkerInterface { bunker_state.rc_state = state.rc_state; return bunker_state; } + + BunkerActuatorState GetActuatorState() override { + auto actuator = AgilexBase::GetActuatorStateMsgGroup(); + + BunkerActuatorState bunker_actuator; + bunker_actuator.time_stamp = actuator.time_stamp; + for (int i = 0; i < 3; ++i) { + bunker_actuator.actuator_hs_state[i] = actuator.actuator_hs_state[i]; + bunker_actuator.actuator_ls_state[i] = actuator.actuator_ls_state[i]; + bunker_actuator.actuator_state[i] = actuator.actuator_state[i]; + } + return bunker_actuator; + } }; } // namespace westonrobot diff --git a/include/ugv_sdk/mobile_robot/bunker_robot.hpp b/include/ugv_sdk/mobile_robot/bunker_robot.hpp index 8c437fb..2f189c7 100644 --- a/include/ugv_sdk/mobile_robot/bunker_robot.hpp +++ b/include/ugv_sdk/mobile_robot/bunker_robot.hpp @@ -33,6 +33,7 @@ class BunkerRobot : public RobotCommonInterface, public BunkerInterface { // get robot state BunkerCoreState GetRobotState() override; + BunkerActuatorState GetActuatorState() override; private: RobotCommonInterface* robot_; diff --git a/src/mobile_robot/bunker_robot.cpp b/src/mobile_robot/bunker_robot.cpp index 2c03c11..481cb9a 100644 --- a/src/mobile_robot/bunker_robot.cpp +++ b/src/mobile_robot/bunker_robot.cpp @@ -42,4 +42,9 @@ BunkerCoreState BunkerRobot::GetRobotState() { auto bunker = dynamic_cast(robot_); return bunker->GetRobotState(); } + +BunkerActuatorState BunkerRobot::GetActuatorState() { + auto bunker = dynamic_cast(robot_); + return bunker->GetActuatorState(); +} } // namespace westonrobot \ No newline at end of file