Skip to content

Commit

Permalink
sample data
Browse files Browse the repository at this point in the history
  • Loading branch information
hyzhou404 committed Dec 25, 2024
1 parent 457a377 commit eca43ae
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 35 deletions.
43 changes: 39 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
<br>

<p align="left">
This is the official project repository of the paper <b>HUGSIM: A Real-Time, Photo-Realistic and Closed-Loop Simulator for Autonomous Driving</b>
This is the official project repository of the paper <b>HUGSIM: A Real-Time, Photo-Realistic and Closed-Loop Simulator for Autonomous Driving</b>.
</p>

</div>

---

# TODO list
- [ ] Release sample data and results
- [x] Release sample data and results
- [ ] Release unicycle model part
- [ ] Release GUI
- [ ] Release more scenarios
Expand Down Expand Up @@ -67,7 +67,7 @@ Install remaining dependencies by:
pip install -r requirements.txt
```

To run the closed-loop simulation, the hug_sim gymnasium environment should be installed:
To run the closed-loop simulation, the hug_sim Gymnasium environment should be installed:
``` bash
cd ./sim
pip install -e .
Expand All @@ -77,7 +77,7 @@ pip install -e .

Please refer to [Data Preparation Document](data/README.md)

We will provide sample sequence data and reconstructed results. The download link will be provided later.
You can download sample data from [here](https://huggingface.co/datasets/hyzhou404/HUGSIM/resolve/main/sample_data.zip), which includes a sample sequence, results of the sequence reconstruction, and results of 3dRealCar vehicles reconstruction.

# Reconstruction

Expand All @@ -98,6 +98,23 @@ python -u train.py --data_cfg ./configs/${dataset_name}.yaml \

**Before simulation, [UniAD_SIM](https://github.com/hyzhou404/UniAD_SIM), [VAD_SIM](https://github.com/hyzhou404/VAD_SIM) and [NAVSIM](https://github.com/hyzhou404/NAVSIM) client should be installed.**

In **closed_loop.py**, we automatically launch autonomous driving algorithms. In practice, you may encounter errors due to an incorrect environment, path, and etc. For debugging purposes, you can modify the last part of code as:
```python
# process = launch(ad_path, args.ad_cuda, output)
# try:
# create_gym_env(cfg, output)
# check_alive(process)
# except Exception as e:
# print(e)
# process.kill()

# For debug
create_gym_env(cfg, output)
```

Paths in **configs/sim/\*\_base.yaml** should be updated as paths on your machine.


``` bash
CUDA_VISIBLE_DEVICES=${sim_cuda} \
python closed_loop.py --scenario_path ${scenario_cfg_path} \
Expand All @@ -108,6 +125,24 @@ python closed_loop.py --scenario_path ${scenario_cfg_path} \
--ad_cuda ${ad_cuda}
```

Run the following commands to execute the provided examples.

```bash
sim_cuda=0
ad_cuda=1
scenario_dir=./configs/benchmark/nuscenes
for cfg in ${scenario_dir}/*.yaml; do
echo ${cfg}
CUDA_VISIBLE_DEVICES=${sim_cuda} \
python closed_loop.py --scenario_path ${cfg} \
--base_path ./configs/sim/nuscenes_base.yaml \
--camera_path ./configs/sim/nuscenes_camera.yaml \
--kinematic_path ./configs/sim/kinematic.yaml \
--ad uniad \
--ad_cuda ${ad_cuda}
done
```


# Citation

Expand Down
1 change: 1 addition & 0 deletions closed_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def create_gym_env(cfg, output):
ad_path = cfg.base.ltf_path
else:
raise NotImplementedError

process = launch(ad_path, args.ad_cuda, output)
try:
create_gym_env(cfg, output)
Expand Down
14 changes: 8 additions & 6 deletions configs/benchmark/nuscenes/scene-0383-extreme-00.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
mode: extreme_00
plan_list:
- - 0.0
- -20.0
- -15.0
- -0.3
- 0
- 3.0
- "2024_06_04_15_45_41"
- "2024_07_02_14_20_29"
- AttackPlanner
- pred_steps: 20
ATTACK_FREQ: 10
best_k: 10
- - 2.0
- 20.0
- 10.0
- -0.3
- 0
- 0
- "2024_07_02_14_14_52"
- ConstantPlanner
- {}
- "2024_07_05_11_02_48"
- AttackPlanner
- pred_steps: 20
ATTACK_FREQ: 3
best_k: 2
load_HD_map: false
start_euler:
- 0.0
Expand Down
4 changes: 2 additions & 2 deletions configs/benchmark/nuscenes/scene-0383-medium-00.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mode: medium_00
plan_list:
- - 2.0
- - 0.0
- 15.0
- -0.3
- 0
- 0
- "2024_07_09_14_25_36"
- "2024_07_05_15_57_10"
- ConstantPlanner
- {}
load_HD_map: false
Expand Down
14 changes: 0 additions & 14 deletions configs/benchmark/nuscenes/scene-0655-easy-00.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions data/waymo/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
cuda=4
export CUDA_VISIBLE_DEVICES=$cuda

# base_dir="/nas/datasets/Waymo_NOTR/static"
# segment="segment-16608525782988721413_100_000_120_000_with_camera_labels.tfrecord"
base_dir="/nas/datasets/Waymo_NOTR/static"
segment="segment-10061305430875486848_1080_000_1100_000_with_camera_labels.tfrecord"

base_dir="/nas/datasets/Waymo_NOTR/dynamic"
segment="segment-16801666784196221098_2480_000_2500_000_with_camera_labels.tfrecord"
# base_dir="/nas/datasets/Waymo_NOTR/dynamic"
# segment="segment-16801666784196221098_2480_000_2500_000_with_camera_labels.tfrecord"

seg_prefix=$(echo $segment| cut -c 9-15)
seq_name=${seg_prefix}
Expand Down
15 changes: 10 additions & 5 deletions sim/hugsim_env/envs/hug_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self, cfg, output):

self.ego_verts = np.array([[0.5, 0, 0.5], [0.5, 0, -0.5], [0.5, 1.0, 0.5], [0.5, 1.0, -0.5],
[-0.5, 0, -0.5], [-0.5, 0, 0.5], [-0.5, 1.0, -0.5], [-0.5, 1.0, 0.5]])
self.whl = np.array([1.6, 1.6, 3.0])
self.whl = np.array([1.6, 1.5, 3.0])
self.ego_verts *= self.whl
self.data_type = cfg.data_type

Expand Down Expand Up @@ -179,7 +179,7 @@ def route_completion(self):
(cam_poses[:, 0, 3] - self.vab[0])**2 + (cam_poses[:, 2, 3] - self.vab[1])**2
)
nearest_cam_idx = np.argmin(cam_dist, axis=0)
return (nearest_cam_idx + 1) / (cam_poses.shape[0] * 0.9)
return (nearest_cam_idx + 1) / (cam_poses.shape[0] * 0.9), cam_dist[nearest_cam_idx]


@property
Expand Down Expand Up @@ -209,7 +209,7 @@ def objs_list(self):
yaw = SCR.from_matrix(obj_b2w[:3, :3].detach().cpu().numpy()).as_euler('YXZ')[0]
# X, Y, Z in IMU, w, l, h
wlh = self.planner.wlhs[obj_id]
obj_boxes.append([obj_b2w[2, 3].item(), -obj_b2w[0, 3].item(), -obj_b2w[1, 3].item(), wlh[0], wlh[1], wlh[2], -yaw])
obj_boxes.append([obj_b2w[2, 3].item(), -obj_b2w[0, 3].item(), -obj_b2w[1, 3].item(), wlh[0], wlh[1], wlh[2], -yaw-0.5*np.pi])
return obj_boxes

def _get_obs(self):
Expand Down Expand Up @@ -304,9 +304,14 @@ def step(self, action):
if fg_collision:
terminated = True
print('Collision with foreground')
reward = -1000
reward = -100

rc = self.route_completion
rc, dist = self.route_completion
if dist > 10:
terminated=True
print('Far from preset trajectory')
reward = -50

if rc >= 1:
terminated = True
print('Complete')
Expand Down

0 comments on commit eca43ae

Please sign in to comment.