utiasDSL / gym-pybullet-drones

PyBullet Gymnasium environments for single and multi-agent reinforcement learning of quadcopter control
https://utiasDSL.github.io/gym-pybullet-drones/
MIT License
1.24k stars 364 forks source link

how to generate gloabl rgba-view state in multi-agent context #127

Open fmxFranky opened 2 years ago

fmxFranky commented 2 years ago

In marl context, common-used CTDE(centralized training decentralized excution) methods(e.g. MAPPO, QMIX) need not only individual observations but also global state of the multi-agent system, how to get the rgba view of the state in the current multi-agent interface? Thanks a lot!

JacopoPan commented 1 year ago

You can simply use PyBullet's:

[w, h, rgb, dep, seg] = p.getCameraImage(width=self.VID_WIDTH,
                                                     height=self.VID_HEIGHT,
                                                     shadow=1,
                                                     viewMatrix=self.CAM_VIEW,
                                                     projectionMatrix=self.CAM_PRO,
                                                     renderer=p.ER_TINY_RENDERER,
                                                     flags=p.ER_SEGMENTATION_MASK_OBJECT_AND_LINKINDEX,
                                                     physicsClientId=self.CLIENT
                                                     )

in any subclass of BaseAviary to get a single frame from the main rendered camera view and use this to create a new observations space that includes it, if that's what you want to do for your approach.

MultiAgenAviary has an observations space that is made of dictionaries comprising of all individual agents' observations at each time step.