huawei-noah / SMARTS

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

[Help Request] Convert observations into tensors #2098

Closed knightcalvert closed 1 year ago

knightcalvert commented 1 year ago

High Level Description

my simplified observations looks like:

({
    'Agent 0': {'active': 1, 'steps_completed': 1, Waypoint(pos=array([134.8,43.03544217]), heading=Heading(0.0)}, 
    'Agent 1': {'active': 1, 'steps_completed': 1}
},
{
    'Agent 0': {'score': 0, 'env_obs': 0, 'done': False, 'reward': 0, }, 
    'Agent 1': {'score': 0, 'env_obs': 0, 'done': False, 'reward': 0, }
})

Version

1.4.0

Operating System

No response

Problems

i can't convert this obs into tensorstensor = th.tensor(obs, dtype=dtype, device=self.device), i'm so confused about what type the waypoint or via etc. is, could someone give me a simple example about def get_obs(self): and def get_state(self): thank you for your reply

Adaickalavan commented 1 year ago

Hi @knightcalvert,

Observation for each individual agent is a dictionary with multiple key value pairs. Refer here and here, which describes the observation structure and the formatted observation.

We should cast the desired individual components of the observation to tensors, rather than casting the entire observation into a tensor.

If you need further clarification, providing a minimal working code along with the question, will enable us to provide more specific assistance.