Skip to content

Commit a5f4efe

Browse files
committed
Merge branch 'fw-v0.5.2rc1'
Merge v0.5.2rc1 branch into master
2 parents 411494c + dcc3f92 commit a5f4efe

File tree

499 files changed

+94724
-20888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

499 files changed

+94724
-20888
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps and configuration necessary to reproduce the behavior.
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Desktop (please complete the following information):**
20+
- OS: [e.g. Windows 10]
21+
- odrivetool Version (`odrivetool --version`)
22+
23+
**Additional context**
24+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/compile.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,22 @@ jobs:
108108
mv tup_build.sh tup_build.bat # in reality this is a .bat script on windows
109109
.\tup_build.bat
110110
111-
#code-checks:
112-
# runs-on: ubuntu-latest
113-
# steps:
111+
code-checks:
112+
strategy:
113+
fail-fast: false
114+
runs-on: ubuntu-latest
115+
steps:
116+
- uses: actions/checkout@v2
117+
118+
- name: Check that we're not using std::isnan
119+
run: |
120+
cd ${{ github.workspace }}/Firmware
121+
122+
if grep 'std::isnan' -R .; then
123+
echo "Don't use std::isnan because it's not compatible with '-ffast-math'. Use is_nan() instead."
124+
return 1;
125+
fi
126+
114127
# TODO:
115128
# - check if enums.py is consistent with yaml
116129
# - clang-format check

.github/workflows/nightly.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
steps:
1717
- name: Install odrivetool
18+
shell: bash
1819
run: |
19-
pip install monotonic # TODO: this is dishonest. Must be removed as soon as v0.5.0 is published!
20-
pip install odrive
20+
pip3 list | grep setuptools || echo "setuptools not installed" # show version
21+
pip3 install setuptools # TODO: this should be a dependency of odrive
22+
pip3 install odrive
23+
env:
24+
# TODO: this is a workaround for https://github.com/pypa/setuptools/issues/2353 and we
25+
# can remove it as soon as python3-setuptools on GitHub's ubuntu-latest
26+
# moves to version 50.1+.
27+
SETUPTOOLS_USE_DISTUTILS: stdlib
2128

2229
# This one currently fails because Github Actions runs pip as non-root
2330
#- name: Check if udev rules were set up properly
@@ -27,7 +34,7 @@ jobs:
2734
# This step is mentioned in the user guide
2835
- name: Add ~/.local/bin to path
2936
if: matrix.os == 'ubuntu-latest'
30-
run: echo "::add-path::~/.local/bin"
37+
run: echo "~/.local/bin" >> $GITHUB_PATH
3138

3239
- name: Launch odrivetool
3340
# This returns a non-zero exit code if the odrivetool throws an exception

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55

6-
# C extensions
7-
*.so
8-
96
# Unit test / coverage reports
107
htmlcov/
118
.tox/
@@ -65,4 +62,4 @@ Firmware/Tests/bin/
6562
# GUI
6663
GUI/dist_electron
6764
GUI/node_modules
68-
GUI/build
65+
GUI/build

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "Firmware/Private"]
2+
path = Firmware/Private
3+
url = git@github.com:madcowswe/ODrivePrivate.git
4+
branch = submodule

CHANGELOG.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,95 @@
11
# Unreleased Features
22
Please add a note of your changes below this heading if you make a Pull Request.
33

4+
# Releases
5+
## [0.5.2] - 2021-05-21
6+
7+
### Fixed
8+
* spinout error is no longer sticky and doesn't trigger on static torque loads due to I^2*R electrical power
9+
* Step and direction mode resets position when entering closed loop just like `input_pos` does
10+
* CAN baud rate setting is now correctly handled
11+
* `odrivetool dfu` works properly when an ODrive is flashed with the `dfu` switch set to "dfu".
12+
* `odrivetool dfu` now erases the entire flash memory before flashing firmware. This ensures that old configuration parameters are erased.
13+
* ASCII and the Native Protocol do not run at the same time on a UART interface. See `odrv0.config.uart0_protocol` and the `STREAM_PROTOCOL_TYPE` enums for details.
14+
15+
### Added
16+
* `sc` command to ascii protocol to run `odrv.clear_errors()`
17+
* Added phase balance check to motor calibration and MOTOR_ERROR_UNBALANCED_PHASES to error enums
18+
* Added polarity and phase offset calibration for hall effect encoders
19+
* [Mechanical brake support](docs/mechanical-brakes.md)
20+
* Added periodic sending of encoder position on CAN
21+
* Support for UART1 on GPIO3 and GPIO4. UART0 (on GPIO1/2) and UART1 can currently not be enabled at the same time.
22+
* Thermistors now have a 2nd order lowpass filter applied to reduce noise
23+
* 2-norm current clamping is used for AC induction motors
24+
* Added spinout detection to detect incorrect encoder offset and CONTROLLER_ERROR_SPINOUT_DETECTED to error enums.
25+
* Added AARCH64 support to libfibre
26+
* Tuning input mode added to provide sinusoidal position, velocity, or torque stimulus. See INPUT_MODE_TUNING and the controller class for details.
27+
* Added torque mirroring to INPUT_MODE_MIRROR
28+
* `mechanical_power_bandwidth`, `electrical_power_bandwidth`, `spinout_electrical_power_threshold`, `spinout_mechanical_power_threshold` added to `controller.config` for spinout detection.
29+
* `mechanical_power` and `electrical_power` added to `controller`.
30+
31+
### Changed
32+
* Step/dir performance improved! Dual axis step rates up to 250kHz have been tested
33+
* Apply_config is called for encoders after a successful direction find
34+
* Full calibration sequence now includes hall polarity calibration if a hall effect encoder is used
35+
* Modified encoder offset calibration to work correctly when calib_scan_distance is not a multiple of 4pi
36+
* Moved thermistors from being a top level object to belonging to Motor objects. Also changed errors: thermistor errors rolled into motor errors
37+
* Use DMA for DRV8301 setup
38+
* Make NVM configuration code more dynamic so that the layout doesn't have to be known at compile time.
39+
* GPIO initialization logic was changed. GPIOs now need to be explicitly set to the mode corresponding to the feature that they are used by. See `<odrv>.config.gpioX_mode`.
40+
* Previously, if two components used the same interrupt pin (e.g. step input for axis0 and axis1) then the one that was configured later would override the other one. Now this is no longer the case (the old component remains the owner of the pin).
41+
* New control loop architecture:
42+
1. TIM8 update interrupt handler (CNT = 0) runs at a high priority and invokes the system level function `sample_cb()` to sample all timing critical inputs (currently only encoder state).
43+
2. TIM8 update interrupt handler (CNT = 0) raises an NVIC flag to kick off a lower priority interrupt.
44+
3. The control loop interrupt handler checks if all ADC measurements are ready and informs both motor objects about the current measurements.
45+
4. The control loop interrupt handler invokes the system level function `control_loop_cb()` which updates all components (encoders, estimators, torque controllers, etc). The data paths between the components are configured by the Axis threads based on the requested state. This replaces the previous architecture where the components were updated inside the Axis threads in `Axis::run_control_loop()`.
46+
5. Meanwhile the TIM1 and TIM8 updates for CNT = 3500 will have fired. The control loop interrupt handler thus reads the new ADC measurements and informs both motor objects that a DC calibration event has happened.
47+
6. Finally, the control loop interrupt invokes `pwm_update_cb` on both motors to make them update their PWM timing registers.
48+
* Components that need low level control over PWM timings are implemented by inheriting from the `PhaseControlLaw` interface. Three components currently inherit this interface: `FieldOrientedController`, `ResistanceMeasurementControlLaw` and `InductanceMeasurementControlLaw`.
49+
* The FOC algorithm is now found in foc.cpp and and is presumably capable of running at a different frequency than the main control tasks (not relevant for ODrive v3).
50+
* ACIM estimator was consolidated into a separate component `<odrv>.acim_estimator`.
51+
* The Automatic Output Enable (AOE) flag of TIM1/TIM8 is used to achieve glitch-free motor arming.
52+
* Sensorless mode was merged into closed loop control mode. Use `<axis>.enable_sensorless_mode` to disable the use of an encoder.
53+
* More informative profiling instrumentation was added.
54+
* A system-level error property was introduced.
55+
* Added `torque_mirror_ratio` and use it to feed-forward `controller_.torque_output` in `INPUT_MODE_MIRROR`
56+
* Accumulate integer steps in step/dir to avoid float precision errors
57+
* Circular setpoint mode must be enabled when the step/dir interface is used.
58+
59+
### API Migration Notes
60+
* `axis.config.turns_per_step` changed to `axis.controller.config.steps_per_circular_range`
61+
* `odrive.axis.fet_thermistor`, `odrive.axis.motor_thermistor` moved to `odrive.axis.motor` object
62+
* `enable_uart` and `uart_baudrate` were renamed to `enable_uart0` and `uart0_baudrate`.
63+
* `enable_i2c_instead_of_can` was replaced by the separate settings `enable_i2c0` and `enable_can0`.
64+
* `<axis>.motor.gate_driver` was moved to `<axis>.gate_driver`.
65+
* `<axis>.min_endstop.pullup` and `<axis>.max_endstop.pullup` were removed. Use `<odrv>.config.gpioX_mode = GPIO_MODE_DIGITAL / GPIO_MODE_DIGITAL_PULL_UP / GPIO_MODE_DIGITAL_PULL_DOWN` instead.
66+
* `<axis>.config.can_node_id` was moved to `<axis>.config.can.node_id`
67+
* `<axis>.config.can_node_id_extended` was moved to `<axis>.config.can.is_extended`
68+
* `<axis>.config.can_heartbeat_rate_ms` was moved to `<axis>.config.can.heartbeat_rate_ms`
69+
* `<odrv>.get_oscilloscope_val()` was moved to `<odrv>.oscilloscope.get_val()`.
70+
* Several error flags from `<odrv>.<axis>.error` were removed. Some were moved to `<odrv>.error` and some are no longer relevant because implementation details changed.
71+
* Several error flags from `<odrv>.<axis>.motor.error` were removed. Some were moved to `<odrv>.error` and some are no longer relevant because implementation details changed.
72+
* `<axis>.lockin_state` was removed as the lockin implementation was replaced by a more general open loop control block (currently not exposed on the API).
73+
* `AXIS_STATE_SENSORLESS_CONTROL` was removed. Use `AXIS_STATE_CLOSED_LOOP_CONTROL` instead with `<odrv>.enable_sensorless_mode = True`.
74+
* `<axis>.config.startup_sensorless_control` was removed. Use `<axis>.config.startup_closed_loop_control` instead with `<odrv>.enable_sensorless_mode = True`.
75+
* `<axis>.clear_errors()` was replaced by the system-wide function `<odrv>.clear_errors()`.
76+
* `<axis>.armed_state` was replaced by `<axis>.is_armed`.
77+
* Several properties in `<axis>.motor.current_control` were changed to read-only.
78+
* `<axis>.motor.current_control.Ibus` was moved to `<axis>.motor.I_bus`.
79+
* `<axis>.motor.current_control.max_allowed_current` was moved to `<axis>.motor.max_allowed_current`.
80+
* `<axis>.motor.current_control.overcurrent_trip_level` was removed.
81+
* `<axis>.motor.current_control.acim_rotor_flux` was moved to `<axis>.acim_estimator.rotor_flux`.
82+
* `<axis>.motor.current_control.async_phase_vel` was moved to `<axis>.acim_estimator.stator_phase_vel`.
83+
* `<axis>.motor.current_control.async_phase_offset` was moved to `<axis>.acim_estimator.phase`.
84+
* `<axis>.motor.timing_log` was removed in favor of `<odrv>.task_times` and `<odrv>.<axis>.task_times`.
85+
* `<axis>.motor.config.direction` was moved to `<axis>.encoder.config.direction`.
86+
* `<axis>.motor.config.acim_slip_velocity` was moved to `<axis>.acim_estimator.config.slip_velocity`.
87+
* Several properties were changed to readonly.
88+
* `<axis>.encoder.config.offset` was renamed to ``<axis>.encoder.config.phase_offset`
89+
* `<axis>.encoder.config.offset_float` was renamed to ``<axis>.encoder.config.phase_offset_float`
90+
* `<odrv>.config.brake_resistance == 0.0` is no longer a valid way to disable the brake resistor. Use `<odrv>.config.enable_brake_resistor` instead. A reboot is necessary for this to take effect.
91+
* `<odrv>.can.set_baud_rate()` was removed. The baudrate is now automatically updated when writing to `<odrv>.can.config.baud_rate`.
92+
493
# Releases
594
## [0.5.1] - 2020-09-27
695
### Added
@@ -18,6 +107,8 @@ Please add a note of your changes below this heading if you make a Pull Request.
18107
* `axis.motor.get_inverter_temp()`, `axis.motor.inverter_temp_limit_lower` and `axis.motor.inverter_temp_limit_upper` have been moved to seperate fet thermistor object under `axis.fet_thermistor`. `get_inverter_temp()` function has been renamed to `temp` and is now a read-only property.
19108
* `axis.config.counts_per_step` is now `axis.config.turns_per_step`
20109
* Outputs of `axis.sensorless_estimator` are now in turns/s instead of electrical rad/s
110+
* Fixed bug of high current during lockin-ramp caused by `motor::update()` expecting a torque command instead of current
111+
* Fixed bug where commanded velocity was extremely high just after sensorless ramp when using `input_mode` INPUT_MODE_VEL_RAMP caused by `vel_setpoint` and `axis.config.sensorless_ramp.vel` being in different units
21112

22113
### Fixed
23114
* Fixed bug of high current during lockin-ramp caused by `motor::update()` expecting a torque command instead of current

Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ RUN add-apt-repository ppa:team-gcc-arm-embedded/ppa
77
RUN add-apt-repository ppa:jonathonf/tup
88
RUN apt-get update
99
RUN apt-get -y upgrade
10-
RUN apt-get -y install gcc-arm-embedded openocd tup python3.7 build-essential git
10+
RUN apt-get -y install gcc-arm-embedded openocd tup python3.7 python3-yaml python3-jinja2 python3-jsonschema build-essential git
1111

1212
# Build step below does not know about debian's python naming schemme
1313
RUN ln -s /usr/bin/python3.7 /usr/bin/python
1414

15-
# Copy the firmware tree into the container
16-
RUN mkdir ODrive
17-
COPY . ODrive
15+
RUN mkdir -p ODrive
1816
WORKDIR ODrive/Firmware
1917

20-
# Hack around Tup's dependency on FUSE
21-
RUN tup generate build.sh
22-
RUN ./build.sh
18+
# Must attach the firmware tree into the container
19+
CMD \
20+
# Regenerate python interface
21+
python interface_generator_stub.py \
22+
--definitions odrive-interface.yaml \
23+
--template ../tools/enums_template.j2 \
24+
--output ../tools/odrive/enums.py && \
25+
# Hack around Tup's dependency on FUSE
26+
tup init && \
27+
tup generate build.sh && \
28+
./build.sh

Firmware/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ STM32CubeMX
2626

2727
#gdb log
2828
openocd.log
29+
30+
# OS-specific files
31+
.DS_Store

Firmware/.vscode/c_cpp_properties.json

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,35 @@
33
{
44
"name": "Win32",
55
"includePath": [
6+
"${workspaceFolder}/Private/**",
67
"${workspaceFolder}/**"
78
],
89
"defines": [
9-
"STM32F405xx",
10+
"__arm__",
11+
"STM32F722xx",
12+
"FPU_FPV5",
1013
"USE_HAL_DRIVER",
11-
"HW_VERSION_MAJOR=3",
12-
"HW_VERSION_MINOR=6",
13-
"HW_VERSION_VOLTAGE=56",
14-
"USB_PROTOCOL_NATIVE",
14+
"HW_VERSION_MAJOR=4",
15+
"HW_VERSION_MINOR=1",
16+
"HW_VERSION_VOLTAGE=58",
17+
"FIBRE_ENABLE_SERVER",
18+
"FIBRE_ENABLE_CLIENT",
1519
"__weak=\"__attribute__((weak))\"",
1620
"__packed=\"__attribute__((__packed__))\"",
1721
"__GNUC__"
1822
],
19-
"intelliSenseMode": "gcc-x64",
20-
"compilerPath": "\"${ARM_GCC_ROOT}/bin/arm-none-eabi-g++.exe\" -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -specs=nosys.specs -specs=nano.specs -u _printf_float -u _scanf_float",
23+
"intelliSenseMode": "gcc-arm",
24+
"compilerPath": "arm-none-eabi-g++.exe",
25+
"compilerArgs": [
26+
"-mthumb",
27+
"-mcpu=cortex-m7",
28+
"-mfpu=fpv5-sp-d16",
29+
"-mfloat-abi=hard",
30+
"-specs=nosys.specs",
31+
"-specs=nano.specs",
32+
"-u _printf_float",
33+
"-u _scanf_float"
34+
],
2135
"cStandard": "c11",
2236
"cppStandard": "c++17"
2337
},
@@ -27,16 +41,20 @@
2741
"${workspaceFolder}/**"
2842
],
2943
"defines": [
44+
"__arm__",
3045
"STM32F405xx",
46+
"FPU_FPV4",
3147
"USE_HAL_DRIVER",
32-
"HW_VERSION_MAJOR=3",
33-
"HW_VERSION_MINOR=6",
34-
"HW_VERSION_VOLTAGE=56",
48+
"HW_VERSION_MAJOR=4",
49+
"HW_VERSION_MINOR=1",
50+
"HW_VERSION_VOLTAGE=58",
51+
"FIBRE_ENABLE_SERVER",
52+
"FIBRE_ENABLE_CLIENT",
3553
"__weak=\"__attribute__((weak))\"",
3654
"__packed=\"__attribute__((__packed__))\"",
3755
"__GNUC__"
3856
],
39-
"intelliSenseMode": "gcc-x64",
57+
"intelliSenseMode": "gcc-arm",
4058
"compilerPath": "arm-none-eabi-g++ -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -specs=nosys.specs -specs=nano.specs -u _printf_float -u _scanf_float",
4159
"cStandard": "c11",
4260
"cppStandard": "c++17"
@@ -47,16 +65,20 @@
4765
"${workspaceFolder}/**"
4866
],
4967
"defines": [
68+
"__arm__",
5069
"STM32F405xx",
70+
"FPU_FPV4",
5171
"USE_HAL_DRIVER",
52-
"HW_VERSION_MAJOR=3",
53-
"HW_VERSION_MINOR=4",
54-
"HW_VERSION_VOLTAGE=24",
72+
"HW_VERSION_MAJOR=4",
73+
"HW_VERSION_MINOR=1",
74+
"HW_VERSION_VOLTAGE=58",
75+
"FIBRE_ENABLE_SERVER",
76+
"FIBRE_ENABLE_CLIENT",
5577
"__weak=\"__attribute__((weak))\"",
5678
"__packed=\"__attribute__((__packed__))\"",
5779
"__GNUC__"
5880
],
59-
"intelliSenseMode": "gcc-x64",
81+
"intelliSenseMode": "gcc-arm",
6082
"cStandard": "c11",
6183
"cppStandard": "c++17"
6284
}

0 commit comments

Comments
 (0)