Skip to content

Menu

WorksComputer Science

ClothCode: Generative Modeling for Garment State Estimation and Dynamics Prediction

Download PDFView on arXiv

Ask your agent about this work

Your agent reads this work through Valency, with its citations and similar works. Paste this at the start of a chat.

Use the Valency MCP. Work: W_vrk69wnf. Fetch it with get_paper_by_id, then find its nearest works with find_similar_papers and tell me what it adds.

Works with any MCP client. Not connected yet? Connect your agent

Abstract

We introduce ClothCode, a unified generative framework for garment state estimation and action-conditioned dynamics prediction in a shared discrete configuration space. A material-aligned tokenizer encodes garment configuration as residual vector-quantized patch tokens, while task-specific Masked Generative Transformers predict these tokens through parallel confidence-guided refinement. Across three garment templates, ClothCode reduces mean displacement error by 26.6% for state estimation and 37.0% for dynamics prediction relative to the strongest baselines. Dynamics prediction requires only 16.7 ms per window, compared with 556.2 ms for diffusion. Integrated into the same model-predictive controller, ClothCode improves real-world folding and flattening success from 56.7% to 78.9%. Further results and videos are available at: https://anonymous.4open.science/r/ClothCode-DE32

Introduction

Model-based cloth manipulation involves robots inferring the full shape of a garment from partial views and forecasting how it will deform in response to their actions [1]. These tasks are challenging because garments have high-dimensional configuration spaces and undergo complex deformations with frequent self-contact and environmental interactions. Severe self-occlusion makes the current state ambiguous, while unknown material properties and contact conditions add uncertainty to the garment’s future behavior. Effective planning thus requires an accurate garment-state estimation and an efficient dynamics model that can be queried repeatedly to evaluate candidate actions.

Existing cloth state and dynamics models are predominantly deterministic, producing a single prediction for each input [2], [3], [4]. Under ambiguous targets, deterministic predictors optimized with point-wise losses can favor conditional averages rather than distinct plausible garment configurations. UniClothDiff [5] instead formulates both state estimation and dynamics prediction as conditional diffusion. However, it generates dense continuous vertex states and displacements without explicitly constraining the predictions to learned local deformation representations. Its sampler also repeatedly denoises the complete output, which makes repeated evaluation costly during planning.

To address these limitations, we introduce ClothCode, a unified generative framework that formulates garment-state estimation and dynamics prediction as conditional generation in a shared discrete garment space as shown in Figure 1. Our working hypothesis is that, although complete garment configurations vary widely, local deformation patterns are shared

Overview of our discrete generative framework for model-based garment manipulation

Figure 1. Overview of our discrete generative framework for model-based garment manipulation. A garment configuration is encoded as a set of discrete patch tokens shared by two Masked Generative Transformers (MGTs). (1) The discrete garment representation captures local deformation states over fixed material patches. (2) For state estimation, an MGT iteratively predicts the complete token configuration from a partial point cloud. (3) For dynamics prediction, an action-conditioned MGT predicts future garment configurations for candidate actions, allowing MPC to select the trajectory with the lowest goal cost. (4) The resulting perception–prediction loop enables closed-loop garment manipulation on a real robot.

across different material regions and garment states. We thus partition the mesh into fixed, material-aligned patches and encode each patch as discrete tokens using residual vector quantization [6], [7], with codebooks shared across patches. A topology-aware decoder maps these tokens back to a continuous mesh geometry, resulting into a compact prediction space of learned patch-level configurations. For this, we use task-specific Masked Generative Transformers (MGTs) for state estimation and dynamics prediction [8], [9], [10], which iteratively refine tokens using confidence scores to enable parallel generation.

In this paper, our central contribution is to show that a shared, material-aligned discrete representation, combined with masked iterative generation, can make both garment perception and dynamics prediction more accurate, substantially faster, and more effective for real-world, closed-loop robotic manipulation. We demonstrate this on a large simulated dataset of 134,400 trajectories across three garment types, and validate it through real-world folding and flattening experiments on a dual-arm robot. Specifically, we found that ClothCode reduces mean displacement error by 26.6% (state) and 37.0% (dynamics) versus baselines, cuts dynamics inference time from 556.2 ms to 16.7 ms per window in simulation environments, and boosts real-world manipulation success from 56.7% to 78.9%.

Related Work

Cloth State Estimation Recovering complete cloth geometry from partial observations has been studied through canonical-space completion, mesh reconstruction, and generative modeling. GarmentNets [2] performs category-level garment reconstruction through canonical-space completion, while MEDOR [3] further refines reconstructed meshes using test-time self-supervision. More recently, UniClothDiff [5] formulates full-state estimation as conditional diffusion. These methods represent the recovered garment state in continuous geometric or latent spaces. In contrast, our discrete bottleneck presented herein constrains prediction to configurations expressed via a learned code vocabulary, while categorical token predictions further enable confidence-guided masked completion.

Cloth Dynamics Prediction Learned cloth dynamics have been modeled using particle-, graph-, and generative representations[11], [12], [13], [14]. Particle-based graph neural dynamics predict object motion through relational message passing [4]. PGND [15] instead combines object particles with a spatial grid to capture both dense local motion and global spatial structure UniClothDiff [5] models garment dynamics using conditional diffusion over continuous future states, while ClothTransformer [16] performs autoregressive prediction in a learned continuous latent space. In contrast, our model jointly refines discrete patch–time configuration tokens within each prediction window, allowing low-confidence future components to be revised without state-by-state autoregressive generation.

Discrete and Masked Generative Modeling Vector quantization provides discrete latent representations, with residual vector quantization increasing capacity through successive residual coding [6] [7][17]. MaskGIT [8] introduced parallel masked generation with confidence-guided token refinement[18], [19], which has since been extended to structured sequential domains such as 3D human motion with MoMask [9] and robot action generation with MGP [10]. Discrete abstractions have also been explored for cloth, but primarily as manipulation-oriented topological or semantic states [20] rather than representations of complete fine-grained geometry. In this paper, we propose to learn patch-wise discrete tokens for the full non-rigid patch-wise garment configuration and use the same configuration space for both full-state estimation and action-conditioned dynamics prediction.

Method

Given a known garment template with fixed connectivity and material correspondence, we represent its configuration at time tt by a triangular mesh with VV vertices, Xt=[xt,1,…,xt,V]T∈RV×3\mathbf{X}_t = [\mathbf{x}_{t,1}, \ldots, \mathbf{x}_{t,V}]^\mathsf{T} \in\mathbb{R}^{V \times3}, where xt,v\mathbf{x}_{t,v} denotes the position of vertex vv. Because vertex indexing is preserved across configurations, each vertex corresponds to the same material point over time. As stated above, ClothCode addresses two tasks: garment state estimation, which reconstructs the complete garment configuration from a partial point cloud, and dynamics prediction, which predicts future configurations from recent configurations together with the planned end-effector motion.

As shown in Figure 2, for each template, we first train a garment tokenizer on complete simulated meshes to encode

Figure 2. Overview of ClothCode. ClothCode first learns a discrete representation of garment shape (top). Each mesh is divided into fixed patches that track the same material regions across deformations, encoded as two-level residual vector-quantization (RVQ) tokens, and reconstructed by a shared mesh decoder. This frozen representation provides a common prediction space for two tasks. For state estimation (bottom left), a masked transformer combines a partial point cloud with masked garment tokens to recover the complete garment configuration and its global position. For dynamics prediction (bottom right), a second masked transformer combines recent garment states with a candidate end-effector trajectory and jointly predicts the future garment sequence and its global motion. M denotes a masked token.

centroid-relative garment configuration as discrete codebook indices, which we term garment tokens (Sec. III-A). The tokenizer is then frozen, defining a shared discrete configuration space for two conditional Masked Generative Transformers (MGTs) for state estimation and dynamics prediction. Since each mesh is centered before tokenization, the garment tokens encode only centroid-relative geometry. Global translation is therefore predicted separately by task-specific translation heads (Sec. III-B). At inference, both MGTs predict masked tokens in parallel and iteratively re-mask and re-predict low-confidence tokens (Sec. III-C); the frozen decoder maps the final tokens back to centroid-relative mesh configurations, which are combined with the corresponding centroid estimates to recover the garment configurations in world coordinates.

Discrete Garment Configuration

Patch construction

For tokenization, we remove global translation and normalize each mesh by defining ct=1V∑v=1Vxt,v\mathbf{c}_t = \frac{1}{V}\sum_{v=1}^{V}\mathbf{x}_{t,v} and x~t,v=(xt,v−ct)/σx\tilde{\mathbf{x}}_{t,v} = (\mathbf{x}_{t,v} - \mathbf{c}_t)/\sigma_x, where σx\sigma_x is a fixed normalization scale which is computed once from the training set as the standard deviation of centroid-centered vertex coordinates. The resulting normalized centroid-relative mesh is denoted by X~t\tilde{\mathbf{X}}_t. We partition the flat reference mesh into PP patches and keep the same vertices in each patch across all garment configurations. Specifically, farthest-point sampling selects PP representative vertices on the reference mesh as patch centers, and each vertex is assigned to its nearest center, yielding PP patches indexed by p=1,…,Pp = 1,\ldots,P. Because vertex correspondence is preserved over time, each patch therefore represents the same material region across all garment configurations.

Patch encoder

For each patch, we encode both its motion relative to the flat reference configuration and its within-patch deformation. The patch-level feature contains the displacement of the patch center, the displacements of its neighboring patches, and its center position in the reference mesh. In parallel, a shared PointNet-style encoder [21] aggregates the local deformation of the vertices within the patch. The two features are concatenated and projected to the model dimension. After adding a learned patch embedding, the PP patch features are processed together by a Transformer using self-attention [22], followed by a linear projection to obtain a continuous patch latent, zt,p∈Rdzz_{t,p} \in\mathbb{R}^{d_z}.

Residual Vector Quantization (RVQ)

Each continuous patch latent zt,pz_{t,p} is discretized by a two-level residual vector quantizer (RVQ) [6, 9], yielding two discrete codebook indices per patch. Each level r∈{1,2}r \in\{1,2\} uses a separate codebook, {ek(r)}k=1K\{e_k^{(r)}\}_{k=1}^{K}, shared across all patches of a garment template. Starting from rt,p(1)=zt,p\mathbf{r}_{t,p}^{(1)} = z_{t,p}, each level thereafter selects the nearest codebook vector for the current residual. That is, at each stage rr, the residual rt,p(r)\mathbf{r}_{t,p}^{(r)} is approximated by the nearest codeword eqt,p(r)(r)e_{q_{t,p}^{(r)}}^{(r)} from a learned codebook, where qt,p(r)q_{t,p}^{(r)} minimizes the squared Euclidean distance. This codeword is subtracted to form the next residual rt,p(r+1)\mathbf{r}_{t,p}^{(r+1)}, and the process repeats across stages, progressively representing the original vector as a sum of discrete codewords. The selected codebook vectors are summed to form the quantized patch latent zt,pq=∑r=12eqt,p(r)(r)\mathbf{z}_{t,p}^{q} = \sum_{r=1}^{2} e_{q_{t,p}^{(r)}}^{(r)}, which is passed to the mesh decoder. We refer to the two indices {qt,p(1),qt,p(2)}\{q_{t,p}^{(1)}, q_{t,p}^{(2)}\} as the garment tokens of patch pp. Collecting them across all patches gives the discrete garment configuration Qt∈{1,…,K}P×2\mathbf{Q}_t \in\{1,\ldots,K\}^{P \times2}.

Mesh decoder

The decoder reconstructs the normalized garment mesh from the quantized patch latents. A Transformer first jointly processes the PP quantized patch features to exchange information across material patches before vertex-level reconstruction. For each vertex, we concatenate its corresponding patch feature with a Fourier positional encoding[23] of its offset from the patch center in the flat reference mesh. A mesh GNN propagates the vertex features along the fixed mesh connectivity and predicts a 3-dimensional displacement for each vertex relative to the reference mesh, yielding the reconstructed configuration X^t\widehat{\mathbf{X}}_t.

Training

The tokenizer, comprising the patch encoder, RVQ module, and mesh decoder, is trained to reconstruct the normalized input mesh. The training objective combines mesh reconstruction and RVQ commitment losses, i.e. Ltok=Lrec+βLcommit\mathcal{L}_{\mathrm{tok}} = \mathcal{L}_{\mathrm{rec}} + \beta\mathcal{L}_{\mathrm{commit}}, where Lrec\mathcal{L}_{\mathrm{rec}} is the mean-squared error between X^t\widehat{\mathbf{X}}_t and X~t\widetilde{\mathbf{X}}_t, and β\beta weights the commitment loss. The RVQ codebooks are updated using exponential moving averages. After training, the patch encoder, RVQ codebooks, and mesh decoder are frozen.

Masked Generative Garment Models

We formulate state estimation and dynamics prediction as conditional masked generation in the discrete garment space, i.e. p(Qt∣Ot)p(\mathbf{Q}_t \mid\mathbf{O}_t) and p(Qt+1:t+H∣Qt−C+1:t,A)p(\mathbf{Q}_{t+1:t+H} \mid\mathbf{Q}_{t-C+1:t}, \mathbf{A}), respectively, where Ot\mathbf{O}_t denotes the partial observation and A\mathbf{A} the planned end-effector motion. Both tasks are modeled by task-specific Masked Generative Transformers (MGTs) [8, 10], each comprising a conditioning encoder and a masked Transformer operating in the discrete garment space. Starting from masked target garment tokens, the MGT predicts their codebook indices in parallel and iteratively re-predicts low-confidence tokens over a small number of refinement steps. The predicted indices are then converted to quantized patch latents using the frozen RVQ codebooks and decoded by the mesh decoder to reconstruct the garment configuration.

State estimation

Given a partial point-cloud observation Ot\mathbf{O}_t, let ctvis\mathbf{c}_t^{\mathrm{vis}} denote the centroid of the observed points. We center the point cloud at ctvis\mathbf{c}_t^{\mathrm{vis}} and normalize its coordinates using the same fixed scale σx\sigma_x as the garment tokenizer. The point-cloud encoder produces two outputs with different roles. It maps the observed points to point features. A fixed set of learned query tokens attends to these point features through cross-attention to produce multiple point-cloud tokens. In parallel, the point features are also pooled into a single global point-cloud feature that captures the overall observation. For each garment patch, the embeddings of its two RVQ levels are summed to form one patch token. The point-cloud tokens are prepended to the garment patch tokens, and the combined sequence is processed by a stack of self-attention Transformer blocks. The global point-cloud feature modulates each Transformer block through AdaLN-zero [24]. The output feature of each garment patch is passed to two level-specific classification heads to predict its two RVQ indices. The global point-cloud feature is also used for centroid prediction. Together with ctvis\mathbf{c}^{\mathrm{vis}}_t, it is passed to a centroid MLP head that predicts the centroid residual δ^t\hat{\delta}_t. The complete garment centroid is then recovered as c^t=ctvis+sxδ^t\hat{\mathbf{c}}_t = \mathbf{c}^{\mathrm{vis}}_t + s_x\hat{\delta}_t.

b) Dynamics prediction.: The dynamics model predicts HH future discrete garment configurations conditioned on CC context configurations and the planned end-effector trajectory. At each future step, the action input combines the gripper position relative to the garment centroid at the final context frame with the end-effector displacement between the current and previous trajectory steps. Both are normalized and encoded using Fourier features [23] followed by an MLP, and the resulting embedding is added to the garment patch tokens at the corresponding future step. Together, the (CC) context steps and (HH) action-conditioned future steps are concatenated along the temporal dimension to form a joint spatiotemporal sequence. Each of the C+HC + H time steps contains PP garment patch tokens, yielding (C+H)P(C + H)P patch–time positions. Each token is assigned a learned patch embedding that identifies the garment patch and a learned temporal embedding that identifies the time step. A separate role embedding indicates whether the token belongs to a context or future configuration. The resulting (C+H)P(C + H)P garment patch tokens are flattened into a single sequence and processed by a stack of self-attention Transformer blocks in MGT, allowing each token to attend to garment patches across all context and future time steps. Two level-specific classification heads predict the two RVQ indices from the Transformer output at each future patch–time position. Since the discrete garment configuration represents centroid-relative geometry, global translation is predicted separately. The centroid-displacement head uses the Transformer outputs obtained with all future garment tokens masked. For each future time step, the outputs of its PP garment patches are averaged and passed to the head to predict the centroid displacement relative to the final context configuration.

c) Training : During training, for each example, we sample u∼U(0,1)u \sim U(0,1) and set the mask ratio to γ(u)=cos⁡(πu/2)\gamma(u) = \cos(\pi u/2). We randomly mask this fraction of the target RVQ indices, and each masked index is replaced by the learned [MASK] embedding of its RVQ level. Let M\mathcal{M} denote the masked set and η\eta the task condition. For state estimation, η=Ot\eta= \mathbf{O}_t; for dynamics prediction, η=(Qt−C+1:t,A)\eta= (\mathbf{Q}_{t-C+1:t}, \mathbf{A}), with all context tokens kept unmasked. Given the task condition and the remaining unmasked tokens, ClothCode predicts the original indices at the masked positions. We minimize cross-entropy over the masked tokens:

Lmask=−1∣M∣∑i∈Mlog⁡pθ(qi∣qM,η),(1)\mathcal{L}_{\mathrm{mask}} = -\frac{1}{|\mathcal{M}|}\sum_{i\in\mathcal{M}}\log p_{\theta}(q_i\mid q_{\mathcal{M}},\eta), \tag*{(1)}

where qMq_{\mathcal{M}} denotes the unmasked target tokens. The masked-token objective is optimized jointly with an L1L_1 loss for centroid prediction:

Lstate=Lmaskstate+λc3∥δ^t−δt∥1,\mathcal{L}_{\mathrm{state}} = \mathcal{L}_{\mathrm{mask}}^{\mathrm{state}} + \frac{\lambda_c}{3}\left\|\hat{\delta}_t-\delta_t\right\|_1,
Ldyn=Lmaskdyn+λtrans3H∑h=1H∥d^t+h−dt+h∥1.(2)\mathcal{L}_{\mathrm{dyn}} = \mathcal{L}_{\mathrm{mask}}^{\mathrm{dyn}} + \frac{\lambda_{\mathrm{trans}}}{3H}\sum_{h=1}^{H}\left\|\hat{d}_{t+h}-d_{t+h}\right\|_1. \tag*{(2)}

where λc\lambda_c and λtrans\lambda_{\mathrm{trans}} are the weights for the centroid-residual and future-translation L1L_1 losses, respectively. The factor 1/31/3 averages the absolute error over the three spatial coordinates, while 1/(3H)1/(3H) additionally averages over the HH future steps. For dynamics prediction, d^t+h\hat{d}_{t+h} is obtained from the fully masked companion pass described above.

Mask-and-Refine Inference

Both tasks use the same confidence-guided mask-and-refine procedure from MGT[8]. State estimation begins with all garment tokens masked, whereas dynamics prediction masks all future tokens while keeping the context tokens fixed. We use four refinement iterations for both tasks. At each iteration, MGT predicts the logits of all masked tokens in parallel, from which the codebook indices are sampled using the Gumbel-Max with temperature τ\tau. The softmax probability assigned to each sampled codebook index is used as its confidence score. A decreasing number of the lowest-confidence tokens are re-masked according to a cosine schedule and generated again in the next iteration, while the higher-confidence tokens are retained. After refinement, the predicted indices are converted to quantized patch latents using the frozen RVQ codebooks and decoded by the frozen mesh decoder. The meshes are then transformed to world coordinates using the estimated garment centroid for state estimation and the predicted centroid displacements for dynamics prediction.

Implementation Details

We partition each garment template into P=128P = 128 material-aligned patches and use a two-level RVQ with K=512K = 512 entries per level and a 64-D patch latent. The tokenizer uses a 256-D Transformer backbone with two encoder and four decoder layers. The dynamics model uses four Transformer blocks with eight attention heads and a hidden dimension of 256, and predicts H=10H = 10 future configurations from C=3C = 3 context configurations. The state-estimation model uses six Transformer blocks with eight attention heads and the same hidden dimension. We use four mask-and-refine iterations for dynamics prediction and state estimation.

Experiment Setup

Dataset Collection

Reliable cloth state estimation and dynamics prediction require data spanning diverse cloth configurations, manipulation actions, and physical properties. We therefore construct a large-scale simulated dataset in Isaac Sim 5.1 with Isaac Lab 2.2.1 [25], using GPU-based deformable-body simulation with self-collision enabled. We consider three fixed-topology templates—a fabric sheet, a T-shirt, and a sweater—initialized from flat, crumpled, and folded configurations.

Each action instance is parameterized by a vector controlling the grasp, target, lifting height, and motion, and records the full garment mesh and end-effector Cartesian position at every frame. We include fold, reposition, and flatten actions, together with garment-specific sleeve-fold and cross-arm actions. For each valid template–initial-configuration–action combination, we sample 700 distinct action instances. Each instance is simulated under eight material-property configurations spanning friction, stiffness, and density, with additional perturbations within each configuration to broaden the range of plausible cloth properties. The resulting dataset contains 16,800 action instances and 134,400 simulated trajectories. For state estimation, partial point clouds are rendered from virtual depth cameras. We randomize camera azimuth, elevation, and distance, and include the gripper and forearm in the rendered scene to model robot-induced occlusion. We further apply zero-mean Gaussian depth noise with σ=3\sigma= 3 mm, randomly drop 10%–20% of observed points, and perturb camera extrinsics with per-axis Gaussian translation noise of σ=5\sigma= 5 mm and random-axis rotation noise of σ=1.5∘\sigma= 1.5^\circ.

We construct three evaluation settings to separately assess generalization to unseen actions and unseen material properties. ID contains action instances that are not used for training but are drawn from the same action and material-property distributions, measuring generalization to unseen trajectories under in-distribution conditions. Action-OOD evaluates action generalization by withholding continuous regions of the action-parameter space from training and testing exclusively on action instances from these held-out regions. For example, for fold actions, we withhold fold fractions in [0.42, 0.70], where the fold fraction specifies the fraction of the distance from the grasp point to the opposing edge traversed during the fold. For reposition actions, we withhold the boundary region where both the grasp and target lie in the upper-right part of their normalized coordinate spaces (x,y>0.69)(x, y > 0.69). For the ID and Action-OOD splits, assignment is performed at the action-instance level, so all material variants of the same action instance remain in the same partition. Physics-OOD evaluates unseen material-property configurations using held-out action instances drawn from the same action distribution as training. Six material configurations are used in all training stages, while the remaining two are withheld from both tokenizer and predictive-model training and used exclusively for Physics-OOD evaluation. This preserves the action distribution while isolating the shift in material configuration.

Examples of this dataset are shown in the accompanying video. The dataset available at https://anonymous.4open.science/r/ClothCode-DE32.

Task Description

We evaluate our framework in both simulation and real-world manipulation. In simulation, we evaluate full-state reconstruction under ID and Action-OOD settings, and action-conditioned dynamics prediction under ID, Action-OOD, and Physics-OOD settings. For dynamics, we additionally evaluate two rollout models: Oracle, using ground-truth context at each prediction window, and Free, autoregressively using previous predictions as context. We further integrate the learned state and dynamics models into model-predictive control (MPC)[26] for real-world folding and flattening.

a) Folding: Starting from an approximately flat configuration, the robot is required to transform the cloth into a prescribed folded configuration. We consider multiple folding targets, including diagonal-folds and target-specific folded shapes.

b) Flattening: Starting from a crumpled configuration, the robot is required to recover an approximately flat state. Rather than following a prescribed folding geometry, the controller must select actions that progressively reduce folds and overlaps from highly variable initial configurations.

Simulation experiments are conducted on three garment templates. A rectangular fabric, a T-shirt, and a sweater. Their dimensions are approximately 40 × 40 cm, 78.9 × 66.2 cm, and 128.1 × 69.2 cm, respectively. Each template is represented by a mesh containing approximately 6,000 vertices. Real-world experiments use three fabric sheets, three T-shirts, and three sweaters with varying sizes and material properties. Within each category, all garments are mapped to the same simulated template and evaluated using the same template-specific model.

Motion Planning

We use OWLv2 [27] and SAM2 [28] to segment the garment from a single RGB-D observation and extract the corresponding partial point cloud. Our model reconstructs the complete cloth mesh, which is registered to the observation by matching its spatial extent followed by ICP refinement [29]. The target configuration is captured beforehand from an RGB-D camera and reconstructed using the same state-estimation pipeline. Following Uni-ClothDiff [5], the grasp vertex is sampled according to the displacement between the current and target configurations, so that vertices farther from their target positions are more likely to be selected. For planning, we use CEM sampling-based MPC [30]. We optimize a horizon-40 sequence of 3-D relative end-effector displacements using 16 candidate sequences per iteration for five optimization iterations and after optimization, the robot executes the first 10 steps of the lowest-cost sequence before replanning. Each candidate sequence is rolled out with the learned dynamics model and scored by a terminal cost combining MSE and Chamfer distance to the target configuration. After execution, the garment is re-observed and its state re-estimated before the next planning cycle, forming a closed-loop perception–prediction–control loop.

MethodID MDE↓ID EMD↓Action-OOD MDE↓Action-OOD EMD↓Physics-OOD MDE↓Physics-OOD EMD↓Rollout Oracle↓Rollout Free↓
UCD-Transformer[5]1.6521.5112.1381.9651.9871.7411.3062.684
UniClothDiff1.1721.1181.5081.4651.3791.3281.9203.916
PGND1.3451.1501.7021.4951.5451.3441.4992.957
ClothCode (Ours)0.7300.6940.8840.8430.8590.8180.8641.822
UCD-Transformer1.1511.1141.3321.3061.3071.2691.0602.335
UniClothDiff1.0140.9841.2631.2471.2061.1751.2452.675
PGND1.1111.0041.3171.2091.2911.1891.1532.432
ClothCode (Ours)0.6740.6510.7620.7500.7680.7440.7251.654
UCD-Transformer1.4521.4021.6591.6211.7941.7501.0962.312
UniClothDiff0.9790.9611.2081.1971.2111.1921.6453.560
PGND0.9960.8901.1571.1451.1781.0701.1562.337
ClothCode (Ours)0.6530.6360.7010.6940.8060.7880.7491.362

Table I. Table I. Action-conditioned dynamics prediction (cm, ↓). Single-window results predict 10 future frames from 3 context frames. Rollout MDE is reported on ID with oracle and predicted (free) context.

GarmentMethodEval A (ID) MDE↓Eval A (ID) EMD↓Eval A (ID) Chamfer↓Eval B (Action-OOD) MDE↓Eval B (Action-OOD) EMD↓Eval B (Action-OOD) Chamfer↓
FabricUniclothdiff Transformer1.3841.2051.7701.6241.3521.896
FabricTransformer1.9101.3881.8812.2851.5652.021
FabricGarmentNets1.9931.7452.3142.1911.8702.423
FabricMEDOR2.1061.8092.3432.2901.9182.417
FabricClothCode (Ours)0.8900.6801.1821.1040.7951.279
T-shirtUniclothdiff Transformer1.9731.6902.3221.9561.6662.301
T-shirtTransformer3.6782.6492.9703.9032.7153.029
T-shirtGarmentNets2.8682.4953.1072.9762.6143.259
T-shirtMEDOR2.9982.5293.0253.0622.6093.088
T-shirtClothCode (Ours)2.1110.9661.5181.1730.9151.427
SweaterUniclothdiff Transformer1.6651.3111.9371.9131.4462.036
SweaterTransformer3.6371.5202.0703.2061.6492.159
SweaterGarmentNets3.2412.6112.7993.7362.9923.136
SweaterMEDOR3.2522.5872.6353.7182.9302.911
SweaterClothCode (Ours)1.4520.9551.5371.9021.1391.704

Table II. Table II. Garment state estimation from partial point-cloud observations.

State + DynamicsFabric F/UT-shirt F/USweater F/U
ClothCode + Uniclothdiff83.3/76.766.7/70.050.0/56.7
Uniclothdiff + ClothCode73.3/73.370.0/70.060.0/66.7
Uniclothdiff + Uniclothdiff66.7/66.756.7/60.040.0/50.0
ClothCode + ClothCode (Ours)90.0/80.080.0/80.066.7/76.7

Table III. Table III. Real-world MPC success rates (%). Each garment column reports folding/flattening (F/U), respectively.

Experiment

All errors are reported in centimeters. Mean displacement error (MDE) measures the mean Euclidean distance between corresponding vertices. Earth Mover’s Distance (EMD) and Chamfer distance compare meshes as point sets using optimal and nearest-neighbour matching, respectively. We report MDE and EMD for both tasks, and additionally Chamfer distance for full-state estimation to remain comparable with garment-reconstruction literature.

Dynamics Prediction

Baselines

We compare ClothCode with three cloth-dynamics models. UniClothDiff [5] uses Transformer-based diffusion to predict continuous future cloth states. UCD-Transformer [5] uses the same backbone with direct MSE regression. PGND [15] propagates dense particles through a spatial grid. All models use the same trajectories and splits, and predict ten future states from three context states.

a) Results.: Table I shows that ClothCode achieves the lowest MDE and EMD across all garments and evaluation splits, reducing them by 37.0% and 36.2% on average relative to the strongest baselines. The gains remain substantial under Action-OOD and Physics-OOD, with MDE reductions of 40.2% and 35.2%, respectively. Over multi-window rollouts, MGT reduces MDE by 32.4% under Oracle context and 34.1% under Free rollout. Despite using four refinement steps, ClothCode requires only 16.7 ms per prediction window, compared with 556.2 ms for Uniclothdiff model [5] using 100 denoising steps. Fig. 3 further shows improved preservation of garment structure over long horizons.

Garment state Estimation

a) Baselines.: We compare ClothCode against the corresponding Transformer and Diffusion baselines described above [5], together with two garment-reconstruction methods. GarmentNets [2] reconstructs garment pose through canonical-space shape completion, while MEDOR [3] further

refines the reconstructed mesh through test-time optimization.

b) Results.: Table II shows that ClothCode achieves the best performance across all garment categories, evaluation splits, and metrics, reducing MDE, EMD, and Chamfer distance by 26.6%, 36.8%, and 29.2% on average relative to Uniclothdiff [5], the strongest baseline. The gains remain substantial under Action-OOD, with corresponding reductions of 23.9%, 36.2%, and 29.2%. Notably, the relative improvement in EMD exceeds that in MDE for every garment under both splits, indicating stronger recovery of overall garment geometry. The improvement is particularly pronounced for the T-shirt under Action-OOD, where MDE, EMD, and Chamfer distance decrease by 40.0%, 45.1%, and 38.0%, respectively. Fig. 4 further shows that ClothCode better preserves global garment shape and folded structure under partial observation and self-occlusion.

Real-World Planning

Using a Baxter robot and a single ZED 2i camera, we evaluate all four combinations of ClothCode and Uniclothdiff [5] state estimation and dynamics prediction under the same MPC and execution settings. We test three garments per category on folding and flattening, with ten trials per instance, and define success as a final-mask IoU of at least 0.80 with the target. As shown in Table III, ClothCode state estimation and dynamics prediction achieves the highest success rate in all six garment–task settings, reaching 78.9% overall. Replacing the state estimator or dynamics model with Uniclothdiff reduces overall success to 68.9% and 67.2%, respectively, while replacing both reduces it to 56.7%. The mixed variants also reveal a category-dependent

@page 6/8 starts_mid=0 ends_mid=1 garment is re-observed and its state re-estimated before the next planning cycle, forming a closed-loop perception–prediction–control loop.

Experiment

All errors are reported in centimeters. Mean displacement error (MDE) measures the mean Euclidean distance between corresponding vertices. Earth Mover’s Distance (EMD) and Chamfer distance compare meshes as point sets using optimal and nearest-neighbour matching, respectively. We report MDE and EMD for both tasks, and additionally Chamfer distance for full-state estimation to remain comparable with garment-reconstruction literature.

Dynamics Prediction

Baselines

We compare ClothCode with three cloth-dynamics models. UniClothDiff [5] uses Transformer-based diffusion to predict continuous future cloth states. UCD-Transformer [5] uses the same backbone with direct MSE regression. PGND [15] propagates dense particles through a spatial grid. All models use the same trajectories and splits, and predict ten future states from three context states.

a) Results.: Table I shows that ClothCode achieves the lowest MDE and EMD across all garments and evaluation splits, reducing them by 37.0% and 36.2% on average relative to the strongest baselines. The gains remain substantial under Action-OOD and Physics-OOD, with MDE reductions of 40.2% and 35.2%, respectively. Over multi-window rollouts, MGT reduces MDE by 32.4% under Oracle context and 34.1% under Free rollout. Despite using four refinement steps, ClothCode requires only 16.7 ms per prediction window, compared with 556.2 ms for Uniclothdiff model [5] using 100 denoising steps. Fig. 3 further shows improved preservation of garment structure over long horizons.

Garment state Estimation

a) Baselines.: We compare ClothCode against the corresponding Transformer and Diffusion baselines described above [5], together with two garment-reconstruction methods. GarmentNets [2] reconstructs garment pose through canonical-space shape completion, while MEDOR [3] further

refines the reconstructed mesh through test-time optimization.

b) Results.: Table II shows that ClothCode achieves the best performance across all garment categories, evaluation splits, and metrics, reducing MDE, EMD, and Chamfer distance by 26.6%, 36.8%, and 29.2% on average relative to Uniclothdiff [5], the strongest baseline. The gains remain substantial under Action-OOD, with corresponding reductions of 23.9%, 36.2%, and 29.2%. Notably, the relative improvement in EMD exceeds that in MDE for every garment under both splits, indicating stronger recovery of overall garment geometry. The improvement is particularly pronounced for the T-shirt under Action-OOD, where MDE, EMD, and Chamfer distance decrease by 40.0%, 45.1%, and 38.0%, respectively. Fig. 4 further shows that ClothCode better preserves global garment shape and folded structure under partial observation and self-occlusion.

Real-World Planning

Using a Baxter robot and a single ZED 2i camera, we evaluate all four combinations of ClothCode and Uniclothdiff [5] state estimation and dynamics prediction under the same MPC and execution settings. We test three garments per category on folding and flattening, with ten trials per instance, and define success as a final-mask IoU of at least 0.80 with the target. As shown in Table III, ClothCode state estimation and dynamics prediction achieves the highest success rate in all six garment–task settings, reaching 78.9% overall. Replacing the state estimator or dynamics model with Uniclothdiff reduces overall success to 68.9% and 67.2%, respectively, while replacing both reduces it to 56.7%. The mixed variants also reveal a category-dependent bottleneck: with ClothCode dynamics fixed, ClothCode state estimation improves fabric success from 73.3% to 85.0%, whereas with ClothCode state estimation fixed, ClothCode dynamics improves sweater success from 53.3% to 71.7%. Some qualitative results of real-world experiments are shown in Figure 5.

Qualitative results of real-world experiments

Figure 5. Qualitative results of real-world experiments.

Figure 3. Qualitative comparison of garment dynamic prediction. Per-vertex reconstruction errors with respect to the ground-truth mesh are visualized using a shared color scale across all methods.

Figure 4. Qualitative comparison of garment state estimation from camera observations. Per-vertex reconstruction errors with respect to the ground-truth mesh are visualized using a shared color scale across all methods.

Ablation

a) Effect of residual quantization.: Under the same patch-wise representation, continuous latents achieve 0.175 cm MDE, while single-level VQ increases the error to 0.367 cm. Two-level RVQ reduces MDE to 0.187 cm and P95 error from 1.503 cm to 0.787 cm, recovering most of the continuous representation fidelity.

b) Representation and prediction design.: We ablate patch-wise factorization, discretization, and iterative generation as shown in Table IV. The discrete one-shot baseline is trained independently for single-pass token prediction rather than obtained by truncating the masked model at inference. As shown in Table IV, discretization reduces state MDE from 2.673 to 1.996 cm under one-shot prediction while remaining competitive on dynamics (1.327 vs. 1.300 cm). Masked iterative prediction further reduces MDE to 0.674 cm for dynamics and 1.211 cm for state, improving over discrete one-shot by 48.2% and 39.3%, respectively. Compared with continuous iterative prediction, the discrete masked model further reduces MDE by 33.5% and 42.5%. These results show that discretization and masked refinement provide complementary gains.

RepresentationPredictionDynamics ↓\downarrowState ↓\downarrow
Continuous globalOne-shot regression1.685±0.0281.685 \pm0.0282.093±0.0712.093 \pm0.071
Continuous patch latentOne-shot regression1.327±0.0151.327 \pm0.0152.673±0.0702.673 \pm0.070
Continuous patch latentIterative diffusion1.014±0.0321.014 \pm0.0322.105±0.1702.105 \pm0.170
Discrete RVQTrained one-shot1.300±0.0191.300 \pm0.0191.996±0.0731.996 \pm0.073
Discrete RVQMasked iterative0.674±0.0230.674 \pm0.0231.211±0.0751.211 \pm0.075

Table 4. Ablation of representation and prediction design. MDE is reported in cm; lower is better.

Conclusion

We presented ClothCode, a unified generative framework for garment state estimation and action-conditioned dynamics prediction in a shared discrete configuration space. ClothCode represents complete garment geometry using material-aligned RVQ tokens and predicts these tokens with task-specific Masked Generative Transformers through parallel, confidence-guided refinement. Across three garment templates and both in-distribution and out-of-distribution evaluation, ClothCode reduces mean displacement error by 26.6% for state estimation and 37.0% for dynamics prediction relative to the strongest baselines, while dynamics inference requires only 16.7 ms per prediction window compared with 556.2 ms for diffusion. ClothCode increase real-world folding and flattening success from 56.7% to 78.9%. Future work will investigate transferable discrete garment representations across unseen garment topologies and their use in longer-horizon closed-loop manipulation.

References

  1. [1]A. Longhini, Y. Wang, I. Garcia-Camacho, D. Blanco-Mulero, M. Mo­letta, M. Welle, G. Alenyà, H. Yin, Z. Erickson, D. Held et al., “Unfolding the literature: A review of robotic cloth manipulation,” Annual Review of Control, Robotics, and Autonomous Systems, vol. 8, no. 1, pp. 295–322, 2025.arxiv.org/abs/2407.01361
  2. [2]C. Chi and S. Song, “Garments: Category-level pose estimation for garments via canonical space shape completion,” in 2021 IEEE/CVF International Conference on Computer Vision (ICCV). IEEE, 2021, pp. 3304–3313.arxiv.org/abs/2104.05177
  3. [3]Z. Huang, X. Lin, and D. Held, “Mesh-based dynamics with occlusion reasoning for cloth manipulation,” arXiv preprint arXiv:2206.02881, 2022.arxiv.org/abs/2206.02881
  4. [4]K. Zhang, B. Li, K. Hauser, and Y. Li, “Adaptagraph: Material-adaptive graph-based neural dynamics for robotic manipulation,” arXiv preprint arXiv:2407.07889, 2024.arxiv.org/abs/2407.07889
  5. [5]T. Tian, H. Li, B. Ai, X. Yuan, Z. Huang, and H. Su, “Diffusion dynamics models with generative state estimation for cloth manipulation,” arXiv preprint arXiv:2503.11999, 2025.arxiv.org/abs/2503.11999
  6. [6]A. Van Den Oord, O. Vinyals et al., “Neural discrete representation learning,” Advances in neural information processing systems, vol. 30, 2017.arxiv.org/abs/1711.00937
  7. [7]D. Lee, C. Kim, S. Kim, M. Cho, and W.-S. Han, “Autoregressive image generation using residual quantization,” in 2022 IEEE/CVF conference on computer vision and pattern recognition (CVPR). IEEE, 2022, pp. 11 513–11 522.arxiv.org/abs/2203.01941
  8. [8]H. Chang, H. Zhang, L. Jiang, C. Liu, and W. T. Freeman, “Maskgit: Masked generative image transformer,” in 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 2022, pp. 11 305–11 315.arxiv.org/abs/2202.04200
  9. [9]C. Guo, Y. Mu, M. G. Javed, S. Wang, and L. Cheng, “Momask: Generative masked modeling of 3d human motions,” in 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 2024, pp. 1900–1910.arxiv.org/abs/2312.00063
  10. [10]L. Zhuang, S. Fan, F. P. Audonnet, Y. Ru, E. S. Ho, G. Aragon-Camarasa, and P. Henderson, “Masked generative policy for robotic control,” in International Conference on Learning Representations, vol. 2026, 2026, pp. 118 833–118 864.arxiv.org/abs/2512.09101
  11. [11]T. Pfaff, M. Fortunato, A. Sanchez-Gonzalez, and P. W. Battaglia, “Learning mesh-based simulation with graph networks,” arXiv preprint arXiv:2010.03409, 2020.arxiv.org/abs/2010.03409
  12. [12]H. Shi, H. Xu, Z. Huang, Y. Li, and J. Wu, “Robocraft: Learning to see, simulate, and shape elasto-plastic objects in 3d with graph networks,” The International Journal of Robotics Research, vol. 43, no. 4, pp. 533–549, 2024.DOI
  13. [13]H. Jiang, H.-Y. Hsu, K. Zhang, H.-N. Yu, S. Wang, and Y. Li, “Phystwin: Physics-informed reconstruction and simulation of deformable objects from videos,” in 2025 IEEE/CVF International Conference on Computer Vision (ICCV). IEEE, 2025, pp. 7219–7230.arxiv.org/abs/2503.17973
  14. [14]X. Lin, Y. Wang, Z. Huang, and D. Held, “Learning visible connectivity dynamics for cloth smoothing,” in Conference on Robot Learning. PMLR, 2022, pp. 256–266.arxiv.org/abs/2105.10389
  15. [15]K. Zhang, B. Li, K. Hauser, and Y. Li, “Particle-grid neural dynamics for learning deformable object models from rgb-d videos,” arXiv preprint arXiv:2506.15680, 2025.arxiv.org/abs/2506.15680
  16. [16]Y. Zhang, Y. Shao, W. Ouyang, Y. Lan, Z. Liang, C. Wu, X. Xu, and X. Pan, “Clothtransformer: Unified latent-space transformers for scalable cloth simulation,” arXiv preprint arXiv:2605.27852, 2026.arxiv.org/abs/2605.27852
  17. [17]P. Esser, R. Rombach, and B. Ommer, “Taming transformers for high-resolution image synthesis,” in Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, 2021, pp. 12 873–12 883.arxiv.org/abs/2012.09841
  18. [18]H. Chang, H. Zhang, J. Barber, A. Maschinot, J. Lezama, L. Jiang, M.-H. Yang, K. Murphy, W. T. Freeman, M. Rubinstein et al., “Muse: Text-to-image generation via masked generative transformers,” arXiv preprint arXiv:2301.00704, 2023.arxiv.org/abs/2301.00704
  19. [19]L. Yu, Y. X. Cheng, K. Sohn, J. Lezama, H. Zhang, H. Chang, A. G. Hauptmann, M.-H. Yang, Y. Hao, I. Essa et al., “Magvit: Masked generative video transformer,” in 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 2023, pp. 10459–10469.arxiv.org/abs/2212.05199
  20. [20]G. Tzelepis, E. E. Aksoy, J. Borras, and G. Alenyà, “Semantic state estimation in cloth manipulation tasks,” arXiv preprint arXiv:2203.11647, 2022.arxiv.org/abs/2203.11647
  21. [21]C. R. Qi, H. Su, K. Mo, and L. J. Guibas, “Pointnet: Deep learning on point sets for 3d classification and segmentation,” in Proceedings of the IEEE conference on computer vision and pattern recognition, 2017, pp. 652–660.arxiv.org/abs/1612.00593
  22. [22]A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin, “Attention is all you need,” Advances in neural information processing systems, vol. 30, 2017.arxiv.org/abs/1706.03762
  23. [23]M. Tancik, P. Srinivasan, B. Mildenhall, S. Fridovich-Keil, N. Raghu­vans, U. Singhal, R. Ramamoorthi, J. Barron, and R. Ng, “Fourier features let networks learn high frequency functions in low dimen­sional domains,” Advances in neural information processing systems, vol. 33, pp. 7537–7547, 2020.arxiv.org/abs/2006.10739
  24. [24]W. Peebles and S. Xie, “Scalable diffusion models with transformers,” in 2023 IEEE/CVF International Conference on Computer Vision (ICCV). IEEE, 2023, pp. 4172–4182.arxiv.org/abs/2212.09748
  25. [25]M. Mittal, P. Roth, J. Tigue, A. Richard, O. Zhang, P. Du, A. Serrano-Munoz, X. Yao, R. Zubrigg, N. Rudin et al., “Isaac lab: A gpu-accelerated simulation framework for multi-modal robot learning,” arXiv preprint arXiv:2511.04831, 2025.arxiv.org/abs/2511.04831
  26. [26]C. E. Garcia, D. M. Prett, and M. Morari, “Model predictive control: Theory and practice—a survey,” Automatica, vol. 25, no. 3, pp. 335–348, 1989.DOI
  27. [27]M. Minderer, A. Gritsenko, and N. Houlsby, “Scaling open-vocabulary object detection,” Advances in Neural Information Processing Systems, vol. 36, pp. 72 983–73 007, 2023.arxiv.org/abs/2306.09683
  28. [28]N. Ravi, V. Gabeur, Y.-T. Hu, R. Hu, C. Ryali, T. Ma, H. Khedr, R. Rädle, C. Rolland, L. Gustafson et al., “Sam 2: Segment anything in images and videos,” in International Conference on Learning Representations, vol. 2025, 2025, pp. 28 085–28 128.arxiv.org/abs/2408.00714
  29. [29]P. J. Besl and N. D. McKay, “Method for registration of 3-d shapes,” in Sensor fusion IV: control paradigms and data structures, vol. 1611. Spie, 1992, pp. 586–606.DOI
  30. [30]P.-T. De Boer, D. P. Kroese, S. Mannor, and R. Y. Rubinstein, “A tutorial on the cross-entropy method,” Annals of operations research, vol. 134, no. 1, pp. 19–67, 2005.DOI

AI tools statement

No AI-use declaration is available for this version in Valency.

The available record does not establish whether AI systems or models contributed to this work.

How AI tools are recorded

Paper details

Cite this paper

Publication

Published
Version
Latest

Data & code

No code, data or supplementary files were declared for this version.

Pick where to look, or just type