  Topology optimization is a powerful tool utilized in various fields for
structural design. However, its application has primarily been restricted to
static or passively moving objects, mainly focusing on hard materials with
limited deformations and contact capabilities. Designing soft and actively
moving objects, such as soft robots equipped with actuators, poses challenges
due to simulating dynamics problems involving large deformations and intricate
contact interactions. Moreover, the optimal structure depends on the object's
motion, necessitating a simultaneous design approach. To address these
challenges, we propose "4D topology optimization," an extension of
density-based topology optimization that incorporates the time dimension. This
enables the simultaneous optimization of both the structure and self-actuation
of soft bodies for specific dynamic tasks. Our method utilizes multi-indexed
and hierarchized density variables distributed over the spatiotemporal design
domain, representing the material layout, actuator layout, and time-varying
actuation. These variables are efficiently optimized using gradient-based
methods. Forward and backward simulations of soft bodies are done using the
material point method, a Lagrangian-Eulerian hybrid approach, implemented on a
recent automatic differentiation framework. We present several numerical
examples of self-actuating soft body designs aimed at achieving locomotion,
posture control, and rotation tasks. The results demonstrate the effectiveness
of our method in successfully designing soft bodies with complex structures and
biomimetic movements, benefiting from its high degree of design freedom.
