From c0a0bfe1fcc007dc5b9111942f69568932ef95f3 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Wed, 6 May 2020 19:19:26 +0200 Subject: [PATCH 1/6] Fix a numerical issue in the trajectory planner that could cause sudden jumps of the position setpoint. If certain inputs were passed to trajectory planner, an expression inside the trajectory planner which is an argument to sqrtf() could become negative due to finite floating point accuracy. This led to Vr_ == NaN and then Tf_ == 0, causing the trajectory to jump to the final setpoint instantaneously. To the user, this manifested as a sudden increase in velocity (limited by controller.config.vel_limit) and/or an overcurrent fault. This bug was likely to show up when constantly sending trajectory setpoints while moving in the negative direction. See also: https://discourse.odriverobotics.com/t/move-to-pos-not-works-well/4626 --- CHANGELOG.md | 4 ++++ Firmware/MotorControl/trapTraj.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8102a27e..a162270d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Please add a note of your changes below this heading if you make a Pull Request. # Releases +## [0.4.12] - 2020-05-06 +### Changed +* Fixed a numerical issue in the trajectory planner that could cause sudden jumps of the position setpoint + ## [0.4.11] - 2019-07-25 ### Added * Separate lockin configs for sensorless, index search, and general. diff --git a/Firmware/MotorControl/trapTraj.cpp b/Firmware/MotorControl/trapTraj.cpp index f1e41aa5..ea244cd2 100644 --- a/Firmware/MotorControl/trapTraj.cpp +++ b/Firmware/MotorControl/trapTraj.cpp @@ -44,7 +44,7 @@ bool TrapezoidalTrajectory::planTrapezoidal(float Xf, float Xi, float Vi, // Are we displacing enough to reach cruising speed? if (s*dX < s*dXmin) { // Short move (triangle profile) - Vr_ = s * sqrtf((Dr_*SQ(Vi) + 2*Ar_*Dr_*dX) / (Dr_ - Ar_)); + Vr_ = s * sqrtf(std::fmax((Dr_*SQ(Vi) + 2*Ar_*Dr_*dX) / (Dr_ - Ar_), 0.0f)); Ta_ = std::max(0.0f, (Vr_ - Vi) / Ar_); Td_ = std::max(0.0f, -Vr_ / Dr_); Tv_ = 0.0f; From 4778ada84c9735854ab7a437622182b2ead8f44d Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Thu, 7 May 2020 12:00:50 -0700 Subject: [PATCH 2/6] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a162270d..5c9c5611 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ Please add a note of your changes below this heading if you make a Pull Request. # Releases ## [0.4.12] - 2020-05-06 -### Changed +### Fixed * Fixed a numerical issue in the trajectory planner that could cause sudden jumps of the position setpoint ## [0.4.11] - 2019-07-25 From 9ccca4352fa570daf70162b854a5642d5fa1c3c5 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Thu, 7 May 2020 12:14:38 -0700 Subject: [PATCH 3/6] make pypi script release by default --- tools/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/setup.py b/tools/setup.py index 986d9d0d..118f0ae5 100644 --- a/tools/setup.py +++ b/tools/setup.py @@ -32,7 +32,7 @@ to publish packages with the name odrive. """ # Set to true to make the current release -is_release = False +is_release = True # Set to true to make an official post-release, rather than dev of new version is_post_release = False From f31ccb5cd2c2248aac0c5f43d2c3a17b030b6cc4 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Fri, 8 May 2020 18:23:11 -0700 Subject: [PATCH 4/6] Update Gemfile.lock --- docs/Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 860837ad..93af7d5e 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -134,7 +134,7 @@ GEM jekyll (~> 3.3) jekyll-remote-theme (0.2.3) jekyll (~> 3.5) - rubyzip (>= 1.2.2, < 3.0) + rubyzip (>= 1.3.0, < 3.0) typhoeus (>= 0.7, < 2.0) jekyll-sass-converter (1.5.2) sass (~> 3.4) @@ -221,7 +221,7 @@ GEM ruby-enum (0.7.2) i18n ruby_dep (1.5.0) - rubyzip (1.2.2) + rubyzip (1.3.0) safe_yaml (1.0.4) sass (3.5.6) sass-listen (~> 4.0.0) From 7148de710abb5701dd2e24ca8e549121870fefa5 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Wed, 13 May 2020 17:45:50 -0700 Subject: [PATCH 5/6] Update odrivetool.md --- docs/odrivetool.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/odrivetool.md b/docs/odrivetool.md index cb8059c3..dddd5ea1 100644 --- a/docs/odrivetool.md +++ b/docs/odrivetool.md @@ -88,7 +88,7 @@ To compile firmware from source, refer to the [developer guide](developer-guide) * On some machines you will need to unplug and plug back in the USB cable to make the PC understand that we switched from regular mode to bootloader mode. * If the DFU script can't find the device, try forcing it into DFU mode. -
How to force DFU mode (ODrive v3.5)
+
How to force DFU mode (ODrive v3.5 and newer)
Flick the DIP switch that "DFU, RUN" to "DFU" and power cycle the board. After you're done upgrading firmware, don't forget to put the switch back into the "RUN" position and power cycle the board again.
From 0d45c3ff2266e5fec405aac4c891e65956227f32 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Mon, 25 May 2020 16:25:24 -0700 Subject: [PATCH 6/6] Fix default data_rate in liveplotter from 10 to 100 --- tools/odrive/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/odrive/utils.py b/tools/odrive/utils.py index f5ce0c7f..24a355a2 100755 --- a/tools/odrive/utils.py +++ b/tools/odrive/utils.py @@ -60,7 +60,7 @@ def dump_errors(odrv, clear=False): else: print(prefix + _VT100Colors['green'] + "no error" + _VT100Colors['default']) -data_rate = 10 +data_rate = 100 plot_rate = 10 num_samples = 1000 def start_liveplotter(get_var_callback):