Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def astar_torus(grid, start_node, goal_node):
while parent_map[route[0][0]][route[0][1]] != ():
route.insert(0, parent_map[route[0][0]][route[0][1]])

print("The route found covers %d grid cells." % len(route))
print(f"The route found covers {len(route)} grid cells.")
for i in range(1, len(route)):
grid[route[i]] = 6
plt.cla()
Expand Down Expand Up @@ -212,7 +212,7 @@ def calc_heuristic_map(M, goal_node):
return heuristic_map


class NLinkArm(object):
class NLinkArm:
"""
Class for controlling and plotting a planar arm with an arbitrary number of links.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def astar_torus(grid, start_node, goal_node):
while parent_map[route[0][0]][route[0][1]] != ():
route.insert(0, parent_map[route[0][0]][route[0][1]])

print("The route found covers %d grid cells." % len(route))
print(f"The route found covers {len(route)} grid cells.")
for i in range(1, len(route)):
grid[route[i]] = 6
plt.cla()
Expand Down Expand Up @@ -243,7 +243,7 @@ def calc_heuristic_map(M, goal_node):
return heuristic_map


class NLinkArm(object):
class NLinkArm:
"""
Class for controlling and plotting a planar arm with an arbitrary number of links.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy as np


class DMP(object):
class DMP:

def __init__(self, training_data, data_period, K=156.25, B=25):
"""
Expand Down Expand Up @@ -215,21 +215,21 @@ def show_DMP_purpose(self):
T_vals = np.linspace(T_orig, 2*T_orig, 20)

for new_q0_value in q0_vals:
plot_title = "Initial Position = [%s, %s]" % \
(round(new_q0_value[0], 2), round(new_q0_value[1], 2))
plot_title = (f"Initial Position = [{round(new_q0_value[0], 2)},"
f" {round(new_q0_value[1], 2)}]")

_, path = self.recreate_trajectory(new_q0_value, g_orig, T_orig)
self.view_trajectory(path, title=plot_title, demo=True)

for new_g_value in g_vals:
plot_title = "Goal Position = [%s, %s]" % \
(round(new_g_value[0], 2), round(new_g_value[1], 2))
plot_title = (f"Goal Position = [{round(new_g_value[0], 2)},"
f" {round(new_g_value[1], 2)}]")

_, path = self.recreate_trajectory(q0_orig, new_g_value, T_orig)
self.view_trajectory(path, title=plot_title, demo=True)

for new_T_value in T_vals:
plot_title = "Period = %s [sec]" % round(new_T_value, 2)
plot_title = f"Period = {round(new_T_value, 2)} [sec]"

_, path = self.recreate_trajectory(q0_orig, g_orig, new_T_value)
self.view_trajectory(path, title=plot_title, demo=True)
Expand Down Expand Up @@ -257,5 +257,4 @@ def example_DMP():


if __name__ == '__main__':

example_DMP()
7 changes: 3 additions & 4 deletions PathPlanning/Eta3SplineTrajectory/eta3_spline_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

class MaxVelocityNotReached(Exception):
def __init__(self, actual_vel, max_vel):
self.message = 'Actual velocity {} does not equal desired max velocity {}!'.format(
actual_vel, max_vel)
self.message = f'Actual velocity {actual_vel} does not equal desired max velocity {max_vel}!'


class eta3_trajectory(Eta3Path):
Expand All @@ -42,7 +41,7 @@
# ensure that all inputs obey the assumptions of the model
assert max_vel > 0 and v0 >= 0 and a0 >= 0 and max_accel > 0 and max_jerk > 0 \
and a0 <= max_accel and v0 <= max_vel
super(eta3_trajectory, self).__init__(segments=segments)
super(__class__, self).__init__(segments=segments)
self.total_length = sum([s.segment_length for s in self.segments])
self.max_vel = float(max_vel)
self.v0 = float(v0)
Expand Down Expand Up @@ -166,7 +165,7 @@
try:
assert np.isclose(self.vels[index], 0)
except AssertionError as e:
print('The final velocity {} is not zero'.format(self.vels[index]))
print(f'The final velocity {self.vels[index]} is not zero')
raise e

self.seg_lengths[index] = s_sf
Expand Down
12 changes: 6 additions & 6 deletions PathPlanning/RRT/sobol/sobol.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ def i4_sobol(dim_num, seed):
if (dim_num < 1 or dim_max < dim_num):
print('I4_SOBOL - Fatal error!')
print(' The spatial dimension DIM_NUM should satisfy:')
print(' 1 <= DIM_NUM <= %d' % dim_max)
print(' But this input value is DIM_NUM = %d' % dim_num)
print(f' 1 <= DIM_NUM <= {dim_max:d}')
print(f' But this input value is DIM_NUM = {dim_num:d}')
return None

dim_num_save = dim_num
Expand Down Expand Up @@ -443,7 +443,7 @@ def i4_sobol(dim_num, seed):
#
l_var = i4_bit_lo0(seed)

elif (seed <= seed_save):
elif seed <= seed_save:

seed_save = 0
lastq = np.zeros(dim_num)
Expand Down Expand Up @@ -471,8 +471,8 @@ def i4_sobol(dim_num, seed):
if maxcol < l_var:
print('I4_SOBOL - Fatal error!')
print(' Too many calls!')
print(' MAXCOL = %d\n' % maxcol)
print(' L = %d\n' % l_var)
print(f' MAXCOL = {maxcol:d}\n')
print(f' L = {l_var:d}\n')
return None


Expand Down Expand Up @@ -819,7 +819,7 @@ def r8mat_write(filename, m, n, a):
with open(filename, 'w') as output:
for i in range(0, m):
for j in range(0, n):
s = ' %g' % (a[i, j])
s = f' {a[i, j]:g}'
output.write(s)
output.write('\n')

Expand Down
Loading