Skip to content

Commit 741f502

Browse files
committed
update documentation
1 parent 52bf738 commit 741f502

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

robot_nav/models/CNNTD3/CNNTD3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def forward(self, s):
5555
The last 5 elements are [distance, cos, sin, lin_vel, ang_vel].
5656
5757
Returns:
58-
torch.Tensor: Action tensor of shape (batch_size, action_dim),
58+
(torch.Tensor): Action tensor of shape (batch_size, action_dim),
5959
with values in range [-1, 1] due to tanh activation.
6060
"""
6161
if len(s.shape) == 1:
@@ -138,7 +138,7 @@ def forward(self, s, action):
138138
action (torch.Tensor): Current action tensor of shape (batch_size, action_dim).
139139
140140
Returns:
141-
tuple:
141+
(tuple):
142142
- q1 (torch.Tensor): First Q-value estimate (batch_size, 1).
143143
- q2 (torch.Tensor): Second Q-value estimate (batch_size, 1).
144144
"""

robot_nav/replay_buffer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def size(self):
5050
Get the number of elements currently in the buffer.
5151
5252
Returns:
53-
int: Current buffer size.
53+
(int): Current buffer size.
5454
"""
5555
return self.count
5656

@@ -62,7 +62,7 @@ def sample_batch(self, batch_size):
6262
batch_size (int): Number of experiences to sample.
6363
6464
Returns:
65-
Tuple of np.ndarrays: Batches of states, actions, rewards, done flags, and next states.
65+
(Tuple of np.ndarrays): Batches of states, actions, rewards, done flags, and next states.
6666
"""
6767
if self.count < batch_size:
6868
batch = random.sample(self.buffer, self.count)
@@ -82,7 +82,7 @@ def return_buffer(self):
8282
Return the entire buffer contents as separate arrays.
8383
8484
Returns:
85-
Tuple of np.ndarrays: Full arrays of states, actions, rewards, done flags, and next states.
85+
(Tuple of np.ndarrays): Full arrays of states, actions, rewards, done flags, and next states.
8686
"""
8787
s = np.array([_[0] for _ in self.buffer])
8888
a = np.array([_[1] for _ in self.buffer])
@@ -149,7 +149,7 @@ def size(self):
149149
Get the number of complete episodes in the buffer.
150150
151151
Returns:
152-
int: Number of episodes.
152+
(int): Number of episodes.
153153
"""
154154
return self.count
155155

@@ -163,7 +163,7 @@ def sample_batch(self, batch_size):
163163
batch_size (int): Number of sequences to sample.
164164
165165
Returns:
166-
Tuple of np.ndarrays: Sequences of past states, actions, rewards, done flags, and next states.
166+
(Tuple of np.ndarrays): Sequences of past states, actions, rewards, done flags, and next states.
167167
"""
168168
if self.count < batch_size:
169169
batch = random.sample(

robot_nav/sim.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def step(self, lin_velocity=0.0, ang_velocity=0.1):
3939
ang_velocity (float): Angular velocity to apply to the robot.
4040
4141
Returns:
42-
tuple: Contains the latest LIDAR scan, distance to goal, cosine and sine of angle to goal,
42+
(tuple): Contains the latest LIDAR scan, distance to goal, cosine and sine of angle to goal,
4343
collision flag, goal reached flag, applied action, and computed reward.
4444
"""
4545
self.env.step(action_id=0, action=np.array([[lin_velocity], [ang_velocity]]))
@@ -80,7 +80,7 @@ def reset(
8080
random_obstacle_ids (list or None): Specific obstacle IDs to randomize.
8181
8282
Returns:
83-
tuple: Initial observation after reset, including LIDAR scan, distance, cos/sin,
83+
(tuple): Initial observation after reset, including LIDAR scan, distance, cos/sin,
8484
and reward-related flags and values.
8585
"""
8686
if robot_state is None:
@@ -128,7 +128,7 @@ def cossin(vec1, vec2):
128128
vec2 (list): Second 2D vector.
129129
130130
Returns:
131-
tuple: (cosine, sine) of the angle between the vectors.
131+
(tuple): (cosine, sine) of the angle between the vectors.
132132
"""
133133
vec1 = vec1 / np.linalg.norm(vec1)
134134
vec2 = vec2 / np.linalg.norm(vec2)
@@ -148,7 +148,7 @@ def get_reward(goal, collision, action, laser_scan):
148148
laser_scan (list): The LIDAR scan readings.
149149
150150
Returns:
151-
float: Computed reward for the current state.
151+
(float): Computed reward for the current state.
152152
"""
153153
if goal:
154154
return 100.0

robot_nav/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def load_buffer(self):
3636
Load samples from the specified files and populate the replay buffer.
3737
3838
Returns:
39-
object: The populated replay buffer.
39+
(object): The populated replay buffer.
4040
"""
4141
for file_name in self.file_names:
4242
print("Loading file: ", file_name)
@@ -141,7 +141,7 @@ def get_buffer(
141141
history_len (int, optional): Used for RCPG buffer configuration. Defaults to 10.
142142
143143
Returns:
144-
object: The initialized and optionally pre-populated replay buffer.
144+
(object): The initialized and optionally pre-populated replay buffer.
145145
"""
146146
if isinstance(model, PPO):
147147
return model.buffer
@@ -210,7 +210,7 @@ def get_max_bound(
210210
device (torch.device): PyTorch device for computation.
211211
212212
Returns:
213-
torch.Tensor: Maximum return bound for each sample in the batch.
213+
(torch.Tensor): Maximum return bound for each sample in the batch.
214214
"""
215215
next_state = next_state.clone() # Prevents in-place modifications
216216
reward = reward.clone() # Ensures original reward is unchanged

0 commit comments

Comments
 (0)