Chapter 4 · Bumps that bend the path: the forcing term
Build a smooth push from weighted bumps, and predict where the path bends when you move one slider.
Picture a robot hand carrying a cup toward its goal, with a bowl sitting in the way: a straight path would knock the bowl off the table. To carry the cup safely over the rim, the hand has to lift and then come down, while a spring alone would pull it straight toward the goal. That lift needs another source, and in this chapter you build it: the push that bends the path.
The picture
Imagine listening to a song while you move the equalizer on a music player: bass, mids, and treble each have their own slider. As you push one slider up, that part of the sound grows stronger while the other sliders stay where you left them.
A DMP gives you that same feeling of shaping something one part at a time, because it splits the movement into overlapping stretches with a slider for each one. Raise a slider, and the robot pushes harder during that stretch of the motion. Those sliders are the weights \(\kforce{w_i}\), and the bands they control are the bumps, which we call basis functions.
The idea
Let us build that push together, starting with the clock and adding the pieces as we go.
In chapter 3 you met the phase \(\kphase{x}\), which runs from 1 down to 0 as the movement unfolds. That gives us a clock to place the bumps along, so each one has its own moment in the movement.
Along that phase, imagine laying out \(N\) little hills: each basis function is a bump-shaped curve \(\kbasis{\Psi_i}\), large near its own center \(\kbasis{c_i}\) and almost zero far away. We can think of each bump as “awake” near its center and “asleep” elsewhere, which gives it just one part of the motion to look after.
Now give each bump a weight, like setting its slider on the equalizer: a large weight brings a big push while the bump is awake, a negative weight pushes the other way, and a weight of zero contributes nothing.
Once we blend those weighted bumps into a smooth curve, we have the forcing term \(\kforce{f(x)}\). The bumps overlap along the way, so the blend has no jumps and can take almost any shape you like.
To bring the hand home at the end, we multiply the blend by the phase \(x\). Because \(x\) shrinks to nearly zero, the push fades away on its own, leaving the spring to have the last word as the hand lands on the goal.
Intuition: a smooth push built from sliders
Picture the bumps sitting side by side along the clock, each awake for a short while as the motion passes through. Multiply every bump by its slider and take a weighted average, then let the clock fade the result toward zero. You get a gentle push that is strongest where you set the sliders high and fades away as the movement ends.
The math
Intuition: a weighted average of bumps
At any moment, only a few bumps are awake, and each casts a vote with its weight to make the average push. As the movement draws to a close, the clock turns the volume down.
Two equations bring this picture together: the first builds the push from the weighted bumps, and the second describes the shape of a single bump. The centers \(\kbasis{c_i}\) come from the clock: the kit places the first at \(x = 1\) and the last at \(x = e^{-\alpha_x}\), spreading the bumps evenly in time.1 Neighboring bumps need to overlap, so their widths are chosen through \(h_i\); a larger \(h_i\) makes a narrower bump.
The math: eq. (4)–(5)
\[ \kforce{f(x)} = \frac{\sum_{i=1}^{N} \kforce{w_i}\,\kbasis{\Psi_i(x)}}{\sum_{i=1}^{N} \kbasis{\Psi_i(x)}}\; \kphase{x} \tag{4} \]
Read it aloud: take each bump \(\Psi_i\) at the current phase, multiply it by its weight \(w_i\), add them up, divide by the sum of the bumps (a weighted average), and then multiply by the phase \(x\).
\[ \kbasis{\Psi_i(x)} = \exp\!\big(-\kbasis{h_i}\,(x - \kbasis{c_i})^2\big) \tag{5} \]
Read it aloud: bump \(i\) is 1 when the phase sits exactly at its center \(c_i\), and it falls away smoothly on both sides, faster when \(h_i\) is large.
Where several bumps overlap, adding them without dividing would make the push stronger just because more bumps happened to be awake there. Dividing by their sum turns that crowd into a weighted average, with the awake bumps having the most say. The weights then give the heights you ask for, and the average never exceeds the biggest of them.
To see how the clock arranges the bumps, follow the same ten across the two panels below: on the left they sit along the phase \(x\), and on the right they sit along time \(t\).
With the bumps in place, we can watch ten weights join forces to make one forcing term. These weights were learned from the reach demonstration in the notebook; chapter 5 will walk you through how that learning happens.
Now bring the cup and bowl back into the picture and watch what one big weight does: with \(f = 0\) the spring slides straight to the goal. Give bump 4 a large weight, and the path rises above the goal before returning, making the bulge our cup needed.
Drag the weight \(w_4\) of bump 4 and watch one stretch of the path bulge up or dip down, while the push \(f\) below grows, shrinks or flips with it.
Follow the bend back to the slider that made it: one slider moved, and one stretch of the path bent. That local influence gives you something useful to hold onto, because you can predict where a weight change will show up.
Try it
Try it: 01_discrete_playground.ipynb › Create 1.5 - Challenge
Open the table of the gap for N = 2, 5, 10, 20, 30 and 60 bumps, and follow the shrinking gap as N grows. The gap levels off at about 0.3 % from N = 20 on, because that last bit comes from the time step rather than the bumps. As you explore, find the smallest N that keeps the path within 2 % and type it into MY_N. Each bump adds another slider to learn, so you are looking for enough to bend the path without keeping more than you need.
Gotcha
Gotcha: bumps evenly spaced in time look crowded in x
Symptom: when you plot the bumps against the phase, the last ones look squeezed together near 0 while the first ones look wide, as though something has gone wrong. Cause: the centers are spread evenly in time, and the phase decays like \(e^{-\alpha_x t/\tau}\), so equal steps in time become tiny steps in \(x\). This trips up everyone. Fix: nothing needs fixing, and this spacing also explains why the widths \(h_i\) differ from bump to bump. Follow them along time in the right panel of Figure 2, and you will see the evenly spread bumps again.