huawei-noah / SMARTS

Scalable Multi-Agent RL Training School for Autonomous Driving
MIT License
909 stars 184 forks source link

[Help Request] Need to customize vehicle parameters #2116

Closed Frzgunr1 closed 6 months ago

Frzgunr1 commented 7 months ago

High Level Description

I need to customize the parameters of the vehicle for my research using SMARTS, for example, I want to create a truck with a different crashbox than a normal vehicle and I want it to have a different color in the visualization.
 Which files do I need to modify in this case?
  Looking forward to your help, I will cite SMARTS in my paper. thank you very much!

Version

ver [1.4.0]

Operating System

ubuntu 20.04

Problems

No response

Frzgunr1 commented 7 months ago
  I noticed a previous issue mentioning the feature, but based on the description, it appears to be hidden. I'd like to know how to customize their crashboxes and specify colors (max acceleration and chassis if possible) after adding agents.
  If possible, could you please tell me in which files there are such cases, or a general approach on how to implement the feature.   
   THX!
Gamenot commented 7 months ago

Hello @Frzgunr1, I will look into this tomorrow to see what work would be involved.

Do you have a specific model of truck you are looking for? The main resource requirement is a urdf file of the vehicle you want.

Frzgunr1 commented 7 months ago
   Hi @Gamenot , I have not implemented a separate urdf modeling for truck at the moment, if possible you could use the truck mentioned in #767  instead. 
   Agent is always of type car when generated, however I noticed that the `SMARTS/smarts/ core/vehicle_state.py` file has some different vehicles than when the smarts are generated, hopefully it will be possible to implement the ability to specify the vehicle parameter of the agent (at least the collision box) when customizing the agent!
  Looking forward to hearing back from you!  :)
Gamenot commented 7 months ago

Hello @Frzgunr1, what is given in #767 is unfortunately just a set of visual models, it is still missing the dynamics model.

The two current physics models are hardcoded in vehicle.py to draw from smarts/core/models/ one of vehicle.urdf ("sedan") or bus.urdf ("bus") based on the value of AgentInterface.vehicle_type.

Question

What is your timeline?

Gamenot commented 7 months ago

Investigation

There are a few components to a vehicle within our simulation.

Selection (via AgentInterface)

Current vehicle selection is done in the agent interface: https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/agent_interface.py#L323-L326

And constrained: https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/agent_interface.py#L370

This currently is resolved to a urdf when the vehicle is constructed: https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/vehicle.py#L300-L305

Visuals

The vehicle state is where the visual representation of the vehicle is resolved and where the simulation is intended to redirect to the appropriate .glb. https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/vehicle_state.py#L50-L93

It also looks like there is currently a bug that does not forward the visual vehicle configuration and default dimensions when generating agents: https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/vehicle.py#L339-L343

This would normally be done through specifying vehicle_config_type (relating to VEHICLE_CONFIGS). https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/vehicle.py#L58-L70

Physics

The physics is represented in the following way:

Bus

https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/models/bus.urdf#L1-L135

Sedan

https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/models/vehicle.urdf#L1-L135

There appears to be a second bug related to vehicle selection in which the vehicle can only ever have the dimensions of the default "passenger" vehicle instead of using information from the AgentInterface.vehicle_type. https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/vehicle.py#L286 https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/vehicle.py#L248-L266

Controller

The controller arguments are currently defined here: https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/models/controller_parameters.yaml#L1-L51

It looks like there is a final bug where if a vehicle is replaced (rather than a new vehicle generated) no configuration is used and defaults to "sedan": https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/vehicle_index.py#L462

https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/chassis.py#L328-L342

https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/chassis.py#L52-L57

Configuration is intended to be provided such as with a newly generated vehicle: https://github.com/huawei-noah/SMARTS/blob/c2ebaaaca4eec8d122f7c75143b899b1611095c9/smarts/core/vehicle.py#L322-L330

Gamenot commented 7 months ago

Result

Frzgunr1 commented 7 months ago

Hi @Gamenot , you're right, thank you very much for your analyses, they are very accurate and readable, you're a great engineer. Considering the current situation, I am going to write the text part of the paper first. I will wait for you to finish this important work and, if there is any material I can provide, just tell me. THX :)

Gamenot commented 7 months ago

@Frzgunr1 I am about to start work on this, is there a particular grade of truck you are looking for?

Alternatively, the truck (7.1m 2.4m 2.4m) as is defined by SUMO.

Frzgunr1 commented 7 months ago

Sure,just use the truck (7.1m) as is defined by SUMO. Then We could make more customized vehicles!