add SetBrakeMode function

This commit is contained in:
zhoups
2021-07-29 18:06:01 +08:00
parent 740de6aeba
commit d519f158bb
10 changed files with 65 additions and 0 deletions

View File

@@ -240,6 +240,10 @@ typedef struct {
ControlMode mode;
} ControlModeConfigMessage;
typedef struct {
BrakeMode mode;
} BrakeModeConfigMessage;
typedef struct {
bool set_as_neutral;
} SteerNeutralRequestMessage;
@@ -295,6 +299,7 @@ typedef enum {
AgxMsgSteerNeutralRequest,
AgxMsgSteerNeutralResponse,
AgxMsgStateResetConfig,
AgxMsgBrakeModeConfig,
// V1-only messages
AgxMsgMotionCommandV1,
AgxMsgValueSetCommandV1,
@@ -333,6 +338,7 @@ typedef struct {
VersionRequestMessage version_request_msg;
VersionResponseMessage version_response_msg;
ControlModeConfigMessage control_mode_config_msg;
BrakeModeConfigMessage brake_mode_config_msg;
SteerNeutralRequestMessage steer_neutral_request_msg;
SteerNeutralResponseMessage steer_neutral_response_msg;
StateResetConfigMessage state_reset_config_msg;

View File

@@ -41,6 +41,12 @@ typedef enum {
CONTROL_MODE_UART = 0x02
} ControlMode;
typedef enum {
// CONTROL_MODE_STANDBY = 0x00,
BRAKE_MODE_UNLOCK = 0x00,
BRAKE_MODE_LOCK = 0x01
} BrakeMode;
typedef enum {
RC_SWITCH_UP = 0,
RC_SWITCH_MIDDLE,

View File

@@ -39,6 +39,8 @@ struct HunterInterface {
virtual void SetMotionCommand(double linear_vel, double steering_angle) = 0;
virtual void SetBrakeMode(BrakeMode mode) = 0;
// get robot state
virtual HunterCoreState GetRobotState() = 0;
virtual HunterActuatorState GetActuatorState() = 0;

View File

@@ -93,6 +93,8 @@ class RobotCommonInterface {
"Only a derived version of this function with actual implementation "
"is supposed to be used.");
};
virtual void EnableBrakeMode(BrakeMode mode){};
};
} // namespace westonrobot

View File

@@ -268,6 +268,17 @@ class AgilexBase : public RobotCommonInterface {
break;
}
}
void EnableBrakedMode(BrakeMode mode) {
// construct message
AgxMessage msg;
msg.type = AgxMsgBrakeModeConfig;
msg.body.brake_mode_config_msg.mode = mode;
// encode msg to can frame and send to bus
can_frame frame;
if (parser_.EncodeMessage(&msg, &frame)) can_->SendFrame(frame);
}
};
} // namespace westonrobot

View File

@@ -36,6 +36,7 @@ class HunterBase : public AgilexBase<ParserType>, public HunterInterface {
angular_vel);
}
// get robot state
HunterCoreState GetRobotState() override {
auto state = AgilexBase<ParserType>::GetRobotCoreStateMsgGroup();
@@ -60,6 +61,10 @@ class HunterBase : public AgilexBase<ParserType>, public HunterInterface {
}
return hunter_actuator;
}
void SetBrakeMode(BrakeMode mode) override{
AgilexBase<ParserType>::EnableBrakeMode(mode);
}
};
} // namespace westonrobot

View File

@@ -25,6 +25,8 @@ class HunterRobot : public RobotCommonInterface, public HunterInterface {
void EnableCommandedMode() override;
void SetBrakeMode(BrakeMode mode) override;
void SetMotionCommand(double linear_vel, double angular_vel) override;
void ResetRobotState() override;