Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #2

Draft
wants to merge 23 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8660de2
Implement GitHub workflow to automate releases
samuelsadok Oct 1, 2020
b917896
Update getting-started.md
Wetmelon Oct 28, 2020
a1ffbcf
[docs] Added page about ground loops and fixes.
PAJohnson Oct 28, 2020
c4cf673
[docs] Added links to isolators, added information about where the in…
PAJohnson Oct 29, 2020
4d75362
[docs] wording changes for ground-loops.md
PAJohnson Oct 29, 2020
a983767
[docs] updated units in hoverboard.md
PAJohnson Oct 31, 2020
59336d4
[docs] Fixed units and conversions in hoverboard.md
PAJohnson Nov 2, 2020
06e0ce8
[docs] Note added to hoverboard.md about parameter values
PAJohnson Nov 2, 2020
21ff75a
add docs to current sense saturation and current limit violation
madcowswe Nov 3, 2020
412fe9e
current control mode -> torque control mode
Wetmelon Nov 5, 2020
690525c
Update odrivetool.md
madcowswe Nov 19, 2020
8eed949
Update odrivetool.md
madcowswe Nov 19, 2020
e52f0f8
Merge pull request #499 from madcowswe/autorelease/v0.5.2
samuelsadok Dec 8, 2020
56c8b9c
Update specifications.md
Bin0ry Dec 17, 2020
f62fbbb
Merge pull request #540 from Bin0ry/patch-1
Wetmelon Dec 17, 2020
431bf91
[docs] update max step rate
PAJohnson Jan 13, 2021
9489fff
Add example for homing speed to docs
Wetmelon Jan 20, 2021
b996b34
Update encoders.md
PAJohnson Jan 28, 2021
296cfb0
Update odrivetool.md
PAJohnson Feb 11, 2021
df5b6d7
Fix Windows and Mac CI for master branch
PAJohnson Feb 11, 2021
fd85dd2
fucked with encoders
noiuynoise Feb 13, 2021
48a9680
compiled
Feb 13, 2021
f4845f4
re-compiled for native UART
Feb 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/actions/release-firmware/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: 'Release Firmware'
description: 'Compiles the firmware for the specified board version and uploads it to a GitHub release url'
inputs:
board_version:
required: true
url:
required: true
token:
required: true
runs:
using: "composite"
steps:
- name: Compile for ODrive ${{ inputs.board_version }}
shell: bash
run: |
# for debugging
arm-none-eabi-gcc --version
python3 --version

cd ${{ github.workspace }}/Firmware

echo "CONFIG_STRICT=true" > tup.config
echo "CONFIG_BOARD_VERSION=${{ inputs.board_version }}" >> tup.config
tup init
tup generate ./tup_build.sh
bash -xe ./tup_build.sh

- name: Upload ELF file
shell: bash
run: |
urls=( ${{ inputs.url }} )
URL="${urls[0]}=ODriveFirmware_${{ inputs.board_version }}.elf"
echo "uploading to $URL"

curl --silent --show-error --fail \
-H "Content-Type: application/octet-stream" \
-H "Authorization: token ${{ inputs.token }}" \
--data-binary @"Firmware/build/ODriveFirmware.elf" \
"$URL"

- name: Upload HEX file
shell: bash
run: |
urls=( ${{ inputs.url }} )
URL="${urls[0]}=ODriveFirmware_${{ inputs.board_version }}.hex"
echo "uploading to $URL"

curl --silent --show-error --fail \
-H "Content-Type: application/octet-stream" \
-H "Authorization: token ${{ inputs.token }}" \
--data-binary @"Firmware/build/ODriveFirmware.hex" \
"$URL"

# This is required to make the action repeatable
- name: Clean up
shell: bash
run: git clean -dffx
4 changes: 2 additions & 2 deletions .github/workflows/compile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
if: startsWith(matrix.os, 'macOS-')
run: |
brew install armmbed/formulae/arm-none-eabi-gcc
brew cask install osxfuse && brew install tup
brew install --cask osxfuse && brew install tup
pip3 install PyYAML Jinja2 jsonschema


Expand All @@ -76,7 +76,7 @@ jobs:
run: |
Invoke-WebRequest -Uri "http://gittup.org/tup/win32/tup-latest.zip" -OutFile ".\tup-latest.zip"
Expand-Archive ".\tup-latest.zip" -DestinationPath ".\tup-latest" -Force
echo "::add-path::$(Resolve-Path .)\tup-latest"
echo "$(Resolve-Path .)\tup-latest" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

choco install gcc-arm-embedded # downloads https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-win32.zip

Expand Down
109 changes: 109 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Create Release Draft

on:
push:
tags: ['fw-v*']

jobs:
release:
runs-on: ubuntu-latest
strategy:
fail-fast: true

steps:
- uses: actions/checkout@v2

- name: Parse Release Specs
id: release_specs
run: |
echo "github.ref = ${{ github.ref }}"

function get_version() { sed -E -n "s|.*([0-9]+\.[0-9]+\.[0-9]+).*|\1|p"; }

#LAST_VERSION="$(curl -s https://api.github.com/repos/madcowswe/ODrive/releases/latest | jq '.name' | get_version)"
#echo "previous version = $LAST_VERSION"

NEW_VERSION="$(echo "${{ github.ref }}" | get_version)"
echo "version = $NEW_VERSION"

ALL_TITLES="$(grep -E -n "^## .*[0-9]+\.[0-9]+\.[0-9]+" CHANGELOG.md)"

echo "I found the following version headers in the changelog:"
echo "$ALL_TITLES"

START_LINE="$(head -1 <<< "$ALL_TITLES" | cut -f 1 -d ':')"
END_LINE="$(head -2 <<< "$ALL_TITLES" | tail -1 | cut -f 1 -d ':')"

BODY="$(head -$(("$END_LINE" - 1)) CHANGELOG.md | tail +$(("$START_LINE" + 1)))"

IS_PRERELEASE="$(grep -F "$NEW_VERSION"-rc <<< "${{ github.ref }}" >/dev/null && echo true || echo false)"
echo "Is prerelease: $IS_PRERELEASE"

# The git tag is later read when packaging the python tools and
# compiling the firmware. We set it explicitly here in case the
# workflow was triggered by something other than a git tag.
git tag "${{ github.ref }}"

# Escape BODY string to set it as GitHub Actions output
BODY="${BODY//'%'/'%25'}"
BODY="${BODY//$'\n'/'%0A'}"
BODY="${BODY//$'\r'/'%0D'}"

echo "::set-output name=body::$BODY"
echo "::set-output name=version::$NEW_VERSION"
echo "::set-output name=is_prerelease::$IS_PRERELEASE"

- name: Create Release Draft
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Firmware version ${{ steps.release_specs.outputs.version }}
body: ${{ steps.release_specs.outputs.body }}
draft: true # Only do a draft so we have a change to manually review
# the release before it goes live.
prerelease: ${{ steps.release_specs.outputs.is_prerelease }}

- name: Install Prerequisites
run: |
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo add-apt-repository ppa:jonathonf/tup
sudo apt-get update
sudo apt-get install gcc-arm-embedded
sudo apt-get install tup
sudo apt install python3 python3-yaml python3-jinja2 python3-jsonschema

- name: Build Python Tools
run: |
cd ${{ github.workspace }}/tools
python setup.py sdist

cd dist
PKG_NAME="$(ls)"
if [ "$(wc -l <<< "$PKG_NAME")" != 1 ]; then
echo "Expected exactly one output file but got:"
ls
exit 1
fi

urls=( ${{ steps.create_release.outputs.upload_url }} )
URL="${urls[0]}=python-${PKG_NAME}"
echo "uploading to $URL"

curl --silent --show-error --fail \
-H "Content-Type: application/octet-stream" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--data-binary @"${PKG_NAME}" \
"$URL"

# Run the action under .github/actions/release-firmware for every board version
#- {uses: ./.github/actions/release-firmware, with: {board-version: v3.2, url: '${{ steps.create_release.outputs.upload_url }}', token: '${{ secrets.GITHUB_TOKEN }}' }}
#- {uses: ./.github/actions/release-firmware, with: {board-version: v3.3, url: '${{ steps.create_release.outputs.upload_url }}', token: '${{ secrets.GITHUB_TOKEN }}' }}
#- {uses: ./.github/actions/release-firmware, with: {board-version: v3.4-24V, url: '${{ steps.create_release.outputs.upload_url }}', token: '${{ secrets.GITHUB_TOKEN }}' }}
#- {uses: ./.github/actions/release-firmware, with: {board-version: v3.4-48V, url: '${{ steps.create_release.outputs.upload_url }}', token: '${{ secrets.GITHUB_TOKEN }}' }}
- {uses: ./.github/actions/release-firmware, with: {board_version: v3.5-24V, url: '${{ steps.create_release.outputs.upload_url }}', token: '${{ secrets.GITHUB_TOKEN }}' }}
- {uses: ./.github/actions/release-firmware, with: {board_version: v3.5-48V, url: '${{ steps.create_release.outputs.upload_url }}', token: '${{ secrets.GITHUB_TOKEN }}' }}
- {uses: ./.github/actions/release-firmware, with: {board_version: v3.6-24V, url: '${{ steps.create_release.outputs.upload_url }}', token: '${{ secrets.GITHUB_TOKEN }}' }}
- {uses: ./.github/actions/release-firmware, with: {board_version: v3.6-56V, url: '${{ steps.create_release.outputs.upload_url }}', token: '${{ secrets.GITHUB_TOKEN }}' }}
26 changes: 15 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ __pycache__/
*$py.class

# C extensions
*.so
#*.so

# Unit test / coverage reports
htmlcov/
Expand All @@ -31,8 +31,8 @@ target/
.ipynb_checkpoints

# Tup
.tup
tup.config
#.tup
#tup.config

# Sphinx documentation
/docs/_build/
Expand All @@ -48,21 +48,25 @@ tup.config
/docs/.jekyll-metadata


*.exe
#*.exe

ODrive\.config
#ODrive\.config

ODrive\.creator
#ODrive\.creator

ODrive\.creator\.user
#ODrive\.creator\.user

ODrive\.files
#ODrive\.files

ODrive\.includes
#ODrive\.includes

Firmware/Tests/bin/
#Firmware/Tests/bin/

# GUI
GUI/dist_electron
GUI/node_modules
GUI/build
GUI/build

#hex
!*.hex
!Firmware/build/
Binary file added Firmware/.tup/db
Binary file not shown.
Empty file added Firmware/.tup/object
Empty file.
Empty file added Firmware/.tup/shared
Empty file.
Empty file added Firmware/.tup/tri
Empty file.
Binary file added Firmware/.tup/vardict
Binary file not shown.
19 changes: 16 additions & 3 deletions Firmware/MotorControl/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,15 @@ bool Encoder::abs_spi_init(){
spi->Init.CLKPolarity = SPI_POLARITY_LOW;
spi->Init.CLKPhase = SPI_PHASE_2EDGE;
spi->Init.NSS = SPI_NSS_SOFT;
spi->Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
spi->Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; //slowed down from 32
spi->Init.FirstBit = SPI_FIRSTBIT_MSB;
spi->Init.TIMode = SPI_TIMODE_DISABLE;
spi->Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
spi->Init.CRCPolynomial = 10;
if (mode_ == MODE_SPI_ABS_AEAT) {
spi->Init.CLKPolarity = SPI_POLARITY_HIGH;
}
reset_AMS = false;
HAL_SPI_DeInit(spi);
HAL_SPI_Init(spi);
return true;
Expand All @@ -355,7 +356,11 @@ bool Encoder::abs_spi_start_transaction(){
return false;
}
HAL_GPIO_WritePin(abs_spi_cs_port_, abs_spi_cs_pin_, GPIO_PIN_RESET);
HAL_SPI_TransmitReceive_DMA(hw_config_.spi, (uint8_t*)abs_spi_dma_tx_, (uint8_t*)abs_spi_dma_rx_, 1);
if(reset_AMS){
HAL_SPI_TransmitReceive_DMA(hw_config_.spi, (uint8_t*)abs_spi_reset_enc, (uint8_t*)abs_spi_dma_rx_, 1);
}else{
HAL_SPI_TransmitReceive_DMA(hw_config_.spi, (uint8_t*)abs_spi_dma_tx_, (uint8_t*)abs_spi_dma_rx_, 1);
}
}
return true;
}
Expand Down Expand Up @@ -386,7 +391,15 @@ void Encoder::abs_spi_cb(){
case MODE_SPI_ABS_AMS: {
uint16_t rawVal = abs_spi_dma_rx_[0];
// check if parity is correct (even) and error flag clear
if (ams_parity(rawVal) || ((rawVal >> 14) & 1)) {
if (ams_parity(rawVal)) {
return;
}
if(((rawVal >> 14) & 1)){
reset_AMS = true;
return;
}
if(reset_AMS){
reset_AMS = false;
return;
}
pos = rawVal & 0x3fff;
Expand Down
3 changes: 3 additions & 0 deletions Firmware/MotorControl/encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ class Encoder : public ODriveIntf::EncoderIntf {

bool abs_spi_init();
bool abs_spi_start_transaction();
bool abs_spi_clear_AMS_error();
bool reset_AMS = false;
void abs_spi_cb();
void abs_spi_cs_pin_init();
uint16_t abs_spi_dma_tx_[1] = {0xFFFF};
uint16_t abs_spi_dma_rx_[1];
uint16_t abs_spi_reset_enc[1] = {0x0001 & (0x1 << 14)};
bool abs_spi_pos_updated_ = false;
Mode mode_ = MODE_INCREMENTAL;
GPIO_TypeDef* abs_spi_cs_port_;
Expand Down
Loading