I searched and studied about mavros and px4 but i can’t understand the role of mavros and structure.
Untile now, I understand mavros is protocol to communicate with ros. is i right means?
If there is diagram about mavros i can understand well.
also should i have to use mavros to connect between px4 and airsim simulator?
At the basic level, mavros provides an “easy” way for you to connect a ROS based system to a Mavlink based one, i.e. your flight controller. Usually, you may have an FCU and on top of that a routing layer like Mavproxy, mavlink-router, or something custom (or nothing if mavros is handling your serial communication). These elements speak Mavlink protocol. In order for a system which is ROS based to understand this protocol, and potentially receive/transmit data/commands, you would want to set-up a connection to the mavlink system using the libraries that are out there which abstract away a lot of the finer details of communicating across mavlink-based connections.
Mavros uses libraries like this to easily establish connections with objects that speak mavlink, and handle communication between mavlink and ROS-systems. ROS-systems use the pub/sub topic structure and their own messages based on ‘basic’ data types. So, sending a “command” on a ros-topic will not result in any action being taken, unless that command is then converted to mavlink and forwarded to the device properly. Mavros helps to abstract that conversion. Features are slowly being added to mavros as well, so more of the mavlink protocol is being exposed now through ros. This means you can get more of the data the FCU exposes, and also send more of the already long list of different commands supported in the mavlink-protocol from ros.
I can’t comment on what would be required for integration airsim with px4. But, you may start with some of the simpler sitl tutorials on the site (gazebo) and as you gain familiarity with how the simulation process works extend it to airsim.