Skip to content

Commit 8356a6a

Browse files
committed
fix broken links and docstring
1 parent f14fbd9 commit 8356a6a

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

docs/modules/sensors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ Cameras bundle a name to a set of properties to render images of the environment
2727

2828
Note that for memory efficiency the `image-state` is not returned by default (this can be toggled in `robosuite/utils/macros.py`).
2929

30-
Observables can also be used to model sensor corruption and delay, and refer the reader to the [Sensor Randomization](../sim2real/sensor_randomization.md) section for additional information.
30+
Observables can also be used to model sensor corruption and delay, and refer the reader to the [Sensor Randomization](../algorithms/sim2real.html#sensors) section for additional information.

robosuite/utils/observables.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ def sensor(modality):
1414
1515
An example use case is shown below:
1616
17-
@sensor(modality="proprio")
18-
def joint_pos(obs_cache):
19-
# Always handle case if obs_cache is empty
20-
if not obs_cache:
21-
return np.zeros(7)
22-
# Otherwise, run necessary calculations and return output
23-
...
24-
out = ...
25-
return out
17+
>>> @sensor(modality="proprio")
18+
>>> def joint_pos(obs_cache):
19+
# Always handle case if obs_cache is empty
20+
if not obs_cache:
21+
return np.zeros(7)
22+
# Otherwise, run necessary calculations and return output
23+
...
24+
out = ...
25+
return out
2626
2727
Args:
2828
modality (str): Modality for this sensor
29+
30+
Returns:
31+
function: decorator function
2932
"""
3033
# Define standard decorator (with no args)
3134
def decorator(func):
@@ -44,6 +47,9 @@ def create_deterministic_corrupter(corruption, low=-np.inf, high=np.inf):
4447
corruption (float): Corruption to apply
4548
low (float): Minimum value for output for clipping
4649
high (float): Maximum value for output for clipping
50+
51+
Returns:
52+
function: corrupter
4753
"""
4854
def corrupter(inp):
4955
inp = np.array(inp)
@@ -60,6 +66,9 @@ def create_uniform_noise_corrupter(min_noise, max_noise, low=-np.inf, high=np.in
6066
max_noise (float): Maximum noise to apply
6167
low (float): Minimum value for output for clipping
6268
high (float): Maxmimum value for output for clipping
69+
70+
Returns:
71+
function: corrupter
6372
"""
6473
def corrupter(inp):
6574
inp = np.array(inp)
@@ -77,6 +86,9 @@ def create_gaussian_noise_corrupter(mean, std, low=-np.inf, high=np.inf):
7786
std (float): Standard deviation of the noise to apply
7887
low (float): Minimum value for output for clipping
7988
high (float): Maxmimum value for output for clipping
89+
90+
Returns:
91+
function: corrupter
8092
"""
8193
def corrupter(inp):
8294
inp = np.array(inp)
@@ -91,6 +103,9 @@ def create_deterministic_delayer(delay):
91103
92104
Args:
93105
delay (float): Delay value to return
106+
107+
Returns:
108+
function: delayer
94109
"""
95110
assert delay >= 0, "Inputted delay must be non-negative!"
96111
return lambda: delay
@@ -103,6 +118,9 @@ def create_uniform_sampled_delayer(min_delay, max_delay):
103118
Args:
104119
min_delay (float): Minimum possible delay
105120
max_delay (float): Maxmimum possible delay
121+
122+
Returns:
123+
function: delayer
106124
"""
107125
assert min(min_delay, max_delay) >= 0, "Inputted delay must be non-negative!"
108126
return lambda: min_delay + (max_delay - min_delay) * np.random.random()
@@ -115,6 +133,9 @@ def create_gaussian_sampled_delayer(mean, std):
115133
Args:
116134
mean (float): Average delay
117135
std (float): Standard deviation of the delay variation
136+
137+
Returns:
138+
function: delayer
118139
"""
119140
assert mean >= 0, "Inputted mean delay must be non-negative!"
120141
return lambda: max(0.0, int(np.round(mean + std * np.random.randn())))
@@ -132,7 +153,7 @@ class Observable:
132153
133154
Args:
134155
name (str): Name for this observable
135-
sensor (function with sensor decorator): Method to grab raw sensor data for this observable. Should take in a
156+
sensor (function with `sensor` decorator): Method to grab raw sensor data for this observable. Should take in a
136157
single dict argument (observation cache if a pre-computed value is required) and return the raw sensor data
137158
for the current timestep. Must handle case if inputted argument is empty ({}), and should have `sensor`
138159
decorator when defined
@@ -247,7 +268,7 @@ def is_enabled(self):
247268
def is_active(self):
248269
"""
249270
Determines whether observable is active or not. This observable is considered active if its current observation
250-
value is being returned in self.obs.
271+
value is being returned in self.obs.
251272
252273
Returns:
253274
bool: True if this observable is active
@@ -269,7 +290,7 @@ def set_enabled(self, enabled):
269290
def set_active(self, active):
270291
"""
271292
Sets whether this observable is active or not. If active, this observable's current
272-
observed value is returned from self.obs, otherwise self.obs returns None.
293+
observed value is returned from self.obs, otherwise self.obs returns None.
273294
274295
Args:
275296
active (bool): True if this observable should be active

0 commit comments

Comments
 (0)