File size: 5,971 Bytes
825cff4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Action Configuration

This tutorial shows how to configure action spaces and normalization in robomimic, particularly useful for tasks with structured action spaces like robot manipulation.

<div class="admonition note">
<p class="admonition-title">Note: Understand how to launch training runs first!</p>

Before diving into action configuration, it might be useful to read the following tutorials:
- [how to launch training runs](./configs.html)
- [how to view training results](./viewing_results.html)

</div>

#### 1. Overview

Robomimic supports structured action spaces where different action components can be treated differently. This is particularly useful for:
- Robot manipulation tasks with different action components (e.g., end-effector position and rotation)
- Actions that require different normalization schemes
- Combining multiple action outputs with different physical meanings

#### 2. Action Configuration Structure

The action configuration consists of two main components:

1. `action_keys`: List of action components to use
2. `action_config`: Dictionary specifying how each action component should be processed

Here's the basic structure:

```python
config.train.action_keys = ["action/eef_pos", "action/eef_rot"]  # order matters!

config.train.action_config = {
    "action/eef_pos": {
        "normalization": "min_max",    # normalize to [-1, 1]
    },
    "action/eef_rot": {
        "normalization": None,                  # no normalization
        "format": "rot_6d",                     # rotation format in dataset / prediction
        "convert_at_runtime": "rot_axis_angle"  # convert rotation format at runtime
    }
}
```

#### 3. Supported Normalization Methods

Robomimic supports several normalization methods for action components:

1. `None`: No normalization
   - Uses unit scale and zero offset
   - Useful when actions are already in desired range

2. `"min_max"`: Min-max normalization
   - Scales actions to range [-1, 1]
   - Useful for bounded action components like positions
   - Handles numerical stability with small ranges
   ```python
   "normalization": "min_max"
   ```

3. `"gaussian"`: Gaussian normalization
   - Normalizes to zero mean and unit variance
   - Useful for unbounded action components
   ```python
   "normalization": "gaussian"
   ```

#### 4. Supported Rotation Conversions

Currently, robomimic supports converting 6D rotations (as proposed in [this paper](https://arxiv.org/abs/1812.07035)) to either axis-angle or Euler formats during rollouts. Below are example action configurations that convert the action key `action/eef_rot` from 6D to each format:

1. 6D to axis-angle
```python
config.train.action_config = {
    "action/eef_rot": {
        "normalization": None,                  # no normalization
        "format": "rot_6d",                     # 6D rotation format in dataset / prediction
        "convert_at_runtime": "rot_axis_angle"  # convert rotation format to axis-angle at runtime
    }
}
```

2. 6D to axis-angle
```python
config.train.action_config = {
    "action/eef_rot": {
        "normalization": None,                  # no normalization
        "format": "rot_6d",                     # 6D rotation format in dataset / prediction
        "convert_at_runtime": "rot_euler"       # convert rotation format to Euler at runtime
    }
}
```

If `"convert_at_runtime"` is not provided, 6D actions are converted to axis-angle format by default.

#### 5. Example Configurations

Here are some common use cases:

##### 5.1 Robot End-Effector Control

```python
# Configure end-effector position and rotation actions
config.train.action_keys = ["action/eef_pos", "action/eef_rot"]
config.train.action_config = {
    "action/eef_pos": {
        "normalization": "min_max",     # normalize position to [-1, 1]
    },
    "action/eef_rot": {
        "normalization": "gaussian",    # normalize rotation with zero mean, unit variance
    }
}
```

##### 5.2 Mixed Action Spaces

```python
# Configure position, rotation, and gripper actions
config.train.action_keys = ["action/eef_pos", "action/eef_rot", "action/gripper"]
config.train.action_config = {
    "action/eef_pos": {
        "normalization": "min_max",
    },
    "action/eef_rot": {
        "normalization": "gaussian",
    },
    "action/gripper": {
        "normalization": None,          # gripper already in [-1, 1]
    }
}
```

#### 6. Best Practices

1. **Action Component Order**:
   - Order in `action_keys` determines concatenation order
   - Keep order consistent across training and deployment
   - Document the expected order in your configs

2. **Normalization Selection**:
   - Use `min_max` for bounded values (e.g., positions, normalized vectors)
   - Use `gaussian` for unbounded values or when distribution matters
   - Use `None` when values are already properly scaled

3. **Numerical Stability**:
   - In `min_max` implementation, ranges smaller than 1e-4 are not scaled
   - In `gaussian` implementation, distributions with stddev smaller than 1e-6 are not scaled

4. **Diffusion Policy Compatibility**:
   - When using Diffusion Policy, ensure actions are normalized to [-1, 1]
   - Use `min_max` normalization or pre-normalize your data
   - The policy will check if actions are in the correct range

#### 7. Implementation Details

The normalization process:
1. Computes statistics (min, max, mean, std) across the entire dataset
2. Applies the specified normalization method to each action component
3. Concatenates the normalized components in the order specified by `action_keys`

For `min_max` normalization:
```python
# Normalizes to range [-0.999999, 0.999999] for numerical stability
scale = (input_max - input_min) / (output_max - output_min)
offset = input_min - scale * output_min
normalized_action = (raw_action - offset) / scale
```

For `gaussian` normalization:
```python
# Normalizes to zero mean, unit variance
normalized_action = (raw_action - mean) / (std + epsilon)
```