Answer
The caterpillars are keeping themselves at optimal temperatures as the weather changes from morning to afternoon.
Work Step by Step
You could test this by artificially changing the temperature in a controlled environment of caterpillars. In theory, the caterpillars would huddle on the east side (the direction of the sun and it’s warmth) when it’s cold and would hang loosely when it was warm.