From b698d0b95f76924a34b3cda6019b753d0cbb00e1 Mon Sep 17 00:00:00 2001 From: Han Date: Sun, 1 Sep 2024 19:33:18 +0800 Subject: [PATCH] update examples with ir-sim v2.2.3 --- RDA_planner/mpc.py | 2 +- README.md | 2 +- example/corridor/corridor.py | 2 +- example/corridor/corridor_diff.py | 2 +- example/corridor/corridor_omni.py | 2 +- example/corridor/corridor_omni.yaml | 1 + example/dynamic_obs/dynamic_obs.py | 4 ++-- example/dynamic_obs/dynamic_obs_diff.py | 4 ++-- example/dynamic_obs/dynamic_obs_omni.py | 2 +- example/dynamic_obs/dynamic_obs_omni.yaml | 1 + example/lidar_nav/lidar_path_track.py | 4 ++-- example/lidar_nav/lidar_path_track_diff.py | 2 +- example/lidar_nav/lidar_path_track_omni.py | 2 +- example/lidar_nav/lidar_path_track_omni.yaml | 1 + example/path_track/path_track.py | 2 +- example/path_track/path_track_diff.py | 4 ++-- example/path_track/path_track_omni.py | 4 ++-- example/path_track/path_track_omni.yaml | 3 ++- example/reverse/reverse.py | 4 ++-- example/reverse/reverse_diff.py | 4 ++-- setup.py | 2 +- 21 files changed, 29 insertions(+), 25 deletions(-) diff --git a/RDA_planner/mpc.py b/RDA_planner/mpc.py index e84d2e8..fdb7de6 100644 --- a/RDA_planner/mpc.py +++ b/RDA_planner/mpc.py @@ -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 diff --git a/README.md b/README.md index c642cbf..abb227d 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ pip install -e . **Dynamic obstacles avoidance (example/dynamic_obs.py)** | | |:-------------------------:|:-------------------------:|:-------------------------:| -**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 diff --git a/example/corridor/corridor.py b/example/corridor/corridor.py index 11582a5..2338f27 100644 --- a/example/corridor/corridor.py +++ b/example/corridor/corridor.py @@ -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 diff --git a/example/corridor/corridor_diff.py b/example/corridor/corridor_diff.py index f7101f2..3a5320e 100644 --- a/example/corridor/corridor_diff.py +++ b/example/corridor/corridor_diff.py @@ -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 diff --git a/example/corridor/corridor_omni.py b/example/corridor/corridor_omni.py index 64667d1..ca0cc05 100644 --- a/example/corridor/corridor_omni.py +++ b/example/corridor/corridor_omni.py @@ -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 diff --git a/example/corridor/corridor_omni.yaml b/example/corridor/corridor_omni.yaml index 73782f6..0bd9ad8 100644 --- a/example/corridor/corridor_omni.yaml +++ b/example/corridor/corridor_omni.yaml @@ -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] diff --git a/example/dynamic_obs/dynamic_obs.py b/example/dynamic_obs/dynamic_obs.py index 847093f..40b84f3 100644 --- a/example/dynamic_obs/dynamic_obs.py +++ b/example/dynamic_obs/dynamic_obs.py @@ -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 @@ -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(): diff --git a/example/dynamic_obs/dynamic_obs_diff.py b/example/dynamic_obs/dynamic_obs_diff.py index b08c090..2ff7dbe 100644 --- a/example/dynamic_obs/dynamic_obs_diff.py +++ b/example/dynamic_obs/dynamic_obs_diff.py @@ -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 @@ -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(): diff --git a/example/dynamic_obs/dynamic_obs_omni.py b/example/dynamic_obs/dynamic_obs_omni.py index ae0706c..e455acc 100644 --- a/example/dynamic_obs/dynamic_obs_omni.py +++ b/example/dynamic_obs/dynamic_obs_omni.py @@ -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 diff --git a/example/dynamic_obs/dynamic_obs_omni.yaml b/example/dynamic_obs/dynamic_obs_omni.yaml index efb6aed..47c7819 100644 --- a/example/dynamic_obs/dynamic_obs_omni.yaml +++ b/example/dynamic_obs/dynamic_obs_omni.yaml @@ -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] diff --git a/example/lidar_nav/lidar_path_track.py b/example/lidar_nav/lidar_path_track.py index dd86968..b717329 100644 --- a/example/lidar_nav/lidar_path_track.py +++ b/example/lidar_nav/lidar_path_track.py @@ -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 @@ -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(): diff --git a/example/lidar_nav/lidar_path_track_diff.py b/example/lidar_nav/lidar_path_track_diff.py index 4bab13a..a565087 100644 --- a/example/lidar_nav/lidar_path_track_diff.py +++ b/example/lidar_nav/lidar_path_track_diff.py @@ -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 diff --git a/example/lidar_nav/lidar_path_track_omni.py b/example/lidar_nav/lidar_path_track_omni.py index 90b0474..b06d401 100644 --- a/example/lidar_nav/lidar_path_track_omni.py +++ b/example/lidar_nav/lidar_path_track_omni.py @@ -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 diff --git a/example/lidar_nav/lidar_path_track_omni.yaml b/example/lidar_nav/lidar_path_track_omni.yaml index 0c8acd3..a7c0887 100644 --- a/example/lidar_nav/lidar_path_track_omni.yaml +++ b/example/lidar_nav/lidar_path_track_omni.yaml @@ -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] diff --git a/example/path_track/path_track.py b/example/path_track/path_track.py index 7b827af..5d328b9 100644 --- a/example/path_track/path_track.py +++ b/example/path_track/path_track.py @@ -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 diff --git a/example/path_track/path_track_diff.py b/example/path_track/path_track_diff.py index f982b80..6ced376 100644 --- a/example/path_track/path_track_diff.py +++ b/example/path_track/path_track_diff.py @@ -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 @@ -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(): diff --git a/example/path_track/path_track_omni.py b/example/path_track/path_track_omni.py index cfccc6d..526e909 100644 --- a/example/path_track/path_track_omni.py +++ b/example/path_track/path_track_omni.py @@ -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 @@ -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) diff --git a/example/path_track/path_track_omni.yaml b/example/path_track/path_track_omni.yaml index 380b095..8dc367b 100644 --- a/example/path_track/path_track_omni.yaml +++ b/example/path_track/path_track_omni.yaml @@ -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] diff --git a/example/reverse/reverse.py b/example/reverse/reverse.py index 70133e3..4e9285c 100644 --- a/example/reverse/reverse.py +++ b/example/reverse/reverse.py @@ -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 @@ -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) diff --git a/example/reverse/reverse_diff.py b/example/reverse/reverse_diff.py index 3d9e586..85f680e 100644 --- a/example/reverse/reverse_diff.py +++ b/example/reverse/reverse_diff.py @@ -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 @@ -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) diff --git a/setup.py b/setup.py index a92406a..39523ce 100644 --- a/setup.py +++ b/setup.py @@ -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',