mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
Merge pull request #12 from chilatiao/next
Added Bunker actuator state feedback, fixed an error in v1 protocol parsing (actuator feedback current)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -47,6 +47,19 @@ class BunkerBase : public AgilexBase<ParserType>, public BunkerInterface {
|
||||
bunker_state.rc_state = state.rc_state;
|
||||
return bunker_state;
|
||||
}
|
||||
|
||||
BunkerActuatorState GetActuatorState() override {
|
||||
auto actuator = AgilexBase<ParserType>::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
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ class BunkerRobot : public RobotCommonInterface, public BunkerInterface {
|
||||
|
||||
// get robot state
|
||||
BunkerCoreState GetRobotState() override;
|
||||
BunkerActuatorState GetActuatorState() override;
|
||||
|
||||
private:
|
||||
RobotCommonInterface* robot_;
|
||||
|
||||
@@ -42,4 +42,9 @@ BunkerCoreState BunkerRobot::GetRobotState() {
|
||||
auto bunker = dynamic_cast<BunkerInterface*>(robot_);
|
||||
return bunker->GetRobotState();
|
||||
}
|
||||
|
||||
BunkerActuatorState BunkerRobot::GetActuatorState() {
|
||||
auto bunker = dynamic_cast<BunkerInterface*>(robot_);
|
||||
return bunker->GetActuatorState();
|
||||
}
|
||||
} // namespace westonrobot
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user