updated ci, updated hunter set brake mode impl

This commit is contained in:
Ruixiang Du
2021-07-29 18:25:22 +08:00
parent 51820bbcb4
commit 5c878914fa
8 changed files with 39 additions and 33 deletions

View File

@@ -6,9 +6,9 @@ name: ROS
# events but only for the master branch # events but only for the master branch
on: on:
push: push:
branches: [ master, v2.x ] branches: [ next ]
pull_request: pull_request:
branches: [ master, v2.x ] branches: [ next ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel # A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs: jobs:
@@ -21,11 +21,11 @@ jobs:
steps: steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2 - uses: actions/checkout@v2
# - name: Install dependencies - name: Install dependencies
# run: sudo apt-get update && sudo apt-get install -y libasio-dev run: sudo apt-get update && sudo apt-get install -y libasio-dev
- name: Create catkin workspace - name: Create catkin workspace
run: mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace" run: mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
- name: Copy code to catkin workspace - name: Copy code to catkin workspace
run: cd /catkin_ws/src && git clone https://github.com/westonrobot/async_port.git && git clone -b v2.x https://github.com/westonrobot/ugv_sdk.git run: cd /catkin_ws/src && git clone -b next https://github.com/westonrobot/ugv_sdk.git
- name: Run catkin_make - name: Run catkin_make
run: cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make" run: cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make"

View File

@@ -2,9 +2,9 @@ name: Cpp
on: on:
push: push:
branches: [ master, v2.x ] branches: [ next ]
pull_request: pull_request:
branches: [ master, v2.x ] branches: [ next ]
jobs: jobs:
build: build:
@@ -13,11 +13,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
# - name: Install dependencies - name: Install dependencies
# run: sudo apt-get install -y build-essential cmake libasio-dev run: sudo apt-get install -y build-essential cmake libasio-dev
- name: Build and install dependent package
run: git clone https://github.com/westonrobot/async_port.git && cd async_port && mkdir build && cd build && cmake .. && make && sudo make install
- name: Update git submodule
run: git submodule update --init --recursive
- name: Build and pack - name: Build and pack
run: mkdir build && cd build && cmake -DBUILD_TESTS=ON .. && cmake --build . && cpack run: mkdir build && cd build && cmake -DBUILD_TESTS=ON .. && cmake --build . && cpack

View File

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

View File

@@ -64,6 +64,8 @@ class RobotCommonInterface {
/****** functions not available/valid to all robots ******/ /****** functions not available/valid to all robots ******/
// functions to be implemented by class AgilexBase // functions to be implemented by class AgilexBase
virtual void SetMotionMode(uint8_t mode){}; virtual void SetMotionMode(uint8_t mode){};
virtual void SetBrakedMode(BrakeMode mode){};
virtual CoreStateMsgGroup GetRobotCoreStateMsgGroup() { virtual CoreStateMsgGroup GetRobotCoreStateMsgGroup() {
throw std::runtime_error( throw std::runtime_error(
"Only a derived version of this function with actual implementation " "Only a derived version of this function with actual implementation "
@@ -93,8 +95,6 @@ class RobotCommonInterface {
"Only a derived version of this function with actual implementation " "Only a derived version of this function with actual implementation "
"is supposed to be used."); "is supposed to be used.");
}; };
virtual void EnableBrakeMode(BrakeMode mode){};
}; };
} // namespace westonrobot } // namespace westonrobot

View File

@@ -190,6 +190,17 @@ class AgilexBase : public RobotCommonInterface {
if (can_connected_) can_->StopService(); if (can_connected_) can_->StopService();
} }
void SetBrakeMode(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);
}
void ParseCANFrame(can_frame *rx_frame) { void ParseCANFrame(can_frame *rx_frame) {
AgxMessage status_msg; AgxMessage status_msg;
if (parser_.DecodeMessage(rx_frame, &status_msg)) { if (parser_.DecodeMessage(rx_frame, &status_msg)) {
@@ -268,17 +279,6 @@ class AgilexBase : public RobotCommonInterface {
break; 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 } // namespace westonrobot

View File

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

View File

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

View File

@@ -38,9 +38,14 @@ void HunterRobot::SetMotionCommand(double linear_vel, double angular_vel) {
hunter->SetMotionCommand(linear_vel, angular_vel); hunter->SetMotionCommand(linear_vel, angular_vel);
} }
void HunterRobot::SetBrakeMode(BrakeMode mode) { void HunterRobot::ActivateBrake() {
auto hunter = dynamic_cast<HunterInterface*>(robot_); auto hunter = dynamic_cast<HunterInterface*>(robot_);
hunter->SetBrakeMode(mode); hunter->ActivateBrake();
}
void HunterRobot::ReleaseBrake() {
auto hunter = dynamic_cast<HunterInterface*>(robot_);
hunter->ReleaseBrake();
} }
HunterCoreState HunterRobot::GetRobotState() { HunterCoreState HunterRobot::GetRobotState() {