Bang-bang acceleration control of angular position

Compares a bang-bang 1 dimensional controller with a controller based on the SmootherStep function.
ダウンロード: 5
更新 2023/4/26

ライセンスの表示

function angs = bangBangAngles(ang0, angGoal, accMax, dt)
Computes angular positions for a bang-bang acceleration control that moves the robot from zero velocity at ang0 (rad) to zero velocity at angGoal (rad) as fast as possible with maximum acccleration accMax (rad/s). The output is a vector of positions every dt seconds. This is suitable to compute set of angular position commands for a robot joint. Bang-bang controller uses max acceleration until the halfway position, then does -1*max acceleration until the goal is reached.
inputs:
  • ang0: initial angle (rad)
  • angGoal: goal angle (rad)
  • accMax: maximum acceleration (rad)
  • dt: time resolution of angular positions to return (s)
outputs:
  • angs: a set of angular positions, every dt s for the object as it moves from ang0 to angGoal
The control picks the fastest (clockwise or counterclockwise) to go from the angle atan2( sin(ang0), cos(ang0) ) to atan2( sin(angGoal), cos(angGoal) ).
The control input is a bang-bang controller with acceleration
sign(angDelta)*accMax for tHalf seconds and
-sign(angDelta)*accMax for tHalf seconds.
The velocity of the robot is then
sign(angDelta)*accMax*t for t from 0 to tHalf and
sign(angDelta)*accMax*tHalf - sign(angDelta)*accMax*(t-tHalf) until 2*tHalf.
The position of the robot is then
ang0 + sign(angDelta)*1/2*accMax*t^2 for t from 0 to tHalf and
ang0 + sign(angDelta)*(1/2*accMax*tHalf^2 + accMax*tHalf*(t-tHalf)
- 1/2*accMax*(t-tHalf)^2) until 2*tHalf.
At tHalf the position of the robot is halfway to the goal, so we can solve for tHalf:
sign(angDelta)*1/2*accMax*tHalf^2 = angDelta/2
sign(angDelta)*accMax*tHalf^2 = angDelta
tHalf^2 = abs(angDelta/accMax)
tHalf = sqrt(abs(angDelta/accMax))
Aaron Becker, April 26, 2023.
function angs = smootherStepAngles(ang0, angGoal, T, dt)
computes angular positions for a smooth control input that moves the robot from ang0 to angGoal in total time T. The output is a vector of positions every dt seconds. This is suitable to compute set of angular position commands for a robot joint. Code is explained at https://en.wikipedia.org/wiki/Smoothstep, Ken Perlin suggested [Texturing and Modeling, Third Edition: A Procedural Approach] an improved version of the commonly used first-order smoothstep function, equivalent to the second order of its general form. It has zero 1st- and 2nd-order derivatives at x = 0 and x = 1.
inputs:
  • ang0: initial angle (rad)
  • angGoal: goal angle (rad)
  • T: time to reach goal (s)
  • dt: time resolution of angular positions to return (s)
outputs:
  • angs: a set of angular positions, every dt s for the object as it moves from ang0 to angGoal
function testbangBangAngles
compares the two functions bangBangAngles() and smootherStepAngles()

引用

Aaron T. Becker's Robot Swarm Lab (2024). Bang-bang acceleration control of angular position (https://www.mathworks.com/matlabcentral/fileexchange/128539-bang-bang-acceleration-control-of-angular-position), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2023a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0