Skip to content

Commit 51cdbdb

Browse files
committed
1.1.11
1 parent 38a5b72 commit 51cdbdb

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

ir_sim/util/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
from math import sqrt, inf, pi, sin, cos
3+
import os
34

45
def random_points(number, low, high, point_distance, max_iter=500):
56
# random distribute some points into a selected area with a minimum distance
@@ -78,6 +79,16 @@ def get_transform(state):
7879

7980
return trans, rot
8081

82+
def repeat_mk_dirs(path, max_num):
8183

84+
if os.path.exists(path):
85+
i = 0
86+
while i < max_num:
87+
new_path = path + '_' + str(i)
88+
if not os.path.exists(new_path):
89+
path = new_path
90+
break
91+
92+
os.makedirs(path)
8293

8394

ir_sim/world/robots/robot_acker.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RobotAcker(RobotBase):
1818
goal_dim = (3, 1) # the goal dimension, x,y, phi
1919
position_dim=(2,1) # the position dimension, x, y
2020

21-
def __init__(self, id=0, state=np.zeros((4, 1)), vel=np.zeros((2, 1)), goal=np.zeros((3, 1)), shape=[4.6, 1.6, 3, 1.6], psi_limit = pi/4, step_time=0.1, arrive_mode='state', vel_min=[-4, -pi/4], vel_max=[4, pi/4], acce=[inf, inf], vel_type='steer', car_model='car_green.png', **kwargs):
21+
def __init__(self, id=0, state=np.zeros((4, 1)), vel=np.zeros((2, 1)), goal=np.zeros((3, 1)), shape=[4.6, 1.6, 3, 1.6], psi_limit = pi/4, step_time=0.1, arrive_mode='state', vel_min=[-4, -pi/4], vel_max=[4, pi/4], acce=[inf, inf], vel_type='steer', car_model='car_green.png', edgecolor='y', **kwargs):
2222

2323
self.init_vertex = RobotAcker.cal_vertex(shape)
2424
# super(RobotAcker, self).state_dim = RobotAcker.state_dim
@@ -35,6 +35,8 @@ def __init__(self, id=0, state=np.zeros((4, 1)), vel=np.zeros((2, 1)), goal=np.z
3535
self.car_model = car_model
3636
self.update_vertex(self.state)
3737

38+
self.edgecolor = edgecolor
39+
3840
def dynamics(self, state, vel, **kwargs):
3941
# The ackermann robot dynamics
4042
# l: wheel base
@@ -170,7 +172,7 @@ def gen_inequal_global(self):
170172

171173
return G, h
172174

173-
def plot_robot(self, ax, show_goal=True, goal_color='c', goal_l=2, show_text=False, show_traj=False, traj_type='-g', show_trail=False, edgecolor='y', trail_type='rectangle', **kwargs):
175+
def plot_robot(self, ax, show_goal=True, goal_color='c', goal_l=2, show_text=False, show_traj=False, traj_type='-g', show_trail=False, trail_type='rectangle', **kwargs):
174176
# cur_vertex =
175177
start_x = self.vertex[0, 0]
176178
start_y = self.vertex[1, 0]
@@ -193,7 +195,7 @@ def plot_robot(self, ax, show_goal=True, goal_color='c', goal_l=2, show_text=Fal
193195

194196
if show_trail:
195197
if trail_type == 'rectangle':
196-
car_rect = mpl.patches.Rectangle(xy=(start_x, start_y), width=self.shape[0], height=self.shape[1], angle=r_phi_ang, edgecolor=edgecolor, fill=False, alpha=0.8, linewidth=0.8)
198+
car_rect = mpl.patches.Rectangle(xy=(start_x, start_y), width=self.shape[0], height=self.shape[1], angle=r_phi_ang, edgecolor=self.edgecolor, fill=False, alpha=0.8, linewidth=0.8)
197199
ax.add_patch(car_rect)
198200

199201
elif trail_type == 'circle':
@@ -214,6 +216,8 @@ def plot_robot(self, ax, show_goal=True, goal_color='c', goal_l=2, show_text=Fal
214216
y_list = [t[1, 0] for t in self.trajectory]
215217
self.plot_line_list.append(ax.plot(x_list, y_list, traj_type))
216218

219+
def set_edgecolor(self, edgecolor='y'):
220+
self.edgecolor = edgecolor
217221

218222
def reset(self):
219223
self.state = self.init_state.copy()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "ir_sim"
9-
version = "1.1.10"
9+
version = "1.1.11"
1010
authors = [
1111
{ name="Han Ruihua", email="hanrh@connect.hku.hk" },
1212
]

0 commit comments

Comments
 (0)