Reaching API
skelarm.reaching
Endpoint-feedback reaching controllers.
These controllers move the endpoint to a task-space target p* using a virtual
spring-damper in task space, rather than tracking a preplanned time trajectory.
They range from a constant target spring through time-varying stiffness to online
reference shaping with a shaped equilibrium p_s. All are stateful endpoint
controllers run via :func:skelarm.control.simulate_controlled.
Isotropic (scalar) task-space stiffness and damping are used, matching the planar
reaching formulation. See docs/reference/08_reaching_control.md for the theory.
AdaptiveReferenceShaping
Bases: OnlineReferenceShaping
Online reference shaping with slow/rapid adaptation of the apparent initial endpoint.
Extends online reference shaping (Seto-Sugihara IROS 2010) so the reach stays
smooth when the target changes mid-motion or a large external force displaces the
endpoint. An apparent initial endpoint p_a normalizes the shaping ratio
:func:adaptive_shaping_ratio; it drifts toward the current endpoint with a
first-order lag (slow adaptation) and is reset to the endpoint when the endpoint
leaves the current reaching region (rapid adaptation).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
ArrayLike
|
The task-space target (may be reassigned during motion). |
required |
k_task
|
float
|
Task-space stiffness and damping. |
required |
d_task
|
float
|
Task-space stiffness and damping. |
required |
c_joint
|
float
|
Joint viscous damping gain. |
0.0
|
epsilon
|
float
|
Small positive floor for the shaping ratio. |
0.01
|
t_adapt
|
float
|
Slow-adaptation time constant |
0.5
|
t1
|
float
|
Lag-filter time constants (seconds). |
0.1
|
t2
|
float
|
Lag-filter time constants (seconds). |
0.1
|
Source code in src/skelarm/reaching.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
apparent_initial
property
The current apparent initial endpoint p_a (None before reset).
__init__(target, *, k_task, d_task, c_joint=0.0, epsilon=0.01, t_adapt=0.5, t1=0.1, t2=0.1)
Store the shaping floor and slow-adaptation time constant.
Source code in src/skelarm/reaching.py
log_channels()
Record the endpoint, equilibrium, and apparent initial endpoint.
Source code in src/skelarm/reaching.py
reset(skeleton)
Initialize the apparent initial endpoint to the current endpoint.
update(t, skeleton, dt)
Adapt p_a, recompute the shaping ratio, then advance the lag filter.
Source code in src/skelarm/reaching.py
EndpointController
Bases: Controller
Base class for task-space spring-damper controllers.
Implements the shared law tau = J^T (k (p_eq - p) - D pdot) - Cq qdot given
a spring equilibrium p_eq and spring stiffness k chosen by subclasses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
ArrayLike
|
The task-space target |
required |
k_task
|
float
|
Task-space spring stiffness. |
required |
d_task
|
float
|
Task-space damping gain. |
required |
c_joint
|
float
|
Joint viscous damping gain |
0.0
|
Source code in src/skelarm/reaching.py
target
property
writable
The task-space target p*. Reassign it (then :meth:reset) to switch goals live.
__init__(target, *, k_task, d_task, c_joint=0.0)
Store the target and the stiffness / damping gains.
Source code in src/skelarm/reaching.py
log_channels()
Record the endpoint and the spring equilibrium once control has run.
Source code in src/skelarm/reaching.py
OnlineReferenceShaping
Bases: EndpointController
Online reference shaping with a fixed ratio r (Seto-Sugihara IROS 2009).
The spring equilibrium is a shaped reference p_s produced by passing
r p* + (1-r) p through a second-order lag filter (two cascaded first-order
lags with time constants t1 and t2). Feeding back the current endpoint
keeps p_s near the arm when the endpoint is constrained.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
ArrayLike
|
The task-space target. |
required |
k_task
|
float
|
Task-space stiffness and damping. |
required |
d_task
|
float
|
Task-space stiffness and damping. |
required |
c_joint
|
float
|
Joint viscous damping gain. |
0.0
|
r
|
float
|
Fixed shaping ratio in |
0.3
|
t1
|
float
|
Lag-filter time constants (seconds). |
0.1
|
t2
|
float
|
Lag-filter time constants (seconds). |
0.1
|
Source code in src/skelarm/reaching.py
__init__(target, *, k_task, d_task, c_joint=0.0, r=0.3, t1=0.1, t2=0.1)
Store the shaping ratio and lag-filter time constants.
Source code in src/skelarm/reaching.py
control(t, skeleton)
Return the spring-damper torque toward the shaped equilibrium p_s.
Source code in src/skelarm/reaching.py
reset(skeleton)
Initialize the shaped reference to the current endpoint at movement onset.
update(t, skeleton, dt)
Advance the second-order lag filter that produces the shaped equilibrium.
Source code in src/skelarm/reaching.py
PositionDependentShaping
Bases: OnlineReferenceShaping
Online reference shaping with a position-dependent ratio r(d) (Humanoids 2009).
Extends :class:OnlineReferenceShaping by recomputing the shaping ratio each
step from the normalized remaining distance, so the reach starts gently and
converges faster near the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
ArrayLike
|
The task-space target. |
required |
k_task
|
float
|
Task-space stiffness and damping. |
required |
d_task
|
float
|
Task-space stiffness and damping. |
required |
c_joint
|
float
|
Joint viscous damping gain. |
0.0
|
a
|
float
|
Small positive shaping constant for :func: |
0.01
|
t1
|
float
|
Lag-filter time constants (seconds). |
0.1
|
t2
|
float
|
Lag-filter time constants (seconds). |
0.1
|
Source code in src/skelarm/reaching.py
__init__(target, *, k_task, d_task, c_joint=0.0, a=0.01, t1=0.1, t2=0.1)
Store the shaping constant; the ratio r is recomputed each step.
Source code in src/skelarm/reaching.py
reset(skeleton)
Record the onset endpoint used to normalize the remaining distance.
update(t, skeleton, dt)
Recompute r(d) from the remaining distance, then advance the lag filter.
Source code in src/skelarm/reaching.py
TimeVaryingStiffness
Bases: EndpointController
Virtual spring-damper with a gamma-shaped time-varying stiffness k(t).
The stiffness starts at zero and grows to k0 (Sekimoto-Arimoto 2006), giving
a small initial torque. The damping gain is fixed at zeta1 * k0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
ArrayLike
|
The task-space target. |
required |
k0
|
float
|
Saturated stiffness. |
required |
alpha
|
float
|
Rate of the gamma-shaped stiffness rise. |
required |
zeta1
|
float
|
Damping ratio so the damping gain is |
required |
c_joint
|
float
|
Joint viscous damping gain. |
0.0
|
Source code in src/skelarm/reaching.py
__init__(target, *, k0, alpha, zeta1, c_joint=0.0)
Store the saturated stiffness, rate, and damping ratio.
Source code in src/skelarm/reaching.py
control(t, skeleton)
Return the spring-damper torque with the current time-varying stiffness.
log_channels()
Record the endpoint, equilibrium, and the current stiffness.
stiffness(t)
Gamma-distribution-shaped stiffness k(t) (zero at t<=0, ->k0).
Source code in src/skelarm/reaching.py
VirtualSpringDamper
Bases: EndpointController
Constant virtual spring-damper toward a fixed target (Arimoto-Sekimoto 2006).
Source code in src/skelarm/reaching.py
control(t, skeleton)
Return the spring-damper torque toward the fixed target.
adaptive_shaping_ratio(remaining, span, epsilon)
Adaptive shaping ratio r from an apparent initial endpoint (IROS 2010).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remaining
|
float
|
Remaining distance to the target, |
required |
span
|
float
|
Distance from the apparent initial endpoint to the target, |
required |
epsilon
|
float
|
Small positive floor ( |
required |
Returns:
| Type | Description |
|---|---|
float
|
|
Source code in src/skelarm/reaching.py
shaping_ratio(d, a)
Position-dependent shaping ratio r(d) (Humanoids 2009), clamped to (0, 1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
float
|
Normalized remaining distance |
required |
a
|
float
|
Small positive shaping constant ( |
required |
Returns:
| Type | Description |
|---|---|
float
|
|