Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manipulating behavior of other vehicles #63

Open
abastola0 opened this issue Feb 20, 2024 · 3 comments
Open

Manipulating behavior of other vehicles #63

abastola0 opened this issue Feb 20, 2024 · 3 comments

Comments

@abastola0
Copy link

I wanted to alter the behavior of another vehicle so that it can for example overtake the default vehicle at certain point. I think there's a way where we can record the drive where we can overtake certain vehicle and later change the simulated vehicle to be non-default and the other one to be us. I wanted to this in digital twin obtained from waymo dataset but it seems to bit hard than what i expected. The other option i was thinking was executing IDM policy to navigate between points and provide some waypoints or a hand drawn line in the birds eye view where we can define the trajectory but the points seem to be in 3D so i'm not sure if changing only the 2D coordinates will be enough.

I was also thinking if this can be done with multi-agent planning but i'm not sure how to do this way.

Any of your suggestion would be highly appreciated.

@QuanyiLi
Copy link
Member

If you take a look at the ScenarioEnv, you will find other cars are controlled by ScenarioTrafficManager. If you set no_traffic=True, this manager will be canceled and thus no vehicles/objects are added into the scene except the ego vehicle. The code is at:
https://github.com/metadriverse/metadrive/blob/fc04519ff124670575eb3bba5cb9ea53587c3167/metadrive/envs/scenario_env.py#L123

Thus, to know how to change other car's behavior, you need to figure out how ScenarioTrafficManager works. By default, it replays the trajectories for all objects. But we also introduce a key, reactive_traffic, which, if enabled, can make other vehicles react to the ego car. If ego car behaves different from the recorded trajectory, for example, slowing down, the rear cars will slow down as well to avoid collision. I believe this is a good example that how we alter the behaviors of surrounding vehicles. Also, the documentation of MetaDrive provides detailed explanation of whole system: https://metadrive-simulator.readthedocs.io/en/latest/. It is worth to read it before you move forward.

If you are familiar with these stuff, the challenge now is how would you alter the trajectory of the target vehicle. The information you have is the original trajectory. Sometime, you can even find a path or route which leads you from start point to end point by BFS. Besides, each step, your vehicle can perceive the surrounding objects with pseudo-lidar. Thus, with these information you should be able to program a tiny self-driving system and allow it to overtake objects. But to be honest, this is as hard as building a driving system from scratch...

Let's go back to your idea. If you can pre-calculate the overtaking point and the overtaking trajectory from the top down view, yes, you can directly make a simple PID controller to track that trajectory. Actually, the IDM policy used in MetaDrive uses two PID controller to track the planned trajectories. When doing this, you may need some debug tools documented here: https://metadrive-simulator.readthedocs.io/en/latest/points_and_lines.html

@abastola0
Copy link
Author

Thus, to know how to change other car's behavior, you need to figure out how ScenarioTrafficManager works. By default, it replays the trajectories for all objects. But we also introduce a key, reactive_traffic, which, if enabled, can make other vehicles react to the ego car. If ego car behaves different from the recorded trajectory, for example, slowing down, the rear cars will slow down as well to avoid collision. I believe this is a good example that how we alter the behaviors of surrounding vehicles. Also, the documentation of MetaDrive provides detailed explanation of whole system: https://metadrive-simulator.readthedocs.io/en/latest/. It is worth to read it before you move forward.

Thanks Quanyi. I'll look at the PID tracking part and see if i can get things to work.

@mimjing
Copy link

mimjing commented Nov 11, 2024

I wanted to alter the behavior of another vehicle so that it can for example overtake the default vehicle at certain point. I think there's a way where we can record the drive where we can overtake certain vehicle and later change the simulated vehicle to be non-default and the other one to be us. I wanted to this in digital twin obtained from waymo dataset but it seems to bit hard than what i expected. The other option i was thinking was executing IDM policy to navigate between points and provide some waypoints or a hand drawn line in the birds eye view where we can define the trajectory but the points seem to be in 3D so i'm not sure if changing only the 2D coordinates will be enough.我想改变另一辆车的行为,以便它可以在某个时间点超车。我认为有一种方法可以记录驾驶过程,我们可以超车某辆车,然后将模拟车辆更改为非默认车辆,将另一辆车更改为我们。我想在从 waymo 数据集获得的数字孪生中做到这一点,但它似乎比我预期的要难。我在考虑的另一个选项是执行 IDM 策略以在点之间导航并在鸟瞰视图中提供一些航路点或手绘线,我们可以在其中定义轨迹,但这些点似乎是 3D 的,所以我不确定仅更改 2D 坐标是否足够。

I was also thinking if this can be done with multi-agent planning but i'm not sure how to do this way.我也在想这是否可以通过多代理规划来完成,但我不确定如何做到这一点。

Any of your suggestion would be highly appreciated.您的任何建议将不胜感激。

Hello, i want to know how about your work mentioned above? I used scenario_env, which is not suitable for IDMpolicy , so i use TrajectoryIDMPolicy. I need to define different trajectories for the surrounding car to make safe-critical scene for my RL-ego-car. I'm going to transform my .osm type map into a grid map , and then make an A* global route planning. But that would be very tough. Is your work going well? Can you give me some advice?
Appreciated for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants