Skip to content

Commit

Permalink
update examples with ir-sim v2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hanruihua committed Sep 1, 2024
1 parent 774bd72 commit b698d0b
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion RDA_planner/mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ def motion_predict_model_omni(self, robot_state, vel, sample_time):
vx = vel[0, 0] * cos(vel[1, 0])
vy = vel[0, 0] * sin(vel[1, 0])
omni_vel = np.array([[vx], [vy], [0]])
# omni_vel = np.array([[vx], [vy]])

next_state = robot_state + sample_time * omni_vel

# ds = np.row_stack((vel, [0]))
# next_state = robot_state + sample_time * ds

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pip install -e .
**Dynamic obstacles avoidance (example/dynamic_obs.py)** | <img src="example\dynamic_obs\animation\dynamic_obs1.gif" width="300" /> | <img src="example\dynamic_obs\animation\dynamic_obs2.gif" width="300" />
|:-------------------------:|:-------------------------:|:-------------------------:|

**Note:** You can customize the scenario by modifying the parameters in the corresponding yaml file as introduced in [ir_sim](https://github.com/hanruihua/ir_sim). For the polygon obstacles, please make sure the obstacles are convex (CCW order is not necessary now).
**Note:** You can customize the scenario by modifying the parameters in the corresponding yaml file as introduced in [ir-sim](https://github.com/hanruihua/ir-sim). For the polygon obstacles, please make sure the obstacles are convex (CCW order is not necessary now).


## Citation
Expand Down
2 changes: 1 addition & 1 deletion example/corridor/corridor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import numpy as np
from RDA_planner.mpc import MPC
from collections import namedtuple
Expand Down
2 changes: 1 addition & 1 deletion example/corridor/corridor_diff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import numpy as np
from RDA_planner.mpc import MPC
from collections import namedtuple
Expand Down
2 changes: 1 addition & 1 deletion example/corridor/corridor_omni.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import numpy as np
from RDA_planner.mpc import MPC
from collections import namedtuple
Expand Down
1 change: 1 addition & 0 deletions example/corridor/corridor_omni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ world:

robot:
- kinematics: {name: 'omni'}
state_dim: 3
shape: {name: 'rectangle', length: 3.0, width: 1.6, wheelbase: 0}
state: [0, 20, 0]
goal: [60, 20, 0]
Expand Down
4 changes: 2 additions & 2 deletions example/dynamic_obs/dynamic_obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
from collections import namedtuple
import numpy as np
from ir_sim.env import EnvBase
from irsim.env import EnvBase
from RDA_planner.mpc import MPC

# environment
Expand All @@ -27,7 +27,7 @@ def main():
opt_vel, info = mpc_opt.control(env.robot.state, 6, obs_list)
env.draw_trajectory(info['opt_state_list'], 'r', refresh=True)

env.step(opt_vel, stop=False)
env.step(opt_vel)
env.render(show_traj=True)

if env.done():
Expand Down
4 changes: 2 additions & 2 deletions example/dynamic_obs/dynamic_obs_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
from collections import namedtuple
import numpy as np
from ir_sim.env import EnvBase
from irsim.env import EnvBase
from RDA_planner.mpc import MPC

# environment
Expand All @@ -27,7 +27,7 @@ def main():
opt_vel, info = mpc_opt.control(env.robot.state, 6, obs_list)
env.draw_trajectory(info['opt_state_list'], 'r', refresh=True)

env.step(opt_vel, stop=False)
env.step(opt_vel)
env.render(show_traj=True)

if env.done():
Expand Down
2 changes: 1 addition & 1 deletion example/dynamic_obs/dynamic_obs_omni.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
from collections import namedtuple
import numpy as np
from ir_sim.env import EnvBase
from irsim.env import EnvBase
from RDA_planner.mpc import MPC
from math import cos, sin

Expand Down
1 change: 1 addition & 0 deletions example/dynamic_obs/dynamic_obs_omni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ world:

robot:
- kinematics: {name: 'omni'}
state_dim: 3
shape: {name: 'rectangle', length: 3.0, width: 1.6, wheelbase: 0}
state: [10, 40, 1.57]
goal: [40, 40, 0]
Expand Down
4 changes: 2 additions & 2 deletions example/lidar_nav/lidar_path_track.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import sys
import numpy as np
from RDA_planner.mpc import MPC
Expand Down Expand Up @@ -82,7 +82,7 @@ def main():
opt_vel, info = mpc_opt.control(env.robot.state, 4, obs_list)
env.draw_trajectory(info['opt_state_list'], 'r', refresh=True)

env.step(opt_vel, stop=False)
env.step(opt_vel)
env.render(show_traj=True, show_trail=True)

if env.done():
Expand Down
2 changes: 1 addition & 1 deletion example/lidar_nav/lidar_path_track_diff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import sys
import numpy as np
from RDA_planner.mpc import MPC
Expand Down
2 changes: 1 addition & 1 deletion example/lidar_nav/lidar_path_track_omni.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import sys
import numpy as np
from RDA_planner.mpc import MPC
Expand Down
1 change: 1 addition & 0 deletions example/lidar_nav/lidar_path_track_omni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ world:

robot:
- kinematics: {name: 'omni'}
state_dim: 3
shape: {name: 'rectangle', length: 3.0, width: 1.6, wheelbase: 0}
state: [10, 40, 1.57]
goal: [40, 40, 0]
Expand Down
2 changes: 1 addition & 1 deletion example/path_track/path_track.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import sys
import numpy as np
from RDA_planner.mpc import MPC
Expand Down
4 changes: 2 additions & 2 deletions example/path_track/path_track_diff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import sys
import numpy as np
from RDA_planner.mpc import MPC
Expand Down Expand Up @@ -30,7 +30,7 @@ def main():

env.draw_trajectory(info['opt_state_list'], 'r', refresh=True)

env.step(opt_vel, stop=False)
env.step(opt_vel)
env.render(show_traj=True, show_trail=True)

if env.done():
Expand Down
4 changes: 2 additions & 2 deletions example/path_track/path_track_omni.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import sys
import numpy as np
from RDA_planner.mpc import MPC
Expand Down Expand Up @@ -36,7 +36,7 @@ def main():
vy = opt_vel[0, 0] * sin(opt_vel[1, 0])
omni_vel = np.array([[vx], [vy]])

env.step(omni_vel, stop=False)
env.step(omni_vel)
# env.step(opt_vel, stop=False)

env.render(show_traj=True, show_trail=True)
Expand Down
3 changes: 2 additions & 1 deletion example/path_track/path_track_omni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ world:
control_mode: 'auto' # 'keyboard', 'auto'

robot:
- kinematics: {name: 'omni'}
- kinematics: {name: 'omni'}
state_dim: 3
shape: {name: 'rectangle', length: 3.0, width: 1.6, wheelbase: 0}
state: [10, 42, 0]
goal: [40, 40, 0]
Expand Down
4 changes: 2 additions & 2 deletions example/reverse/reverse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import numpy as np
from RDA_planner.mpc import MPC
from collections import namedtuple
Expand Down Expand Up @@ -37,7 +37,7 @@

env.draw_trajectory(info['opt_state_list'], 'r', refresh=True)

env.step(opt_vel, stop=False)
env.step(opt_vel)
env.render(0.01, show_traj=True, show_trail=True)
# env.render(0.1, show_traj=True)

Expand Down
4 changes: 2 additions & 2 deletions example/reverse/reverse_diff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ir_sim.env import EnvBase
from irsim.env import EnvBase
import numpy as np
from RDA_planner.mpc import MPC
from collections import namedtuple
Expand Down Expand Up @@ -37,7 +37,7 @@

env.draw_trajectory(info['opt_state_list'], 'r', refresh=True)

env.step(opt_vel, stop=False)
env.step(opt_vel)
env.render(0.01, show_traj=True, show_trail=True)
# env.render(0.1, show_traj=True)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'cvxpy==1.5.2',
'numpy',
'pathos',
'ir_sim==2.1.2',
'ir-sim==2.2.3',
'matplotlib',
'gctl==1.1',
'opencv-python',
Expand Down

0 comments on commit b698d0b

Please sign in to comment.