How px4 firmware connects to the gazebo in code level?

I would like to know how the px4 firmware connects to the gazebo simulation in code level. Now I can fly the iris in gazebo through PX4Devguide.
But I would like to know which files the connection process is occurring and the principles of communications between px4 firmware and gazebo. Why drone in gazebo can move?
I have lost in the PX4 firmware code and I haven’t find any relevant information.
can someone help me? Thanks a lot.

I’m not familiar with this code, but I believe it’s entirely through mavlink.

MAVLINK_MSG_ID_HIL_GPS
MAVLINK_MSG_ID_HIL_SENSOR
MAVLINK_MSG_ID_DISTANCE_SENSOR
MAVLINK_MSG_ID_HIL_OPTICAL_FLOW
MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS

http://mavlink.org/messages/common

1 Like

@dagar
The gazebo_mavlink_interface.cpp shows how gazebo receives/sends mavlink messages, but where dose px4 firmware sends/receives mavlink messages from?
When px4 firmware connects a real drone, is the same method to send messages to drone as connectiong to simulation?

PX4 centralizes mavlink send/receive in the mavlink module here - https://github.com/PX4/Firmware/tree/master/src/modules/mavlink

A bit of an explanation here. http://dev.px4.io/concept-architecture.html

1 Like

Oh! You are a very nice person!:grinning::grinning::grinning: